@fabiospampinato/fifo
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Fifo

Simple FIFO queue implementation.

Install

$ npm install --save @fabiospampinato/fifo

Usage

import FIFO from '@fabiospampinato/fifo';

const queue = new FIFO ();

queue.add ( 'foo' ).add ( 'bar' ).add ( 'baz' );

queue.next (); // foo
queue.next (); // bar
queue.next (); // baz
queue.next (); // undefined

API

new FIFO ( queue? )

Returns an instance of FIFO. If queue is passed the queue will be setted to that.

.get (): queue

Returns the queue.

.next (): any

Returns the next element in the queue.

.set ( queue: queue = [] ): this

Sets the queue to queue.

.reset (): this

Empties the queue.

.add ( element: any ): this

Adds an element to the queue.

License

MIT © Fabio Spampinato

Dependents (1)

Package Sidebar

Install

npm i @fabiospampinato/fifo

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

9.22 kB

Total Files

13

Last publish

Collaborators

  • fabiospampinato