@zerodep/struct-stack
v2.0.6
Published
A factory that returns an optionally-typed Stack data structure instance.
Downloads
20
Readme
@zerodep/struct-stack
A factory function that returns an optionally-typed Stack data structure instance
Full documentation is available at the zerodep.app page.
Examples
All @zerodep packages support both ESM and CJS.
import { structStackFactory } from '@zerodep/struct-stack';
// or
const { structStackFactory } = require('@zerodep/struct-stack');
Use Case
const stack = structStackFactory(['a', 'b']);
// add items to the stack
stack.push('c');
stack.push('d');
// size()
stack.size(); // 4
// pop()
stack.pop(); // "d"
// peek()
stack.peek(); // "c"
// toArray()
stack.toArray(); // ["a", "b", "c"]