npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bletchley-tech/stack

v1.0.0

Published

A native JavaScript implementation of the Stack data structure

Downloads

1

Readme

Stack.js

Stack.js provides a simple, fast, and flexible implementation of the stack data structure built natively in JavaScript.

Installation

$ npm install @bletchley-tech/stack

Usage

Stack provides a simple implementation of the stack data structure built natively in JavaScript for use in Node.js.

The package provides a single class, Stack, which is a simple implementation of the stack data structure. To use it, follow the steps below:

  1. Import/Require the Stack class:

    // CommonJS
    const Stack = require('@bletchley-tech/stack');
    
    // ES6+
    import Stack from '@bletchley-tech/stack';

    This will load the Stack class into the global scope.

  2. Create a new instance of Stack:

    const stack = new Stack();

    This will create a new instance of Stack and store it in the stack variable.

  3. Use the stack:

    stack.push(1); // Push 1 to top of the stack
    stack.stack; // "a"
    stack.pop(); // Pop the top item from the stack

    This will push 1 to the top of the stack, print the updated stack, and then pop the top item from the stack.

Stack Class

The Stack class has only one property, stack, which is an array of values. The specific functionality of the stack data structure is provided through class methods.

Class Methods

push(value)

The push method adds a value to the top of the stack.

stack.push("string"); // Push "string" to top of the stack

pushMany(values)

The pushMany method will push all of the values to the top of the stack.

stack.pushMany("string2", "string3"); // Push "string2" and "string3" to top of the stack

// or

stack.pushMany(["string2", "string3"]); // Push "string2" and "string3" to top of the stack

pop()

The pop method will pop the top item from the stack.

stack.pop(); // Pop the top item from the stack

clear()

The clear method will clear the stack.

stack.clear(); // Clear the stack

Class Attributes

size

stack.size; // Get the size of the stack

This will return the size of the stack.

isEmpty

stack.isEmpty; // Check if the stack is empty

This will return true if the stack is empty, false otherwise.

top

stack.top; // Get the top item from the stack

This will return the top item from the stack.

stack

stack.stack; // Print the stack as a formatted string

This will return the stack as a formatted string.

License

Stack is licensed under the MIT License (see the LICENSE file for more information).