Socket
Socket
Sign inDemoInstall

bluebird

Package Overview
Dependencies
Maintainers
1
Versions
223
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluebird - npm Package Compare versions

Comparing version 0.9.11-1 to 0.10.0-0

js/main/direct_resolve.js

94

API.md

@@ -11,2 +11,4 @@ #API Reference

- [`.done([Function fulfilledHandler] [, Function rejectedHandler ] [, Function progressHandler ])`](#donefunction-fulfilledhandler--function-rejectedhandler---function-progresshandler----promise)
- [`.return(dynamic value)`](#returndynamic-value---promise)
- [`.throw(dynamic reason)`](#throwdynamic-reason---promise)
- [`Promise.try(Function fn [, Array<dynamic>|dynamic arguments] [, dynamic ctx] )`](#promisetryfunction-fn--arraydynamicdynamic-arguments--dynamic-ctx----promise)

@@ -453,2 +455,48 @@ - [`Promise.fulfilled(dynamic value)`](#promisefulfilleddynamic-value---promise)

#####`.return(dynamic value)` -> `Promise`
Convenience method for:
```js
.then(function() {
return value;
});
```
in the case where `value` doesn't change its value.
That means `value` is bound at the time of calling `.return()` so this will not work as expected:
```js
function getData() {
var data;
return query().then(function(result) {
data = result;
}).return(data);
}
```
because `data` is `undefined` at the time `.return` is called.
*For compatibility with earlier ECMAScript version, an alias `.thenReturn()` is provided for `.return()`.*
<hr>
#####`.throw(dynamic reason)` -> `Promise`
Convenience method for:
```js
.then(function() {
throw reason;
});
```
Same limitations apply as with `.return()`.
*For compatibility with earlier ECMAScript version, an alias `.thenThrow()` is provided for `.throw()`.*
<hr>
#####`Promise.try(Function fn [, Array<dynamic>|dynamic arguments] [, dynamic ctx] )` -> `Promise`

@@ -477,2 +525,48 @@

#####`Promise.method(Function fn)` -> `Function`
Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
This method is convenient when a function can sometimes return synchronously or throw synchronously.
Example without using `Promise.method`:
```js
MyClass.prototype.method = function(input) {
if (!this.isValid(input)) {
return Promise.rejected(new TypeError("input is not valid"));
}
if (this.cache(input)) {
return Promise.fulfilled(this.someCachedValue);
}
return db.queryAsync(input).then(function(value) {
this.someCachedValue = value;
return value;
});
};
```
Using the same function `Promise.method`, there is no need to manually wrap direct return or throw values into a promise:
```js
MyClass.prototype.method = Promise.method(function(input) {
if (!this.isValid(input)) {
throw new TypeError("input is not valid");
}
if (this.cachedFor(input)) {
return this.someCachedValue;
}
return db.queryAsync(input).bind(this).then(function(value) {
this.someCachedValue = value;
return value;
});
});
```
<hr>
#####`Promise.fulfilled(dynamic value)` -> `Promise`

@@ -479,0 +573,0 @@

@@ -0,1 +1,54 @@

## 0.10.0-0 (2013-11-17)
Features:
- Implement `Promise.method()`
- Implement `.return()`
- Implement `.throw()`
Bugfixes:
- Fix promises being able to use themselves as resolution or follower value
## 0.9.11-1 (2013-11-14)
Features:
- Implicit `Promise.all()` when yielding an array from generators
## 0.9.11-0 (2013-11-13)
Bugfixes:
- Fix `.spread` not unwrapping thenables
## 0.9.10-2 (2013-11-13)
Features:
- Improve performance of promisified functions on V8
Bugfixes:
- Report unhandled rejections even when long stack traces are disabled
- Fix `.error()` showing up in stack traces
## 0.9.10-1 (2013-11-05)
Bugfixes:
- Catch filter method calls showing in stack traces
## 0.9.10-0 (2013-11-05)
Bugfixes:
- Support primitives in catch filters
## 0.9.9-0 (2013-11-05)
Features:
- Add `Promise.race()` and `.race()`
## 0.9.8-0 (2013-11-01)

@@ -2,0 +55,0 @@

9

Gruntfile.js

@@ -16,4 +16,5 @@ "use strict";

"internet explorer|Windows XP": ["7"],
"internet explorer|Windows 7": ["8", "9", "10"],
"internet explorer|Windows 8.1": ["11"],
"internet explorer|Windows 7": ["8"],
"internet explorer|WIN8": ["10"],
"internet explorer|WIN8.1": ["11"],
"firefox|Windows 7": ["3.5", "3.6", "4", "25"],

@@ -264,2 +265,3 @@ "chrome|Windows 7": null,

src: [
"./src/direct_resolve.js",
"./src/synchronous_inspection.js",

@@ -521,3 +523,4 @@ "./src/simple_thenables.js",

"./src/promise_resolver.js",
"./src/promise_spawn.js"
"./src/promise_spawn.js",
"./src/direct_resolve.js"
];

@@ -524,0 +527,0 @@

@@ -59,2 +59,5 @@ /**

var makeSelfResolutionError = function Promise$_makeSelfResolutionError() {
return new TypeError( "Resolving promises cyclically" );
};

@@ -260,2 +263,12 @@ function isPromise( obj ) {

Promise.method = function Promise$_Method( fn ) {
if( typeof fn !== "function" ) {
throw new TypeError( "fn must be a function" );
}
return function PromiseMethod() {
var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
return Promise.attempt( fn, args, this );
};
};
Promise["try"] = Promise.attempt = function Promise$_Try( fn, args, ctx ) {

@@ -315,2 +328,3 @@

Promise.onPossiblyUnhandledRejection =

@@ -628,9 +642,8 @@ function Promise$OnPossiblyUnhandledRejection( fn ) {

else if( x === promise ) {
var selfResolutionError =
new TypeError( "Circular thenable chain" );
this._attachExtraTrace( selfResolutionError );
var err = makeSelfResolutionError();
this._attachExtraTrace( err );
async.invoke(
promise._reject,
promise,
selfResolutionError
err
);

@@ -694,3 +707,4 @@ }

if( !isPromise( value ) ||
this._isFollowingOrFulfilledOrRejected() ) return false;
this._isFollowingOrFulfilledOrRejected() ||
value === this ) return false;

@@ -811,21 +825,2 @@ this._assumeStateOf( value, mustAsync );

Promise.prototype._resolveFulfill = function Promise$_resolveFulfill( value ) {
this._cleanValues();
this._setFulfilled();
this._resolvedValue = value;
var len = this._length();
this._setLength( 0 );
for( var i = 0; i < len; i+= 5 ) {
if( this._fulfillAt( i ) !== void 0 ) {
async.invoke( this._doResolveAt, this, i );
}
else {
var promise = this._promiseAt( i );
this._unsetAt( i );
async.invoke( promise._fulfill, promise, value );
}
}
};
Promise.prototype._resolveLast = function Promise$_resolveLast( index ) {

@@ -858,3 +853,32 @@ this._setLength( 0 );

Promise.prototype._resolveFulfill = function Promise$_resolveFulfill( value ) {
if( value === this ) {
var err = makeSelfResolutionError();
this._attachExtraTrace( err );
return this._resolveReject( err );
}
this._cleanValues();
this._setFulfilled();
this._resolvedValue = value;
var len = this._length();
this._setLength( 0 );
for( var i = 0; i < len; i+= 5 ) {
if( this._fulfillAt( i ) !== void 0 ) {
async.invoke( this._doResolveAt, this, i );
}
else {
var promise = this._promiseAt( i );
this._unsetAt( i );
async.invoke( promise._fulfill, promise, value );
}
}
};
Promise.prototype._resolveReject = function Promise$_resolveReject( reason ) {
if( reason === this ) {
var err = makeSelfResolutionError();
this._attachExtraTrace( err );
return this._resolveReject( err );
}
this._cleanValues();

@@ -965,2 +989,3 @@ this._setRejected();

require( "./direct_resolve.js" )( Promise );
Promise.CancellationError = CancellationError;

@@ -967,0 +992,0 @@ Promise.TimeoutError = TimeoutError;

@@ -59,2 +59,5 @@ /**

var makeSelfResolutionError = function Promise$_makeSelfResolutionError() {
return new TypeError( "Resolving promises cyclically" );
};

@@ -260,2 +263,12 @@ function isPromise( obj ) {

Promise.method = function Promise$_Method( fn ) {
if( typeof fn !== "function" ) {
throw new TypeError( "fn must be a function" );
}
return function PromiseMethod() {
var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
return Promise.attempt( fn, args, this );
};
};
Promise["try"] = Promise.attempt = function Promise$_Try( fn, args, ctx ) {

@@ -315,2 +328,3 @@

Promise.onPossiblyUnhandledRejection =

@@ -628,6 +642,5 @@ function Promise$OnPossiblyUnhandledRejection( fn ) {

else if( x === promise ) {
var selfResolutionError =
new TypeError( "Circular thenable chain" );
this._attachExtraTrace( selfResolutionError );
promise._reject(selfResolutionError);
var err = makeSelfResolutionError();
this._attachExtraTrace( err );
promise._reject(err);
}

@@ -690,3 +703,4 @@ else {

if( !isPromise( value ) ||
this._isFollowingOrFulfilledOrRejected() ) return false;
this._isFollowingOrFulfilledOrRejected() ||
value === this ) return false;

@@ -807,21 +821,2 @@ this._assumeStateOf( value, mustAsync );

Promise.prototype._resolveFulfill = function Promise$_resolveFulfill( value ) {
this._cleanValues();
this._setFulfilled();
this._resolvedValue = value;
var len = this._length();
this._setLength( 0 );
for( var i = 0; i < len; i+= 5 ) {
if( this._fulfillAt( i ) !== void 0 ) {
this._doResolveAt(i);
}
else {
var promise = this._promiseAt( i );
this._unsetAt( i );
promise._fulfill(value);
}
}
};
Promise.prototype._resolveLast = function Promise$_resolveLast( index ) {

@@ -854,3 +849,32 @@ this._setLength( 0 );

Promise.prototype._resolveFulfill = function Promise$_resolveFulfill( value ) {
if( value === this ) {
var err = makeSelfResolutionError();
this._attachExtraTrace( err );
return this._resolveReject( err );
}
this._cleanValues();
this._setFulfilled();
this._resolvedValue = value;
var len = this._length();
this._setLength( 0 );
for( var i = 0; i < len; i+= 5 ) {
if( this._fulfillAt( i ) !== void 0 ) {
this._doResolveAt(i);
}
else {
var promise = this._promiseAt( i );
this._unsetAt( i );
promise._fulfill(value);
}
}
};
Promise.prototype._resolveReject = function Promise$_resolveReject( reason ) {
if( reason === this ) {
var err = makeSelfResolutionError();
this._attachExtraTrace( err );
return this._resolveReject( err );
}
this._cleanValues();

@@ -961,2 +985,3 @@ this._setRejected();

require( "./direct_resolve.js" )( Promise );
Promise.CancellationError = CancellationError;

@@ -963,0 +988,0 @@ Promise.TimeoutError = TimeoutError;

{
"name": "bluebird",
"description": "Full featured Promises/A+ implementation with exceptionally good performance",
"version": "0.9.11-1",
"version": "0.10.0-0",
"keywords": [

@@ -6,0 +6,0 @@ "promise",

Sorry, the diff of this file is not supported yet

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