1.0.4 • Published 6 years ago

@fabiospampinato/fifo v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

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

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago