Socket
Socket
Sign inDemoInstall

bluebird

Package Overview
Dependencies
0
Maintainers
1
Versions
223
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.0-2 to 0.8.0-3

31

API.md

@@ -402,2 +402,33 @@ #API Reference

#####`.asCallback` -> `Function`
Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
```js
var fs = require("fs");
function readAbc() {
var resolver = Promise.pending();
fs.readFile("abc.txt", resolver.asCallback);
return resolver.promise;
}
readAbc()
.then(function(abcContents) {
console.log(abcContents);
})
.catch(function(e) {
console.error(e);
});
```
This example is an alternative to automatic promisification of node functions.
*Performance tips*
The `asCallback` is actually an accessor property (except on legacy browsers where it's eager data property) - so save the result if you need to call it multiple times.
This is more efficient way of promisification than using `new Promise`.
##Collections

@@ -404,0 +435,0 @@

2

package.json
{
"name": "bluebird",
"description": "Full featured Promises/A+ implementation with exceptionally good performance",
"version": "0.8.0-2",
"version": "0.8.0-3",
"keywords": [

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

@@ -1,11 +0,18 @@

var Promise = require('./js/bluebird.js');
var Q = require("./js/bluebird");
Q.longStackTraces();
Q.fulfilled(5)
.then(function () { return 10; })
.then(function () { return 20; })
.then(function () { throw new Error("boo!"); })
.done();
function test2() {
Promise.fulfilled().then(test2)
return;
function test(i){
if (i <= 0){
console.log(process.memoryUsage().heapUsed / (1024 * 1024));
return Q.when('done')
} else {
return Q.when(i-1).then(test)
}
}
test2();
//6 490 216
//25 367 200
test(10000).then(function(output){ console.log(output) });

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc