JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4174
  • Score
    100M100P100Q121366F
  • License MIT

Always will expose native `Promise` if available, otherwise `Bluebird` but only if you don't give another promise module like `q` or `promise` or what you want.

Package Exports

  • native-or-another

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (native-or-another) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

native-or-another npmjs.com The MIT License

Always will expose native Promise if available, otherwise Bluebird but only if you don't give another promise module like q or promise or what you want.

Heads up: v3 is here! See the changelog.md

code climate standard code style travis build status coverage status dependency status

Install

npm i native-or-another --save

Usage

For more use-cases see the tests

const getPromise = require('native-or-another')

nativeOrAnother

Always will expose native Promise if available. Otherwise given promise module or Bluebird.

  • [Prome] {Function} custom promise module
  • returns {Function} native Promise or another

Example

const fs = require('fs')
const NativeOrBluebird = getPromise()
const NativeOrPromise = getPromise(require('promise'))
const NativeOrPinkie = getPromise(require('pinkie'))
const NativeOrQ = getPromise(require('q'))

const promise = new NativeOrBluebird((resolve, reject) => {
  fs.readFile('package.json', 'utf-8', (err, res) => {
    if (err) return reject(err)
    resolve(res)
  })
})

promise.then(data => {
  console.log(JSON.parse(data).name)
  //=> 'native-or-another'
})
  • always-done: Handles completion and errors of anything!
  • always-promise: Promisify basically everything.
  • always-thunk: Create thunk from anything, works like thunkify. Transforms anything (callbacks, streams, promises, observables, child processes, sync and generator functions) to thunk.
  • redolent: Simple promisify a callback-style function with sane defaults.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github