@f/queue

1.0.2 • Public • Published

queue

Build status Git tag NPM version Code style

Simple function queue

Installation

$ npm install @f/queue

Usage

var createQueue = require('@f/queue')
var queue = createQueue()

queue.push(function () {
  console.log('hello world')
})

queue.flush()

Or in ES6:

import createQueue from '@f/queue'

const {add, flush} = createQueue()
add(() => console.log('hello world'))

setTimeout(flush)

API

queue()

Returns: An object containing two functions, add and flush:

  • add(fn) - Add fn to the queue.
  • flush() - Flush the queue - i.e., run all the fns, clear the queue, and return an array of their return values.

Note that queue does not use a prototype, so you can call flush and add without invoking them on the queue object.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @f/queue

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • f