1.0.2 • Published 8 years ago

@f/queue v1.0.2

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

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