stack.js
Stack implementation in TypeScript for Node and the browser.
Stacks are data containers that can only be accessed (read or modified) at the top. This library enables you to use and manage stacks, limited or not, persistent or not.
Installing
npm i stacked.js
Usage
On Node (ES5):
const stackJS =
On Node (ES6+):
On browsers (locally):
On browsers (CDN):
Example
const stackJS = // Standard unlimited stacklet myStack = myStackmyStackmyStack console // "c"console // 2 let anotherStack = anotherStackanotherStack // Swapping stacksanotherStack console // [1,2] // Limit the amount of itemsmyStackmyStack console // [2,3] // You can also initialize a limited stack. Just do so:let myLimitedStack = 2 // Persistent stack using localstorage-ponyfillconst createLocalStorage = const localStorage = let myPersistentStack = Infinity localStorage // Let's test itif myPersistentStacksize > 0 console else console myPersistentStack
Contributing
- Install TypeScript
- Clone this repo &
npm i
- Hack
npm run build
& PR
License
MIT.