Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stack-list

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stack-list

A simple stack list data structure.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

stack-list

A Node.js JavaScript implementation of the stack data type. Supporting both LIFO via push() and pop(), and FIFO via push() and shift().

npm install stack-list

Syntax

new StackList(initialValue);

Parameters

initialValue

An Array of values of any type to initially populate the stack list.

Methods

push()

Push a new value to the top of the stack.

pop()

Take the top most value off the list and return it.

shift()

Take the bottom most value off the list and return it.

peek()

View the top most value on the list.

inspect()

View the bottom most value on the list.

clear()

Reset to an empty list.

Properties

size

The number of elements in the list. Also available under alias property length.

Examples

const StackList = require('stack-list');

let list = new StackList(['Hey']); // Optional initial values

// Push
list.push('Mate');

// Get size
list.size; // 2

// Peek top value
list.peek(); // 'Mate'

// Pop top value
list.pop(); // 'Mate'
list.pop(); // 'Hey'

// Clear stack
list.clear();

Keywords

FAQs

Package last updated on 09 Oct 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc