ts-data.stack
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

ts-data.stack

A stack implemented in TypeScript.

Installation

$ npm install ts-data.stack

Usage

import Stack from "ts-data.stack";

let stack = new Stack<number>();

stack.push(3);
stack.push(7);

stack.count(); // 2
stack.isEmpty(); // false

stack.peek(); // 7

stack.pop(); // 7
stack.pop(); // 3

stack.isEmpty(); // true

Documentation

Stack<TData>()

A stack containing TData types. The constructor takes no arguments.

count(): number

Get the count of items in the stack.

isEmpty(): boolean

True if the stack is empty, false if it contains any elements.

push(value: TData): void

Pushes value to the top of the stack.

pop(): TData

Pop the top value off of the stack and return it.

peek(): TData

Get the top value of the stack without removing it from the stack.

License

Licensed under the MIT License.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i ts-data.stack

    Weekly Downloads

    154

    Version

    1.0.6

    License

    MIT

    Last publish

    Collaborators

    • jameskmonger