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

promise

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

58

index.js

@@ -35,3 +35,3 @@ 'use strict';

Promise.from = Promise.cast = function (value) {
Promise.resolve = function (value) {
if (value instanceof Promise) return value

@@ -61,2 +61,10 @@

}
Promise.from = Promise.cast = function (value) {
var err = new Error('Promise.from and Promise.cast are deprecated, use Promise.resolve instead')
err.name = 'Warning'
console.warn(err.stack)
return Promise.resolve(value)
}
Promise.denodeify = function (fn, argumentCount) {

@@ -98,4 +106,11 @@ argumentCount = argumentCount || Infinity

Promise.all = function () {
var args = Array.prototype.slice.call(arguments.length === 1 && Array.isArray(arguments[0]) ? arguments[0] : arguments)
var calledWithArray = arguments.length === 1 && Array.isArray(arguments[0])
var args = Array.prototype.slice.call(calledWithArray ? arguments[0] : arguments)
if (!calledWithArray) {
var err = new Error('Promise.all should be called with a single array, calling it with multiple arguments is deprecated')
err.name = 'Warning'
console.warn(err.stack)
}
return new Promise(function (resolve, reject) {

@@ -127,2 +142,16 @@ if (args.length === 0) return resolve([])

Promise.reject = function (value) {
return new Promise(function (resolve, reject) {
reject(value);
});
}
Promise.race = function (values) {
return new Promise(function (resolve, reject) {
values.forEach(function(value){
Promise.resolve(value).then(resolve, reject);
})
});
}
/* Prototype Methods */

@@ -140,3 +169,3 @@

Promise.prototype.nodeify = function (callback) {
if (callback === null || typeof callback == 'undefined') return this
if (typeof callback != 'function') return this

@@ -154,25 +183,4 @@ this.then(function (value) {

Promise.prototype.catch = function (onRejected) {
Promise.prototype['catch'] = function (onRejected) {
return this.then(null, onRejected);
}
Promise.resolve = function (value) {
return new Promise(function (resolve) {
resolve(value);
});
}
Promise.reject = function (value) {
return new Promise(function (resolve, reject) {
reject(value);
});
}
Promise.race = function (values) {
return new Promise(function (resolve, reject) {
values.map(function(value){
Promise.cast(value).then(resolve, reject);
})
});
}
{
"name": "promise",
"version": "4.0.0",
"version": "5.0.0",
"description": "Bare bones Promises/A+ implementation",

@@ -5,0 +5,0 @@ "main": "index.js",

<a href="http://promises-aplus.github.com/promises-spec"><img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" align="right" /></a>
# promise
This a bare bones [Promises/A+](http://promises-aplus.github.com/promises-spec/) implementation.
This is a simple implementation of Promises. It is a super set of ES6 Promises designed to have readable, performant code and to provide just the extensions that are absolutely necessary for using promises today.
It is designed to get the basics spot on correct, so that you can build extended promise implementations on top of it.
For detailed tutorials on its use, see www.promisejs.org

@@ -14,12 +14,12 @@ [![Build Status](https://travis-ci.org/then/promise.png)](https://travis-ci.org/then/promise)

**Server:**
**Server:**
$ npm install promise
**Client:**
You can use browserify on the client, or download a standalone version from [www.promisejs.org](http://www.promisejs.org/implementations/#i-promise)
**Client:**
You can use browserify on the client, or use the pre-compiled script that acts as a pollyfill.
```html
<script src="http://www.promisejs.org/implementations/promise/promise-3.2.0.js"></script>
<script src="https://www.promisejs.org/polyfills/promise-4.0.0.js"></script>
```

@@ -29,3 +29,3 @@

The example below shows how you can load the promise library (in a way that works on both client and server). It then demonstrates creating a promise from scratch. You simply call `new Promise(fn)`. There is a complete specification for what is returned by this method in [Promises/A+](http://promises-aplus.github.com/promises-spec/).
The example below shows how you can load the promise library (in a way that works on both client and server). It then demonstrates creating a promise from scratch. You simply call `new Promise(fn)`. There is a complete specification for what is returned by this method in [Promises/A+](http://promises-aplus.github.com/promises-spec/).

@@ -62,7 +62,9 @@ ```javascript

#### Promise.from(value)
#### Promise.resolve(value)
(deprecated aliases: `Promise.from(value)`, `Promise.cast(value)`)
Converts values and foreign promises into Promises/A+ promises. If you pass it a value then it returns a Promise for that value. If you pass it something that is close to a promise (such as a jQuery attempt at a promise) it returns a Promise that takes on the state of `value` (rejected or fulfilled).
#### Promise.all(array) / Promise.all(a, b, c, ...)
#### Promise.all(array)

@@ -89,2 +91,4 @@ Returns a promise for an array. If it is called with a single argument that `Array.isArray` then this returns a promise for a copy of that array with any promises replaced by their fulfilled values. Otherwise it returns a promise for an array that conatins its arguments, except with promises replaced by their resolution values. e.g.

_Non Standard_
Takes a function which accepts a node style callback and returns a new function that returns a promise instead.

@@ -108,2 +112,4 @@

_Non Standard_
The twin to `denodeify` is useful when you want to export an API that can be used by people who haven't learnt about the brilliance of promises yet.

@@ -136,6 +142,10 @@

The same semantics as `.then` except that it does not return a promise and any exceptions are re-thrown so that they can be logged (crashing the applicaiton in non-browser environments)
_Non Standard_
The same semantics as `.then` except that it does not return a promise and any exceptions are re-thrown so that they can be logged (crashing the application in non-browser environments)
#### Promise#nodeify(callback)
_Non Standard_
If `callback` is `null` or `undefined` it just returns `this`. If `callback` is a function it is called with rejection reason as the first argument and result as the second argument (as per the node.js convention).

@@ -142,0 +152,0 @@

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