• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / js-slang / 23995741899

05 Apr 2026 06:14AM UTC coverage: 77.093% (+0.002%) from 77.091%
23995741899

push

github

web-flow
Upgrade to TypeScript 6 and Prettier improvements (#1936)

* Upgrade TypeScript to v6

* Fix import source

* Fix tsconfig

* Fix preexisting type errors

* Remove scm-slang

* Bump node types

* Fix tsconfig

* Fix node types specifier

* Enable trailing commas

* Enable semicolons

* Check and commit files with changed line numbers

* Update Yarn to 4.13.0

* Remove unneeded sicp package deps

3112 of 4282 branches covered (72.68%)

Branch coverage included in aggregate %.

3761 of 5218 new or added lines in 152 files covered. (72.08%)

26 existing lines in 9 files now uncovered.

7136 of 9011 relevant lines covered (79.19%)

175254.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/src/cse-machine/stack.ts
1
/**
2
 * Stack is implemented for control and stash registers.
3
 */
4
interface IStack<T> {
5
  push(...items: T[]): void;
6
  pop(): T | undefined;
7
  peek(): T | undefined;
8
  size(): number;
9
  isEmpty(): boolean;
10
  getStack(): T[];
11
}
12

13
export class Stack<T> implements IStack<T> {
14
  // Bottom of the array is at index 0
15
  private storage: T[] = [];
1,882✔
16

17
  public constructor() {}
18

19
  public push(...items: T[]): void {
20
    for (const item of items) {
11,049,819✔
21
      this.storage.push(item);
11,488,789✔
22
    }
23
  }
24

25
  public pop(): T | undefined {
26
    return this.storage.pop();
10,686,077✔
27
  }
28

29
  public peek(): T | undefined {
30
    if (this.isEmpty()) {
8,092,534✔
31
      return undefined;
21,106✔
32
    }
33
    return this.storage[this.size() - 1];
8,071,428✔
34
  }
35

36
  public size(): number {
37
    return this.storage.length;
23,964,919✔
38
  }
39

40
  public isEmpty(): boolean {
41
    return this.size() == 0;
15,342,309✔
42
  }
43

44
  public getStack(): T[] {
45
    // return a copy of the stack's contents
46
    return [...this.storage];
16✔
47
  }
48

49
  public some(predicate: (value: T) => boolean): boolean {
NEW
50
    return this.storage.some(predicate);
×
51
  }
52

53
  // required for first-class continuations,
54
  // which directly mutate this stack globally.
55
  public setTo(otherStack: Stack<T>): void {
56
    this.storage = otherStack.storage;
2✔
57
  }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc