Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bluebird-tools

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluebird-tools - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

tests/manipulation.specs.js

3

package.json
{
"name": "bluebird-tools",
"version": "1.1.0",
"version": "1.2.0",
"description": "",

@@ -29,4 +29,5 @@ "main": "src/index.js",

"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.2.0"
}
}

@@ -100,2 +100,12 @@ # Bluebird Tools

#### promise.whenLog(level, conditional, text, ...args) -> `promise`
```js
Promise.resolve(1).whenLog('into', x => x === 1, 'testing log', 1, 2, 3);
```
#### promise.unlessLog(level, conditional, text, ...args) -> `promise`
```js
Promise.resolve(1).unlessLog('into', x => x === 2, 'testing log', 1, 2, 3);
```
### Manipulating promises

@@ -102,0 +112,0 @@

@@ -58,2 +58,9 @@ const Promise = require('bluebird');

Promise.prototype.whenLog = function when(level, conditional, text, ...args) {
if (conditional(this.value())) {
Promise.log(level, text, ...args);
}
return this;
};
Promise.prototype.unless = function unless(conditional, fail) {

@@ -63,2 +70,9 @@ return this.iif(conditional, echo, fail);

Promise.prototype.unlessLog = function unless(level, conditional, text, ...args) {
if (!conditional(this.value())) {
Promise.log(level, text, ...args);
}
return this;
};
Promise.convert = function convert(promise) {

@@ -65,0 +79,0 @@ return new Promise((resolve, reject) => {

@@ -0,0 +0,0 @@ const Promise = require('../src');

@@ -254,2 +254,30 @@ const Promise = require('../src');

});
context('#whenLog', () => {
it('when the result is true, must log', (done) => {
const level = 'error';
const message = 'log test';
Promise.configureLog((l, msg) => {
assert.equal(l, level);
assert.equal(msg, message);
done();
});
Promise.resolve(3)
.whenLog(level, x => x === 3, message)
});
it('when the result is false, must not execute the method', (done) => {
const level = 'error';
const message = 'log test';
Promise.configureLog(() => {
done({ message: 'has logged' });
});
Promise.resolve(2)
.whenLog(level, x => x === 3, message)
.then(() => done());
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc