tiny-stack
Tiny stack for browser or server
Last updated 6 years ago by avoidwork .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install tiny-stack 
SYNC missed versions from official npm registry.

Tiny Stack

Stack for Client or Server.

build status

API

clear

Clears the stack

length

Gets the length/size of the stack

peek

Gets the top item of the stack

pop

Gets & removes the top item of the stack

push

Adds an item to the top the stack

empty

Tests if this stack is empty

search

Returns the 1-based position where an object is on this stack

Example

const stack = require("tiny-stack"),
    mystack = stack(),
    jane = {name: "Jane Doe"},
    john = {name: "John Doe"};

mystack.length(); // 0
mystack.empty(); // true
mystack.push(john);
mystack.push(jane);
mystack.length(); // 2
mystack.search(jane); // 1
mystack.search(john); // 2
mystack.search({}); // -1
mystack.empty(); // false
mystack.peek(); // {name: "Jane Doe"}
mystack.pop();
mystack.length(); // 1
mystack.peek(); // {name: "John Doe"}
mystack.clear();
mystack.length(); // 0

License

Copyright (c) 2018 Jason Mulligan Licensed under the BSD-3-Clause license.

Current Tags

  • 2.0.1                                ...           latest (6 years ago)

5 Versions

  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           9 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 6
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (11)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |