promise-once

1.0.2 • Public • Published

promise-once Build Status Dependency Status devDependency Status

Wrap a promise constructor to return the same promise everytime.

It's once for promises.

npm install promise-once --save

Usage

var i = 0;
var incrementOnce = require('promise-once')(increment);
 
incrementOnce()
  .then(incrementOnce)
  .then(incrementOnce)
  .then(incrementOnce)
  .then(incrementOnce)
  .then(incrementOnce)
  .then(console.log)
 
// `1` is written to the console
 
function increment() {
  i++;
}

Default is to use promise but you can pass your shim along:

var promiseOnce = require('promise-once');
promiseOnce.Promise = require('es6-promise');

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    1
  • 1.0.1
    1

Package Sidebar

Install

npm i promise-once

Weekly Downloads

2

Version

1.0.2

License

ISC

Last publish

Collaborators

  • vvo