Socket
Socket
Sign inDemoInstall

rsvp

Package Overview
Dependencies
Maintainers
6
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rsvp - npm Package Compare versions

Comparing version 4.8.4 to 4.8.5

5

CHANGELOG.md
# Master
# 4.8.5
* remove try/catch performance hacks, modern runtimes no longer require these tricks
* internal tooling improvements
# 4.8.2

@@ -4,0 +9,0 @@

61

lib/rsvp/-internal.js

@@ -23,34 +23,13 @@ import originalThen from './then';

export const TRY_CATCH_ERROR = { error: null };
export function getThen(promise) {
function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
try {
return promise.then;
} catch(error) {
TRY_CATCH_ERROR.error = error;
return TRY_CATCH_ERROR;
}
}
let tryCatchCallback;
function tryCatcher() {
try {
let target = tryCatchCallback;
tryCatchCallback = null;
return target.apply(this, arguments);
then.call(value, fulfillmentHandler, rejectionHandler);
} catch(e) {
TRY_CATCH_ERROR.error = e;
return TRY_CATCH_ERROR;
return e;
}
}
export function tryCatch(fn) {
tryCatchCallback = fn;
return tryCatcher;
}
function handleForeignThenable(promise, thenable, then) {
config.async(promise => {
let sealed = false;
let result = tryCatch(then).call(
let error = tryThen(then,
thenable,

@@ -74,10 +53,6 @@ value => {

);
if (!sealed && result === TRY_CATCH_ERROR) {
if (!sealed && error) {
sealed = true;
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null;
reject(promise, error);
}
}, promise);

@@ -111,6 +86,2 @@ }

handleOwnThenable(promise, maybeThenable);
} else if (then === TRY_CATCH_ERROR) {
let error = TRY_CATCH_ERROR.error
TRY_CATCH_ERROR.error = null;
reject(promise, error);
} else if (typeof then === 'function') {

@@ -127,3 +98,10 @@ handleForeignThenable(promise, maybeThenable, then);

} else if (objectOrFunction(value)) {
handleMaybeThenable(promise, value, getThen(value));
let then;
try {
then = value.then;
} catch (error) {
reject(promise, error);
return;
}
handleMaybeThenable(promise, value, then);
} else {

@@ -207,6 +185,11 @@ fulfill(promise, value);

let hasCallback = typeof callback === 'function';
let value;
let value, succeeded = true, error;
if (hasCallback) {
value = tryCatch(callback)(result);
try {
value = callback(result)
} catch (e) {
succeeded = false;
error = e;
}
} else {

@@ -220,5 +203,3 @@ value = result;

reject(promise, withOwnPromise());
} else if (value === TRY_CATCH_ERROR) {
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null; // release
} else if (succeeded === false) {
reject(promise, error);

@@ -225,0 +206,0 @@ } else if (hasCallback) {

@@ -67,3 +67,3 @@ import {

@param {Array} entries
@param {String} label - optional string that describes the promise.
@param {String} [label] - optional string that describes the promise.
Useful for tooling.

@@ -70,0 +70,0 @@ @return {Promise} promise that is fulfilled with an array of the settled

@@ -11,3 +11,3 @@ import Promise from "./promise";

@param {Array} array Array of promises.
@param {String} label An optional label. This is useful
@param {String} [label] An optional label. This is useful
for tooling.

@@ -14,0 +14,0 @@ */

@@ -32,3 +32,3 @@ import Promise from "./promise";

@for rsvp
@param {String} label optional string for labeling the promise.
@param {String} [label] optional string for labeling the promise.
Useful for tooling.

@@ -35,0 +35,0 @@ @return {Object}

@@ -11,3 +11,2 @@ import {

PENDING,
getThen
} from './-internal';

@@ -61,3 +60,9 @@

if (this._isUsingOwnResolve) {
let then = getThen(entry);
let then, error, succeeded = true;
try {
then = entry.then;
} catch (e) {
succeeded = false;
error = e;
}

@@ -71,4 +76,8 @@ if (then === ownThen && entry._state !== PENDING) {

let promise = new c(noop);
handleMaybeThenable(promise, entry, then);
this._willSettleAt(promise, i, firstPass);
if (succeeded === false) {
reject(promise, error);
} else {
handleMaybeThenable(promise, entry, then);
this._willSettleAt(promise, i, firstPass);
}
} else {

@@ -75,0 +84,0 @@ this._willSettleAt(new c(resolve => resolve(entry)), i, firstPass);

@@ -141,3 +141,3 @@

@param {String} eventName event to stop listening to
@param {Function} callback optional argument. If given, only the function
@param {Function} [callback] optional argument. If given, only the function
given will be removed from the event's callback queue. If no `callback`

@@ -190,3 +190,3 @@ argument is given, all callbacks will be removed from the event's callback

@param {String} eventName name of the event to be triggered
@param {*} options optional value to be passed to any event handlers for
@param {*} [options] optional value to be passed to any event handlers for
the given `eventName`

@@ -193,0 +193,0 @@ */

import Promise from './promise';
import { MapEnumerator } from './map';
import {
tryCatch,
fulfill,
TRY_CATCH_ERROR,
REJECTED

@@ -25,6 +23,10 @@ } from './-internal';

this._result[i] = value;
let val = tryCatch(this._mapFn)(value, i);
if (val === TRY_CATCH_ERROR) {
this._settledAt(REJECTED, i, val.error, false);
} else {
let val, succeeded = true;
try {
val = this._mapFn(value, i);
} catch (error) {
succeeded = false;
this._settledAt(REJECTED, i, error, false);
}
if (succeeded) {
this._eachEntry(val, i, false);

@@ -127,3 +129,3 @@ }

filter the final results.
@param {String} label optional string describing the promise. Useful for
@param {String} [label] optional string describing the promise. Useful for
tooling.

@@ -130,0 +132,0 @@ @return {Promise}

@@ -118,3 +118,3 @@ import Promise from './promise';

@param {Object} object
@param {String} label optional string that describes the promise.
@param {String} [label] optional string that describes the promise.
Useful for tooling.

@@ -121,0 +121,0 @@ @return {Promise} promise that is fulfilled when when all properties of `promises`

@@ -89,3 +89,3 @@ import Promise from './promise';

@param {Object} object
@param {String} label optional string that describes the promise.
@param {String} [label] optional string that describes the promise.
Useful for tooling.

@@ -92,0 +92,0 @@ @return {Promise} promise that is fulfilled when all properties of `promises`

@@ -6,4 +6,2 @@ import Promise from './promise';

import {
tryCatch,
TRY_CATCH_ERROR,
REJECTED

@@ -29,7 +27,6 @@ } from './-internal';

if (firstPass) {
let val = tryCatch(this._mapFn)(value, i);
if (val === TRY_CATCH_ERROR) {
this._settledAt(REJECTED, i, val.error, false);
} else {
this._eachEntry(val, i, false);
try {
this._eachEntry(this._mapFn(value, i), i, false);
} catch (error) {
this._settledAt(REJECTED, i, error, false);
}

@@ -41,3 +38,2 @@ } else {

}
}

@@ -121,3 +117,3 @@

@param {Function} mapFn function to be called on each fulfilled promise.
@param {String} label optional string for labeling the promise.
@param {String} [label] optional string for labeling the promise.
Useful for tooling.

@@ -124,0 +120,0 @@ @return {Promise} promise that is fulfilled with the result of calling

@@ -6,5 +6,2 @@ import Promise from './promise';

reject,
getThen,
tryCatch,
TRY_CATCH_ERROR
} from './-internal';

@@ -183,13 +180,22 @@

let arg = arguments[i];
let then;
// TODO: this code really needs to be cleaned up
if (!promiseInput) {
// TODO: clean this up
promiseInput = needsPromiseInput(arg);
if (promiseInput === TRY_CATCH_ERROR) {
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null;
let p = new Promise(noop);
reject(p, error);
return p;
} else if (promiseInput && promiseInput !== true) {
if (arg !== null && typeof arg === 'object') {
if (arg.constructor === Promise) {
promiseInput = true;
} else {
try {
promiseInput = arg.then;
} catch(error) {
let p = new Promise(noop);
reject(p, error);
return p;
}
}
} else {
promiseInput = false;
}
if (promiseInput && promiseInput !== true) {
arg = wrapThenable(promiseInput, arg);

@@ -230,6 +236,5 @@ }

function handleValueInput(promise, args, nodeFunc, self) {
let result = tryCatch(nodeFunc).apply(self, args);
if (result === TRY_CATCH_ERROR) {
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null;
try {
nodeFunc.apply(self, args);
} catch (error) {
reject(promise, error);

@@ -244,13 +249,1 @@ }

}
function needsPromiseInput(arg) {
if (arg !== null && typeof arg === 'object') {
if (arg.constructor === Promise) {
return true;
} else {
return getThen(arg);
}
} else {
return false;
}
}

@@ -127,3 +127,3 @@ import { config } from './config';

@param {function} resolver
@param {String} label optional string for labeling the promise.
@param {String} [label] optional string for labeling the promise.
Useful for tooling.

@@ -180,3 +180,3 @@ @constructor

@param {Function} onRejection
@param {String} label optional string for labeling the promise.
@param {String} [label] optional string for labeling the promise.
Useful for tooling.

@@ -225,3 +225,3 @@ @return {Promise}

@param {Function} callback
@param {String} label optional string for labeling the promise.
@param {String} [label] optional string for labeling the promise.
Useful for tooling.

@@ -441,3 +441,3 @@ @return {Promise}

@param {Function} onRejection
@param {String} label optional string for labeling the promise.
@param {String} [label] optional string for labeling the promise.
Useful for tooling.

@@ -444,0 +444,0 @@ @return {Promise}

@@ -48,3 +48,3 @@ import Enumerator from '../enumerator';

@param {Array} entries array of promises
@param {String} label optional string for labeling the promise.
@param {String} [label] optional string for labeling the promise.
Useful for tooling.

@@ -51,0 +51,0 @@ @return {Promise} promise that is fulfilled when all `promises` have been

@@ -77,3 +77,3 @@ import {

@param {Array} entries array of promises to observe
@param {String} label optional string for describing the promise returned.
@param {String} [label] optional string for describing the promise returned.
Useful for tooling.

@@ -80,0 +80,0 @@ @return {Promise} a promise which settles in the same way as the first passed

@@ -42,3 +42,3 @@ import {

@param {*} reason value that the returned promise will be rejected with.
@param {String} label optional string for identifying the returned promise.
@param {String} [label] optional string for identifying the returned promise.
Useful for tooling.

@@ -45,0 +45,0 @@ @return {Promise} a promise rejected with the given `reason`.

@@ -38,3 +38,3 @@ import {

@param {*} object value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
@param {String} [label] optional string for identifying the returned promise.
Useful for tooling.

@@ -41,0 +41,0 @@ @return {Promise} a promise that will become fulfilled with the given

@@ -11,3 +11,3 @@ import Promise from './promise';

@param {Array} array Array of promises.
@param {String} label An optional label. This is useful
@param {String} [label] An optional label. This is useful
for tooling.

@@ -14,0 +14,0 @@ */

@@ -11,3 +11,3 @@ import Promise from './promise';

@param {*} reason value that the returned promise will be rejected with.
@param {String} label optional string for identifying the returned promise.
@param {String} [label] optional string for identifying the returned promise.
Useful for tooling.

@@ -14,0 +14,0 @@ @return {Promise} a promise rejected with the given `reason`.

@@ -11,3 +11,3 @@ import Promise from './promise';

@param {*} value value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
@param {String} [label] optional string for identifying the returned promise.
Useful for tooling.

@@ -14,0 +14,0 @@ @return {Promise} a promise that will become fulfilled with the given

{
"name": "rsvp",
"namespace": "RSVP",
"version": "4.8.4",
"description": "A lightweight library that provides tools for organizing asynchronous code",
"main": "dist/rsvp.js",
"module": "dist/rsvp.es.js",
"jsnext:main": "dist/rsvp.es.js",
"files": [
"dist",
"lib",
"!dist/test"
],
"directories": {
"lib": "lib"
"version": "4.8.5",
"author": "Tilde, Inc. & Stefan Penner",
"browser": {
"vertx": false
},
"bugs": {
"url": "https://github.com/tildeio/rsvp.js/issues"
},
"devDependencies": {

@@ -31,23 +26,38 @@ "babel-plugin-transform-es2015-arrow-functions": "^6.22.0",

"broccoli-babel-transpiler": "6.4.3",
"broccoli-concat": "^3.2.2",
"broccoli-concat": "^3.7.1",
"broccoli-funnel": "2.0.1",
"broccoli-merge-trees": "^3.0.0",
"broccoli-merge-trees": "^3.0.1",
"broccoli-rollup": "2.1.1",
"broccoli-stew": "^1.5.0",
"broccoli-stew": "^2.0.0",
"broccoli-uglify-js": "^0.2.0",
"broccoli-watchify": "1.0.1",
"ember-cli": "3.2.0",
"ember-cli-dependency-checker": "2.1.1",
"ember-cli": "3.4.2",
"ember-cli-dependency-checker": "3.0.0",
"ember-cli-inject-live-reload": "^2.0.1",
"ember-cli-progress": "^1.0.6",
"git-repo-version": "1.0.2",
"mocha": "5.2.0",
"promises-aplus-tests-phantom": "^2.1.0-revise"
"promises-aplus-tests": "2.1.2"
},
"scripts": {
"build": "ember build --environment production",
"start": "ember s",
"test": "ember test",
"test:server": "ember test --server",
"test:node": "ember test --launch Mocha",
"test:browser": "ember test --launch PhantomJS"
"directories": {
"lib": "lib"
},
"engines": {
"node": "6.* || >= 7.*"
},
"files": [
"dist",
"lib",
"!dist/test"
],
"homepage": "https://github.com/tildeio/rsvp.js",
"jsnext:main": "dist/rsvp.es.js",
"keywords": [
"futures",
"promises"
],
"license": "MIT",
"main": "dist/rsvp.js",
"module": "dist/rsvp.es.js",
"namespace": "RSVP",
"repository": {

@@ -58,17 +68,9 @@ "type": "git",

},
"bugs": {
"url": "https://github.com/tildeio/rsvp.js/issues"
},
"browser": {
"vertx": false
},
"keywords": [
"promises",
"futures"
],
"author": "Tilde, Inc. & Stefan Penner",
"license": "MIT",
"engines": {
"node": "0.12.* || 4.* || 6.* || >= 7.*"
"scripts": {
"build": "ember build --environment production",
"start": "ember s",
"test": "ember test",
"test:node": "ember test --launch Mocha",
"test:server": "ember test --server"
}
}

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

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