Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

fabiospampinato/FIFO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple FIFO queue implementation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published