promise-set

1.0.0 • Public • Published

promise-set

JavaScript Style Guide dependencies status devDependencies status Travis CI downloads version license

Requirements

  • ECMAScript 6 supports
  • V8 > 5.0.0
  • Node > 6.0.0
  • Chrome > 50.0.0

Usage

Import

XPromiseSet

There're two ways to import this class

const XPromiseSet = require('promise-set/x')
const {XPromiseSet} = require('promise-set')

Usage

XPromiseSet(XPromise, XSet)
  // XPromise and XSet might be either es6 Promise and Set or custom classes or undefined

PromiseSet

It's just XPromiseSet(Promise, Set)

const PromiseSet = require('promise-set')

Methods

getter .all

  • Returns: A XPromise instance

Equivalent to XPromise::all

getter .race

  • Returns: A XPromise instance

Equivalent to XPromise::race

.toPromiseSet()

  • Arguments: None
  • Returns: A XPromiseSet instance

.map(onfulfill, onreject)

  • Arguments: Two functions onfulfill and onreject that take 1 argument and return value to resolve or throw exception to reject
  • Returns: Delivered object of 'this' (PromiseSet instance)

.filter(onfulfill, onreject)

  • Arguments: Two functions onfulfill and onreject that take 1 argument and return a boolean
  • Returns: Delivered object of 'this' (PromiseSet instance)

Example

const XPromiseSet = require('promise-set/x')
const MyPromiseSet = XPromiseSet(MyPromiseClass, MyIterableSetClass)
const promiseset = new MyPromiseSet(
  mypromiseexecutor, // fn (resolve: fn (?) -> void, reject: fn (?) -> void) -> void
  mypromiseobject, // instance of MyPromiseClass
  ...etc
)
promiseset
  .mapExecutor(
    onfulfill, // fn (val: ?, resolve: fn (?) -> void, reject: fn (?) -> void) -> void
    onreject
  )
  .map(
    onfulfill, // fn (val: ?) !> ? -> ?
    onreject
  )
  .filter(
    onfulfill, // fn (val: ?) -> bool
    onreject
  )

Package Sidebar

Install

npm i promise-set

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • khai96_