New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dastack

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dastack

A stack written in clean es5

latest
Source
npmnpm
Version
0.0.5
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

dastack Build Status

All of the implementations of stacks I found attached everything to the prototype and didn't make good use of private encapsulation, getters, non-enumerable methods, etc.

So here it is, a clean implementation of a stack written in straight simple es5.

API

Create a stack

var createStack = require('dastack');

var stack = createStack(); // => Creates an empty stack

var stack = createStack(1, 2, 3); // => Creates a stack with initial values

stack.size

The only property on the stack is size, works exactly the same as the length property on Array.

var stack = createStack(1, 2, 3);

stack.size // => 3

stack.push()

Add a new element to the top of the stack.

var stack2 = createStack(1, 2, 3);

stack.size // => 3

stack.pop()

Remove the top element from the top of the stack.

var stack = createStack(1, 2, 3);

stack.pop() // => 3

stack.size // => 2

stack.peek()

Get the top element from the top of the stack, but do not remove it.

var stack = createStack(1, 2, 3);

stack.peek() // => 3

stack.size // => 3

stack.clear()

Empty the stack.

var stack = createStack(1, 2, 3);

stack.clear()

stack.size // => 0

stack.toString()

Get the current stack as a string.

var stack = createStack(1, 2, 3);

stack.toString() // => "1,2,3"

stack.toArray()

Copy the current stack into a regular array.

var stack = createStack(1, 2, 3);

stack.toArray() // => [1, 2, 3]

Keywords

stack

FAQs

Package last updated on 18 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts