native-or-bluebird
Advanced tools
Comparing version 1.0.0 to 1.1.0
12
index.js
var _Promise | ||
try { | ||
_Promise = require('bluebird') | ||
} catch (_) { | ||
_Promise = global.Promise | ||
} | ||
module.exports = require('./promise') | ||
if (!_Promise) { | ||
/* istanbul ignore next */ | ||
if (!module.exports) { | ||
console.error('Neither `bluebird` nor the native `Promise` functions were found.') | ||
@@ -14,3 +10,1 @@ console.error('Please install `bluebird` yourself.') | ||
} | ||
module.exports = _Promise |
{ | ||
"name": "native-or-bluebird", | ||
"description": "use either the native Promise or Bluebird", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -17,3 +17,13 @@ "name": "Jonathan Ong", | ||
"promises" | ||
] | ||
], | ||
"devDependencies": { | ||
"bluebird": "*", | ||
"istanbul": "0", | ||
"mocha": "1" | ||
}, | ||
"scripts": { | ||
"test": "mocha --reporter spec", | ||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", | ||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" | ||
} | ||
} |
@@ -5,6 +5,12 @@ | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Dependency Status][david-image]][david-url] | ||
[![License][license-image]][license-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
Use either `bluebird` or the native `Promise` implementation. | ||
If no implementation is found, an error will be thrown: | ||
```js | ||
@@ -14,11 +20,31 @@ var Promise = require('native-or-bluebird'); | ||
You must install `bluebird` yourself for maximum compatibility. | ||
The goal of this library is to be able to eventually remove this line | ||
from your code and use native `Promise`s, allowing you to | ||
to write future-compatible code with ease. | ||
You should install `bluebird` in your libraries for maximum compatibility. | ||
[npm-image]: https://img.shields.io/npm/v/native-or-bluebird.svg?style=flat | ||
If you do not want an error to be thrown, | ||
`require()` the `Promise` implementation directly. | ||
If no implementation is found, `undefined` will be returned. | ||
```js | ||
var Promise = require('native-or-bluebird/promise'); | ||
if (Promise) // do stuff with promises | ||
``` | ||
[npm-image]: https://img.shields.io/npm/v/native-or-bluebird.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/native-or-bluebird | ||
[travis-image]: https://img.shields.io/travis/normalize/native-or-bluebird.svg?style=flat | ||
[github-tag]: http://img.shields.io/github/tag/normalize/native-or-bluebird.svg?style=flat-square | ||
[github-url]: https://github.com/normalize/native-or-bluebird/tags | ||
[travis-image]: https://img.shields.io/travis/normalize/native-or-bluebird.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/normalize/native-or-bluebird | ||
[coveralls-image]: https://img.shields.io/coveralls/normalize/native-or-bluebird.svg?style=flat | ||
[coveralls-image]: https://img.shields.io/coveralls/normalize/native-or-bluebird.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/normalize/native-or-bluebird?branch=master | ||
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat | ||
[david-image]: http://img.shields.io/david/normalize/native-or-bluebird.svg?style=flat-square | ||
[david-url]: https://david-dm.org/normalize/native-or-bluebird | ||
[license-image]: http://img.shields.io/npm/l/native-or-bluebird.svg?style=flat-square | ||
[license-url]: LICENSE | ||
[downloads-image]: http://img.shields.io/npm/dm/native-or-bluebird.svg?style=flat-square | ||
[downloads-url]: https://npmjs.org/package/native-or-bluebird | ||
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square | ||
[gittip-url]: https://www.gittip.com/jonathanong/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5259
8
35
49
3