Materialises source into a stack (LIFO).
Type of elements within source.
The source iterable.
Optional
Optional equality comparator used by the resulting stack.
A stack whose top element corresponds to the last element of source.
The entire sequence is enumerated immediately.
const numbers = [1, 2, 3];const stack = toStack(numbers);console.log(stack.peek()); // 3console.log(stack.pop().peek()); // 2 Copy
const numbers = [1, 2, 3];const stack = toStack(numbers);console.log(stack.peek()); // 3console.log(stack.pop().peek()); // 2
Materialises source into a stack (LIFO).