bluebird-tools
Advanced tools
Comparing version 1.3.1 to 1.3.2
{ | ||
"name": "bluebird-tools", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -123,6 +123,13 @@ # Bluebird Tools | ||
#### Promise.convert(promise) -> promise | ||
#### Promise.convert(promise) -> `promise` | ||
Converts a native promise to a BluebirdTools promise | ||
```js | ||
Promise.convert(promise) | ||
``` | ||
``` | ||
#### promise.isBluebird -> `bool` | ||
Converts a native promise to a BluebirdTools promise | ||
```js | ||
if (Promise.resolve().isBluebird) { // true | ||
} | ||
``` |
@@ -94,8 +94,12 @@ const Promise = require('bluebird'); | ||
Promise.prototype.isBluebird = true; | ||
Promise.convert = function convert(promise) { | ||
return new Promise((resolve, reject) => { | ||
promise | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
return promise.isBluebird | ||
? promise | ||
: new Promise((resolve, reject) => { | ||
promise | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
@@ -102,0 +106,0 @@ |
@@ -10,6 +10,19 @@ const BluebirdPromise = require('../src'); | ||
assert.isFunction(promise['iif']); | ||
assert.isNotFunction(vanillaPromise['iif']); | ||
assert.isUndefined(vanillaPromise.isBluebird); | ||
assert.isTrue(promise.isBluebird); | ||
}); | ||
}); | ||
context('#isBluebird', () => { | ||
it('a vanilla Promise must have isBluebird as undefined', () => { | ||
const promise = Promise.resolve(); | ||
assert.isUndefined(promise.isBluebird); | ||
}); | ||
it('a Bluebird Promise must set isBluebird true', () => { | ||
const promise = BluebirdPromise.resolve(); | ||
assert.isTrue(promise.isBluebird); | ||
}); | ||
}); | ||
}); |
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
18124
397
135