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.10.0-1 to 0.10.1-0

benchmark/package.json

58

API.md

@@ -15,5 +15,5 @@ #API Reference

- [`Promise.method(Function fn)`](#promisemethodfunction-fn---function)
- [`Promise.fulfilled(dynamic value)`](#promisefulfilleddynamic-value---promise)
- [`Promise.rejected(dynamic reason)`](#promiserejecteddynamic-reason---promise)
- [`Promise.pending()`](#promisepending---promiseresolver)
- [`Promise.resolve(dynamic value)`](#promiseresolvedynamic-value---promise)
- [`Promise.reject(dynamic reason)`](#promiserejectdynamic-reason---promise)
- [`Promise.defer()`](#promisedefer---promiseresolver)
- [`Promise.cast(dynamic value)`](#promisecastdynamic-value---promise)

@@ -26,3 +26,3 @@ - [`Promise.bind(dynamic thisArg)`](#promisebinddynamic-thisarg---promise)

- [Promise resolution](#promise-resolution)
- [`.fulfill(dynamic value)`](#fulfilldynamic-value---undefined)
- [`.resolve(dynamic value)`](#resolvedynamic-value---undefined)
- [`.reject(dynamic reason)`](#rejectdynamic-reason---undefined)

@@ -65,3 +65,3 @@ - [`.progress(dynamic value)`](#progressdynamic-value---undefined)

- [`.isRejected()`](#isrejected---boolean)
- [`.isPending()`](#ispending---boolean)
- [`.isPending()`](#isdefer---boolean)
- [`.isResolved()`](#isresolved---boolean)

@@ -112,5 +112,5 @@ - [`.inspect()`](#inspect---promiseinspection)

function delay(ms, value) {
var resolver = Promise.pending();
var resolver = Promise.defer();
setTimeout(function(){
resolver.fulfill(value);
resolver.resolve(value);
}, ms);

@@ -129,3 +129,3 @@ return resolver.promise;

[Promises/A+ `.then()`](http://promises-aplus.github.io/promises-spec/) with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved depending on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
[Promises/A+ `.then()`](http://promises-aplus.github.io/promises-spec/) with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.

@@ -200,3 +200,3 @@ Example:

```js
Promise.fulfilled().then(function(){
Promise.resolve().then(function(){
throw new MyCustomError();

@@ -444,3 +444,3 @@ }).catch(MyCustomError, function(e){

```js
Promise.fulfilled("my-element")
Promise.resolve("my-element")
.bind(document)

@@ -542,7 +542,7 @@ .then(document.getElementById)

if (!this.isValid(input)) {
return Promise.rejected(new TypeError("input is not valid"));
return Promise.reject(new TypeError("input is not valid"));
}
if (this.cache(input)) {
return Promise.fulfilled(this.someCachedValue);
return Promise.resolve(this.someCachedValue);
}

@@ -578,9 +578,9 @@

#####`Promise.fulfilled(dynamic value)` -> `Promise`
#####`Promise.resolve(dynamic value)` -> `Promise`
Create a promise that is fulfilled with the given `value`. If `value` is a trusted `Promise`, the promise will instead follow that promise, adapting to its state. The promise is synchronously fulfilled in the former case.
Create a promise that is resolved with the given `value`. If `value` is a trusted `Promise`, the promise will instead follow that promise, adapting to its state. The promise is synchronously fulfilled in the former case.
<hr>
#####`Promise.rejected(dynamic reason)` -> `Promise`
#####`Promise.reject(dynamic reason)` -> `Promise`

@@ -591,3 +591,3 @@ Create a promise that is rejected with the given `reason`. The promise is synchronously rejected.

#####`Promise.pending()` -> `PromiseResolver`
#####`Promise.defer()` -> `PromiseResolver`

@@ -621,3 +621,3 @@ Create a promise with undecided fate and return a `PromiseResolver` to control it. See [Promise resultion](#promise-resolution).

Sugar for `Promise.fulfilled(undefined).bind(thisArg);`. See [`.bind()`](#binddynamic-thisarg---promise).
Sugar for `Promise.resolve(undefined).bind(thisArg);`. See [`.bind()`](#binddynamic-thisarg---promise).

@@ -653,5 +653,5 @@ <hr>

Promise.longStackTraces();
Promise.fulfilled().then(function outer() {
return Promise.fulfilled().then(function inner() {
return Promise.fulfilled().then(function evenMoreInner() {
Promise.resolve().then(function outer() {
return Promise.resolve().then(function inner() {
return Promise.resolve().then(function evenMoreInner() {
a.b.c.d()

@@ -710,5 +710,5 @@ }).catch(function catcher(e){

#####`.fulfill(dynamic value)` -> `undefined`
#####`.resolve(dynamic value)` -> `undefined`
Fulfill the underlying promise with `value` as the fulfillment value. If `value` is a trusted `Promise`, the underlying promise will instead follow that promise, adapting to its state.
Resolve the underlying promise with `value` as the resolution value. If `value` is a trusted `Promise`, the underlying promise will instead follow that promise, adapting to its state.

@@ -731,6 +731,6 @@ <hr>

function delay(ms) {
var resolver = Promise.pending();
var resolver = Promise.defer();
var now = Date.now();
setTimeout(function(){
resolver.fulfill(Date.now() - now);
resolver.resolve(Date.now() - now);
}, ms);

@@ -756,3 +756,3 @@ return resolver.promise;

function readAbc() {
var resolver = Promise.pending();
var resolver = Promise.defer();
fs.readFile("abc.txt", resolver.asCallback);

@@ -1246,3 +1246,3 @@ return resolver.promise;

By default, all Promises are cancellable. A cancellable promise can be cancelled if it's not resolved. Cancelling a promise propagates to the farthest ancestor of the target promise that is still pending, and rejects that promise with `CancellationError`. The rejection will then propagate back to the original promise and to its descendants. This roughly follows the semantics described [here](https://github.com/promises-aplus/cancellation-spec/issues/7)
By default, all Promises are cancellable. A cancellable promise can be cancelled if it's not resolved. Cancelling a promise propagates to the farthest ancestor of the target promise that is still defer, and rejects that promise with `CancellationError`. The rejection will then propagate back to the original promise and to its descendants. This roughly follows the semantics described [here](https://github.com/promises-aplus/cancellation-spec/issues/7)

@@ -1271,3 +1271,3 @@ If you are the resolver for a promise, you can react to a cancel in your promise by catching the `CancellationError`:

Cancel this promise. The cancellation will propagate
to farthest ancestor promise which is still pending.
to farthest ancestor promise which is still defer.

@@ -1351,3 +1351,3 @@ That ancestor will then be rejected with a CancellationError

See if this `promise` is still pending.
See if this `promise` is still defer.

@@ -1376,3 +1376,3 @@ <hr>

See if the underlying promise was pending at the creation time of this inspection object.
See if the underlying promise was defer at the creation time of this inspection object.

@@ -1379,0 +1379,0 @@ `.value()` -> `dynamic`, throws `TypeError`

@@ -0,1 +1,9 @@

## 0.10.1-0 (2013-11-21)
Features:
- Add methods `Promise.resolve()`, `Promise.reject()`, `Promise.defer()` and `.resolve()`.
## 0.10.0-1 (2013-11-17)
## 0.10.0-0 (2013-11-17)

@@ -2,0 +10,0 @@

@@ -88,3 +88,4 @@ /**

PromiseResolver.prototype.fulfill = function PromiseResolver$fulfill( value ) {
PromiseResolver.prototype.resolve =
PromiseResolver.prototype.fulfill = function PromiseResolver$resolve( value ) {
if( this.promise._tryAssumeStateOf( value, false ) ) {

@@ -91,0 +92,0 @@ return;

@@ -239,7 +239,9 @@ /**

};
Promise.fulfilled = function Promise$Fulfilled( value, caller ) {
Promise.resolve = Promise.fulfilled =
function Promise$Resolve( value, caller ) {
var ret = new Promise();
ret._setTrace( typeof caller === "function"
? caller
: Promise.fulfilled, void 0 );
: Promise.resolve, void 0 );
if( ret._tryAssumeStateOf( value, false ) ) {

@@ -254,5 +256,5 @@ return ret;

Promise.rejected = function Promise$Rejected( reason ) {
Promise.reject = Promise.rejected = function Promise$Reject( reason ) {
var ret = new Promise();
ret._setTrace( Promise.rejected, void 0 );
ret._setTrace( Promise.reject, void 0 );
ret._cleanValues();

@@ -305,6 +307,6 @@ ret._setRejected();

Promise.pending = function Promise$Pending( caller ) {
Promise.defer = Promise.pending = function Promise$Defer( caller ) {
var promise = new Promise();
promise._setTrace( typeof caller === "function"
? caller : Promise.pending, void 0 );
? caller : Promise.defer, void 0 );
return new PromiseResolver( promise );

@@ -324,3 +326,3 @@ };

if( !( ret instanceof Promise ) ) {
return Promise.fulfilled( ret, caller );
return Promise.resolve( ret, caller );
}

@@ -327,0 +329,0 @@ return ret;

@@ -88,3 +88,4 @@ /**

PromiseResolver.prototype.fulfill = function PromiseResolver$fulfill( value ) {
PromiseResolver.prototype.resolve =
PromiseResolver.prototype.fulfill = function PromiseResolver$resolve( value ) {
if( this.promise._tryAssumeStateOf( value, false ) ) {

@@ -91,0 +92,0 @@ return;

@@ -239,7 +239,9 @@ /**

};
Promise.fulfilled = function Promise$Fulfilled( value, caller ) {
Promise.resolve = Promise.fulfilled =
function Promise$Resolve( value, caller ) {
var ret = new Promise();
ret._setTrace( typeof caller === "function"
? caller
: Promise.fulfilled, void 0 );
: Promise.resolve, void 0 );
if( ret._tryAssumeStateOf( value, false ) ) {

@@ -254,5 +256,5 @@ return ret;

Promise.rejected = function Promise$Rejected( reason ) {
Promise.reject = Promise.rejected = function Promise$Reject( reason ) {
var ret = new Promise();
ret._setTrace( Promise.rejected, void 0 );
ret._setTrace( Promise.reject, void 0 );
ret._cleanValues();

@@ -305,6 +307,6 @@ ret._setRejected();

Promise.pending = function Promise$Pending( caller ) {
Promise.defer = Promise.pending = function Promise$Defer( caller ) {
var promise = new Promise();
promise._setTrace( typeof caller === "function"
? caller : Promise.pending, void 0 );
? caller : Promise.defer, void 0 );
return new PromiseResolver( promise );

@@ -324,3 +326,3 @@ };

if( !( ret instanceof Promise ) ) {
return Promise.fulfilled( ret, caller );
return Promise.resolve( ret, caller );
}

@@ -327,0 +329,0 @@ return ret;

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

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

@@ -23,2 +23,3 @@ [![Build Status](https://travis-ci.org/petkaantonov/bluebird.png?branch=master)](https://travis-ci.org/petkaantonov/bluebird)

- [Custom builds](#custom-builds)
- [For library authors](#for-library-authors)
- [What is the sync build?](#what-is-the-sync-build)

@@ -513,17 +514,17 @@ - [License](#license)

Currently the most relevant benchmark is @gorkikosev's benchmark in the article [Analysis of generators and other async patterns in node](http://spion.github.io/posts/analysis-generators-and-other-async-patterns-node.html). The benchmark emulates a situation where n amount of users are making a request in parallel to execute some mixed async/sync action. The benchmark has been modified to include a warm-up phase to minimize any JITing during timed sections.
To run a benchmark, run the given command for a benchmark while on the project root. Requires bash (on windows the mingw32 that comes with git works fine too).
You can run the benchmark with:
Node 0.11.2+ is required to run the generator examples.
bench spion
###1\. DoxBee sequential
While on the project root. Requires bash (on windows the mingw32 that comes with git works fine too).
Currently the most relevant benchmark is @gorkikosev's benchmark in the article [Analysis of generators and other async patterns in node](http://spion.github.io/posts/analysis-generators-and-other-async-patterns-node.html). The benchmark emulates a situation where n amount of users are making a request in parallel to execute some mixed async/sync action. The benchmark has been modified to include a warm-up phase to minimize any JITing during timed sections.
Node 0.11.2+ is required to run the generator examples.
Command: `bench doxbee`
Another benchmark to run is the [When.js benchmarks by CujoJS](https://github.com/cujojs/promise-perf-tests). The reduce and map have been modified from the original. The benchmarks also include warmup-phases.
###2\. Made-up parallel
bench cujojs
This made-up scenario runs 15 shimmed queries in parallel.
While on the project root. Requires bash (on windows the mingw32 that comes with git works fine too).
Command: `bench parallel`

@@ -614,2 +615,20 @@ ##Custom builds

##For library authors
Building a library that depends on bluebird? You should know about a few features.
If your library needs to do something obtrusive like adding or modifying methods on the `Promise` prototype, uses long stack traces or uses a custom unhandled rejection handler then... that's totally ok as long as you don't use `require("bluebird")`. Instead you should create a file
that creates an isolated copy. For example, creating a file called `bluebird-extended.js` that contains:
```js
//NOTE the function call right after
module.exports = require("bluebird/js/main/promise")();
```
Your library can then use `var Promise = require("bluebird-extended");` and do whatever it wants with it. Then if the application or other library uses their own bluebird promises they will all play well together because of Promises/A+ thenable assimilation magic.
You should also know about [`.nodeify()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#nodeifyfunction-callback---promise) which makes it easy to provide a dual callback/promise API.
<hr>
##What is the sync build?

@@ -616,0 +635,0 @@

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