@strong-roots-capital/finite-stack
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

finite-stack Build status npm version codecov

Append-only LIFO stack with finite history

Install

npm install @strong-roots-capital/finite-stack

Use

import * as Stack from '@strong-roots-capital/finite-stack'

const emptyStack: Stack.EmptyStack<number> = Stack.stack<number>(2)

let nonEmptyStack: Stack.NonEmptyStack<number> = Stack.push(0)(emptyStack)
console.log(Stack.toArray(nonEmptyStack))
//=>[ 0 ]

nonEmptyStack = Stack.push(1)(nonEmptyStack)
console.log(Stack.toArray(nonEmptyStack))
//=>[ 1, 0 ]

nonEmptyStack = Stack.push(2)(nonEmptyStack)
console.log(Stack.toArray(nonEmptyStack))
//=>[ 2, 1 ]

Related

Acknowledgments

Package Sidebar

Install

npm i @strong-roots-capital/finite-stack

Weekly Downloads

0

Version

2.0.2

License

ISC

Unpacked Size

6.35 kB

Total Files

4

Last publish

Collaborators

  • hamroctopus
  • amchelle