initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

300
node_modules/rsvp/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,300 @@
# Master
# 3.5.0
* expose RSVP.asap for access to the micro-task polyfil
# 3.4.0
* [BUGFIX] Fix memory leak [#446]
* Mirror Node's LTS policy
* add dist/rsvp.es.js (bundle as a single ES module file)
* fix typo in readme
# 3.3.3
* [BUGFIX] Fix asap for Titanium \w webpack usage.
# 3.3.2
* [BUGFIX] fix invalid ES6
# 3.3.1
* [BUGFIX] for compat, ensure both default export and property export exist. This will likely go away in 4.0.0, and was the result of rollup producing proper output with `__esModule: true` brand
# 3.3.0
* improve build, switch to broccoli-rollup (among other things)
* RSVP.filter() now itself accepts a Promise.all as input
* compress and mangle prod build output
* [REVERT] reject instead of throwing, spec violation.
# 3.2.1
* reject instead of throwing
# 3.2.0
* add tamper protection - then / resolve tampering should avoid fast-paths the rely on those being predictable
* improve performance of Enumerator operating on non-promise objects
* Ensure the promise constructor continues to get inlined.
# 3.1.0
* `RSVP.on('error', function(reason, label) { ... }` now also provides the
rejected promises label.
# 3.0.21
* actually don't publish built tests to npm
# 3.0.20
* correctly publish bower & npm
# 3.0.19
* don't publish built tests to npm
# 3.0.18
* issue with phantomjs 2.0 on travis. I have lost patience..
* test on iojs and node 0.12
* bump ember-cli
* Support objects not inheriting from Object.prototype in RSVP.hash()
# 3.0.17
* Added browser field to fix browserification
* Fix stripping source map
* Fix duplicate imports
* Remove unused loader.js dependency
* Add the ember-cli dependency checker
* Remove the duplicate build script
* Remove the static middleware
* add npm run build:production
* browserify extern not needed
* also add lib for those es6 peeps
* enusre only dist is included in publishes
* strip source maps for now.
* copy correct tree into test
* prefer start to server
* use git-repo-version
* ah, prod builds used rename correctly.
* remove rename, prefer mv for this scenario
* prepend license
* Revert "node 0.10.x doesnt like this. Its not really needed just run `npm run test` or `npm run test:ci`"
* node 0.10.x doesnt like this. Its not really needed just run `npm run test` or `npm run test:ci`
* move stuff around + bump to broccoli-stew 0.0.3
* bump broccoli-stew which now supports globs
* Problem with path for vertx.js.
# 3.0.16
* use more supported version of export default
* more broccoli fun
* remove accidentally imported map file
* test non-minified (we can add a flag to test minified next)
* [BUGFIX release] Replace closure compiler
# 3.0.15
* Added Node 0.11 to travis ci test runner
* Replaced deprecated process.nextTick with setImmediate
* Ember test and npm run test:node passing
* (origin/upgrade-tooling) upgrade tooling
* Fix onerror test
* [fixes #322] don't inform instrumentation of errors until the current turn is complete.
* Follow thenable state not own state
* Correct minor spelling error in defer doc example
* Set [[AlreadyResolved]] as soon as resolve is called
* Finally should correctly trigger on('error')
* [fixes #294] finally work correctly with on(error)
* Use git-repo-version to calculate build signature
* yay the new transpiler supports this now!!!
* Use the latest version of the transpiler
* add subclassing tests to finally
* extern event emitter stuff
* [fixes #309] some more externs
* ensure those select few using node with minified JS don't have an issue
* [fixes #302] use @calvinmetcalfs promises-aplus-tests-phantom
# 3.0.14
* Instrumentation with stack is now opt-in
* improve cost of instrumentation by up to 15x in chrome
* reduce AST size
* last vertex related touch-ups.
* Add vert.x compatibility.
* [fixes #296] for define.amd and module.exports to no minify
* [fixes #292] ensure the deferred's api doesn't break when minified
* ignore some files for npm
* Add 'finally' to readme
* Use browserify assert instead of vendoring one
* Use mocha and json3 from npm, not bower
* Remove unused json2 file
* upgrade build tooling
* improve performance of instrumentation (also add seperate flag to include "stack" with instrumentation as it is unfortunately slow)
* ensure minified RSVP.defer() maintains known external API [#293](https://github.com/tildeio/rsvp.js/pull/293)
* add `finally` to the readme
* improve usage of browserify for promise/a+ tests
* add wasteful files to gitignore
* add [vert.x](http://vertx.io/) compatibility
# 3.0.13
* [Bugfix] fix `RSVP.hash` `RSVP.hashSettled` in runtimes < es5 by fixing a broken `Object.create` polyfil [#286](https://github.com/tildeio/rsvp.js/pull/286)
* [Enhancement] cleanup & improve test related build tooling [#288](https://github.com/tildeio/rsvp.js/pull/288)
# 3.0.12
* [Bugfix] fix regression in denodeify that broke foreign thenables as arguments to denodeifed functions [#281](https://github.com/tildeio/rsvp.js/pull/281)
# 3.0.11
* [Bugfix] some onerror scenarios did not result in error notifications [4dcf](https://github.com/tildeio/rsvp.js/commit/4dcfa92bab6f5fc9e97ca3abfb71025a08984e7e)
* [Bugfix] for more correctness internal optimization should only occure
if constructors equal, not just if instanceof check passes [96b5ec](https://github.com/tildeio/rsvp.js/commit/96b5ec201b2ddafc70cd5c836bc341a46081ae23)
* fancy new s3 publishing thanks to @rondale-sc
# 3.0.10
* faster denodeify
* rework tooling (Broccoli, testem, no grunt)
* utilize bundle format for super small UMD builds
# 3.0.9
* [Bugfix] no longer include promise-aplus tests as a production
dependency
* [Enhancement] fast then path for both rejection/fulfilment [0d252](https://github.com/tildeio/rsvp.js/commit/0d252ed4831eabb82991584e2e3eaae2a3a2ba42)
* [Enhancement] short-cut for faster then chaining in specific scenarios
[#256](https://github.com/tildeio/rsvp.js/pull/256)
# 3.0.8
* [Bugfix] custom onerror handler, for potentially unhandled errors
would report unhandled errors in some incorrect scenarios.
[#255](https://github.com/tildeio/rsvp.js/pull/255)
# 3.0.7
* improve tests in some older es5+ browsers
* [Bugfix] denodeify should not use console for deprecation warning unless console is defined
* [Enhancement] instrumentation should emit out-of-band. This should improve ember-extension performance
* [Bugfix] race should not be susceptible to zalgo
* [Perf] PromiseEnumerator increase performance of all enumerable methods all/allSettled/hash/hasSettled -> https://gist.github.com/stefanpenner/26465d5848f2924e2aca
* [Docfix] Fix small documentation inconsistency
* [Perf] an internal promise shouldn't bother validating `this` and `resolver`
* [Perf] flatten asaps QUEUE structure
* [Perf] Reduce Constructor AST size.
* [Perf] some versions of v8, think keep marking these functions to be optimized. This hints to them not to be.
* [Perf] accidental resolve step, that merely needed to be a fulfill
* [Perf/Enhancement] simplify publishing
* [Spec ADdition]add spec test “Ensure `then` is always called with a clean stack.” ensure RSVP passes future a+ spec
* [Bugfix] web worker support
* [Docfix] Add a param name to make yuidoc happy
* [Enhancement] simplify async vs sync pub/sub code-paths
* [Bugfix] Passed the label through to the Promise object, as expected
* [Docfix] missing Parentheses on promise example in documentation
* [License] Add Stefan Penner to license
* [Docfix] document `var promises` in filter.js
# 3.0.3 -> 3.0.6 (missing changelog)
* Changes to RSVP.denodeify: Behaviour for multiple success callback parameters
has been improved and the denodefied function now inherits from the original
node function.
# 3.0.2
* [Spec compliance] Promise.all and Promise.race should reject, not throw on invalid input
* Add RSVP.allSettled
# 3.0.1
* Optimization: promises with noop resolvers now don't bother try to handle them.
* [perf] skip costly resolver invocation if it is known not to be needed.
* improve promise inspector interopt
# 3.0.0
* align with the promise spec
https://github.com/domenic/promises-unwrapping
* idiomatic es6 usage
* RSVP.all: now casts rather then resolves, and doesn't touch the
"then"
* RSVP.hash: now casts rather then resolves, and doesn't touch the
"then"
* MutationObserver: prefer text mutation, this fixes interop with
MutationObserver polyfils
* Removing asap unload listener. Allows back/forward page cache, chrome
bug is old. Fixes #168
* add grunt docs task
* document: Promise.cast
* document: Promise.resolve/Promise.reject
* document: Promise.race
* document: Promise.all
* document: Promise.hash
* document: RSVP.denodeify
* document: RSVP.EventTarget
* document: RSVP.rethrow
* document: RSVP.defer
* Document: RSVP.on('error'
* Add Instrumentation hooks for tooling
* Significant internal cleanup and performance improvements
* require Promise constructor to be new'd (aligned with es6 spec)
* Prefer tasks + config inline within project
* Add Promise.finally
* Add Promise.cast
* Add Promise.resolve
* Add Promise.reject
* Add Promise.all
* Add Promise.race
* Add RSVP.map
* Support promise inheritance
* optimize onerror and reduce promise creation cost by 20x
* promise/a+ 2.0.3 compliant
* RSVP.async to schedule callbacks on internal queue
* Optimization: only enforce a single nextTick for each queue flush.
# 2.0.4
* Fix npm package
# 2.0.3
* Fix useSetTimeout bug
# 2.0.2
* Adding RSVP#rethrow
* add pre-built AMD link to README
* adding promise#fail
# 2.0.1
* misc IE fixes, including IE array detection
* upload passing builds to s3
* async: use three args for addEventListener
* satisfy both 1.0 and 1.1 specs
* Run reduce tests only in node
* RSVP.resolve now simply uses the internal resolution procedure
* prevent multiple promise resolutions
* simplify thenable handling
* pre-allocate the deferred's shape
* Moved from Rake-based builds to Grunt
* Fix Promise subclassing bug
* Add RSVP.configure('onerror')
* Throw exception when RSVP.all is called without an array
* refactor RSVP.all to just use a promise directly
* Make `RSVP.denodeify` pass along `thisArg`
* add RSVP.reject
* Reject promise if resolver function throws an exception
* add travis build-status
* correctly test and fix self fulfillment
* remove promise coercion.
* Fix infinite recursion with deep self fulfilling promises
* doc fixes
# 2.0.0
* No changelog beyond this point. Here be dragons.

19
node_modules/rsvp/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

365
node_modules/rsvp/README.md generated vendored Normal file
View File

@@ -0,0 +1,365 @@
# RSVP.js [![Build Status](https://secure.travis-ci.org/tildeio/rsvp.js.svg?branch=master)](http://travis-ci.org/tildeio/rsvp.js) [![Inline docs](http://inch-ci.org/github/tildeio/rsvp.js.svg?branch=master)](http://inch-ci.org/github/tildeio/rsvp.js)
RSVP.js provides simple tools for organizing asynchronous code.
Specifically, it is a tiny implementation of Promises/A+.
It works in node and the browser (IE6+, all the popular evergreen ones).
## downloads
- [rsvp-latest](http://rsvpjs-builds.s3.amazonaws.com/rsvp-latest.js)
- [rsvp-latest (minified)](http://rsvpjs-builds.s3.amazonaws.com/rsvp-latest.min.js)
## Promises
Although RSVP is ES6 compliant, it does bring along some extra toys. If you would prefer a strict ES6 subset, I would suggest checking out our sibling project https://github.com/stefanpenner/es6-promise, It is RSVP but stripped down to the ES6 spec features.
## Bower
`bower install -S rsvp`
## NPM
`npm install --save rsvp`
`RSVP.Promise` is an implementation of
[Promises/A+](http://promises-aplus.github.com/promises-spec/) that passes the
[test suite](https://github.com/promises-aplus/promises-tests).
It delivers all promises asynchronously, even if the value is already
available, to help you write consistent code that doesn't change if the
underlying data provider changes from synchronous to asynchronous.
It is compatible with [TaskJS](http://taskjs.org/), a library by Dave
Herman of Mozilla that uses ES6 generators to allow you to write
synchronous code with promises. It currently works in Firefox, and will
work in any browser that adds support for ES6 generators. See the
section below on TaskJS for more information.
### Basic Usage
```javascript
var RSVP = require('rsvp');
var promise = new RSVP.Promise(function(resolve, reject) {
// succeed
resolve(value);
// or reject
reject(error);
});
promise.then(function(value) {
// success
}).catch(function(error) {
// failure
});
```
Once a promise has been resolved or rejected, it cannot be resolved or
rejected again.
Here is an example of a simple XHR2 wrapper written using RSVP.js:
```javascript
var getJSON = function(url) {
var promise = new RSVP.Promise(function(resolve, reject){
var client = new XMLHttpRequest();
client.open("GET", url);
client.onreadystatechange = handler;
client.responseType = "json";
client.setRequestHeader("Accept", "application/json");
client.send();
function handler() {
if (this.readyState === this.DONE) {
if (this.status === 200) { resolve(this.response); }
else { reject(this); }
}
};
});
return promise;
};
getJSON("/posts.json").then(function(json) {
// continue
}).catch(function(error) {
// handle errors
});
```
### Chaining
One of the really awesome features of Promises/A+ promises are that they
can be chained together. In other words, the return value of the first
resolve handler will be passed to the second resolve handler.
If you return a regular value, it will be passed, as is, to the next
handler.
```javascript
getJSON("/posts.json").then(function(json) {
return json.post;
}).then(function(post) {
// proceed
});
```
The really awesome part comes when you return a promise from the first
handler:
```javascript
getJSON("/post/1.json").then(function(post) {
// save off post
return getJSON(post.commentURL);
}).then(function(comments) {
// proceed with access to post and comments
});
```
This allows you to flatten out nested callbacks, and is the main feature
of promises that prevents "rightward drift" in programs with a lot of
asynchronous code.
Errors also propagate:
```javascript
getJSON("/posts.json").then(function(posts) {
}).catch(function(error) {
// since no rejection handler was passed to the
// first `.then`, the error propagates.
});
```
You can use this to emulate `try/catch` logic in synchronous code.
Simply chain as many resolve callbacks as a you want, and add a failure
handler at the end to catch errors.
```javascript
getJSON("/post/1.json").then(function(post) {
return getJSON(post.commentURL);
}).then(function(comments) {
// proceed with access to posts and comments
}).catch(function(error) {
// handle errors in either of the two requests
});
```
## Error Handling
There are times when dealing with promises that it seems like any errors
are being 'swallowed', and not properly raised. This makes it extremely
difficult to track down where a given issue is coming from. Thankfully,
`RSVP` has a solution for this problem built in.
You can register functions to be called when an uncaught error occurs
within your promises. These callback functions can be anything, but a common
practice is to call `console.assert` to dump the error to the console.
```javascript
RSVP.on('error', function(reason) {
console.assert(false, reason);
});
```
`RSVP` allows Promises to be labeled: `Promise.resolve(value, 'I AM A LABEL')`
If provided, this label is passed as the second argument to `RSVP.on('error')`
```javascript
RSVP.on('error', function(reason, label) {
if (label) {
console.error(label);
}
console.assert(false, reason);
});
```
**NOTE:** promises do allow for errors to be handled asynchronously, so
this callback may result in false positives.
## Finally
`finally` will be invoked regardless of the promise's fate, just as native
try/catch/finally behaves.
```js
findAuthor().catch(function(reason){
return findOtherAuthor();
}).finally(function(){
// author was either found, or not
});
```
## Arrays of promises
Sometimes you might want to work with many promises at once. If you
pass an array of promises to the `all()` method it will return a new
promise that will be fulfilled when all of the promises in the array
have been fulfilled; or rejected immediately if any promise in the array
is rejected.
```javascript
var promises = [2, 3, 5, 7, 11, 13].map(function(id){
return getJSON("/post/" + id + ".json");
});
RSVP.all(promises).then(function(posts) {
// posts contains an array of results for the given promises
}).catch(function(reason){
// if any of the promises fails.
});
```
## Hash of promises
If you need to reference many promises at once (like `all()`), but would like
to avoid encoding the actual promise order you can use `hash()`. If you pass
an object literal (where the values are promises) to the `hash()` method it will
return a new promise that will be fulfilled when all of the promises have been
fulfilled; or rejected immediately if any promise is rejected.
The key difference to the `all()` function is that both the fulfillment value
and the argument to the `hash()` function are object literals. This allows
you to simply reference the results directly off the returned object without
having to remember the initial order like you would with `all()`.
```javascript
var promises = {
posts: getJSON("/posts.json"),
users: getJSON("/users.json")
};
RSVP.hash(promises).then(function(results) {
console.log(results.users) // print the users.json results
console.log(results.posts) // print the posts.json results
});
```
## All settled and hash settled
Sometimes you want to work with several promises at once, but instead of
rejecting immediately if any promise is rejected, as with `all()` or `hash()`,
you want to be able to inspect the results of all your promises, whether
they fulfill or reject. For this purpose, you can use `allSettled()` and
`hashSettled()`. These work exactly like `all()` and `hash()`, except that
they fulfill with an array or hash (respectively) of the constituent promises'
result states. Each state object will either indicate fulfillment or
rejection, and provide the corresponding value or reason. The states will take
one of the following formats:
```javascript
{ state: 'fulfilled', value: value }
or
{ state: 'rejected', reason: reason }
```
## Deferred
> The `RSVP.Promise` constructor is generally a better, less error-prone choice
> than `RSVP.defer()`. Promises are recommended unless the specific
> properties of deferred are needed.
Sometimes one needs to create a deferred object, without immediately specifying
how it will be resolved. These deferred objects are essentially a wrapper around
a promise, whilst providing late access to the `resolve()` and `reject()` methods.
A deferred object has this form: `{ promise, resolve(x), reject(r) }`.
```javascript
var deferred = RSVP.defer();
// ...
deferred.promise // access the promise
// ...
deferred.resolve();
```
## TaskJS
The [TaskJS](http://taskjs.org/) library makes it possible to take
promises-oriented code and make it synchronous using ES6 generators.
Let's review an earlier example:
```javascript
getJSON("/post/1.json").then(function(post) {
return getJSON(post.commentURL);
}).then(function(comments) {
// proceed with access to posts and comments
}).catch(function(reason) {
// handle errors in either of the two requests
});
```
Without any changes to the implementation of `getJSON`, you could write
the following code with TaskJS:
```javascript
spawn(function *() {
try {
var post = yield getJSON("/post/1.json");
var comments = yield getJSON(post.commentURL);
} catch(error) {
// handle errors
}
});
```
In the above example, `function *` is new syntax in ES6 for
[generators](http://wiki.ecmascript.org/doku.php?id=harmony:generators).
Inside a generator, `yield` pauses the generator, returning control to
the function that invoked the generator. In this case, the invoker is a
special function that understands the semantics of Promises/A, and will
automatically resume the generator as soon as the promise is resolved.
The cool thing here is the same promises that work with current
JavaScript using `.then` will work seamlessly with TaskJS once a browser
has implemented it!
## Instrumentation
```js
function listener (event) {
event.guid // guid of promise. Must be globally unique, not just within the implementation
event.childGuid // child of child promise (for chained via `then`)
event.eventName // one of ['created', 'chained', 'fulfilled', 'rejected']
event.detail // fulfillment value or rejection reason, if applicable
event.label // label passed to promise's constructor
event.timeStamp // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now
event.stack // stack at the time of the event. (if 'instrument-with-stack' is true)
}
RSVP.configure('instrument', true | false);
// capturing the stacks is slow, so you also have to opt in
RSVP.configure('instrument-with-stack', true | false);
// events
RSVP.on('created', listener);
RSVP.on('chained', listener);
RSVP.on('fulfilled', listener);
RSVP.on('rejected', listener);
```
Events are only triggered when `RSVP.configure('instrument')` is true, although
listeners can be registered at any time.
## Building & Testing
Custom tasks:
* `npm test` - build & test
* `npm test:node` - build & test just node
* `npm test:server` - build/watch & test
* `npm run build` - Build
* `npm run build:production` - Build production (with minified output)
* `npm start` - build, watch and run interactive server at http://localhost:4200'
## Releasing
Check what release-it will do by running `npm run-script dry-run-release`.
To actually release, run `node_modules/.bin/release-it`.

2465
node_modules/rsvp/dist/es6/rsvp.es.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/rsvp/dist/es6/rsvp.es.map generated vendored Normal file

File diff suppressed because one or more lines are too long

2515
node_modules/rsvp/dist/rsvp.es.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/rsvp/dist/rsvp.es.map generated vendored Normal file

File diff suppressed because one or more lines are too long

2545
node_modules/rsvp/dist/rsvp.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/rsvp/dist/rsvp.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/rsvp/dist/rsvp.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/rsvp/dist/rsvp.min.map generated vendored Normal file

File diff suppressed because one or more lines are too long

94
node_modules/rsvp/lib/rsvp.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
import Promise from './rsvp/promise';
import EventTarget from './rsvp/events';
import denodeify from './rsvp/node';
import all from './rsvp/all';
import allSettled from './rsvp/all-settled';
import race from './rsvp/race';
import hash from './rsvp/hash';
import hashSettled from './rsvp/hash-settled';
import rethrow from './rsvp/rethrow';
import defer from './rsvp/defer';
import {
config,
configure
} from './rsvp/config';
import map from './rsvp/map';
import resolve from './rsvp/resolve';
import reject from './rsvp/reject';
import filter from './rsvp/filter';
import asap from './rsvp/asap';
// defaults
config.async = asap;
config.after = cb => setTimeout(cb, 0);
const cast = resolve;
const async = (callback, arg) => config.async(callback, arg);
function on() {
config['on'].apply(config, arguments);
}
function off() {
config['off'].apply(config, arguments);
}
// Set up instrumentation through `window.__PROMISE_INTRUMENTATION__`
if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') {
let callbacks = window['__PROMISE_INSTRUMENTATION__'];
configure('instrument', true);
for (let eventName in callbacks) {
if (callbacks.hasOwnProperty(eventName)) {
on(eventName, callbacks[eventName]);
}
}
}
import platform from './rsvp/platform';
// the default export here is for backwards compat:
// https://github.com/tildeio/rsvp.js/issues/434
export default {
asap,
cast,
Promise,
EventTarget,
all,
allSettled,
race,
hash,
hashSettled,
rethrow,
defer,
denodeify,
configure,
on,
off,
resolve,
reject,
map,
['async']: async, // babel seems to error if async isn't a computed prop here...
filter
};
export {
asap,
cast,
Promise,
EventTarget,
all,
allSettled,
race,
hash,
hashSettled,
rethrow,
defer,
denodeify,
configure,
on,
off,
resolve,
reject,
map,
async,
filter
};

243
node_modules/rsvp/lib/rsvp/-internal.js generated vendored Normal file
View File

@@ -0,0 +1,243 @@
import {
objectOrFunction,
isFunction
} from './utils';
import originalThen from './then';
import originalResolve from './promise/resolve';
import instrument from './instrument';
import { config } from './config';
import Promise from './promise';
function withOwnPromise() {
return new TypeError('A promises callback cannot return that same promise.');
}
export function noop() {}
export const PENDING = void 0;
export const FULFILLED = 1;
export const REJECTED = 2;
const GET_THEN_ERROR = new ErrorObject();
export function getThen(promise) {
try {
return promise.then;
} catch(error) {
GET_THEN_ERROR.error = error;
return GET_THEN_ERROR;
}
}
function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
try {
then.call(value, fulfillmentHandler, rejectionHandler);
} catch(e) {
return e;
}
}
function handleForeignThenable(promise, thenable, then) {
config.async(promise => {
let sealed = false;
let error = tryThen(then, thenable, value => {
if (sealed) { return; }
sealed = true;
if (thenable !== value) {
resolve(promise, value, undefined);
} else {
fulfill(promise, value);
}
}, reason => {
if (sealed) { return; }
sealed = true;
reject(promise, reason);
}, 'Settle: ' + (promise._label || ' unknown promise'));
if (!sealed && error) {
sealed = true;
reject(promise, error);
}
}, promise);
}
function handleOwnThenable(promise, thenable) {
if (thenable._state === FULFILLED) {
fulfill(promise, thenable._result);
} else if (thenable._state === REJECTED) {
thenable._onError = null;
reject(promise, thenable._result);
} else {
subscribe(thenable, undefined, value => {
if (thenable !== value) {
resolve(promise, value, undefined);
} else {
fulfill(promise, value);
}
}, reason => reject(promise, reason));
}
}
export function handleMaybeThenable(promise, maybeThenable, then) {
let isOwnThenable =
maybeThenable.constructor === promise.constructor &&
then === originalThen &&
promise.constructor.resolve === originalResolve;
if (isOwnThenable) {
handleOwnThenable(promise, maybeThenable);
} else if (then === GET_THEN_ERROR) {
reject(promise, GET_THEN_ERROR.error);
GET_THEN_ERROR.error = null;
} else if (isFunction(then)) {
handleForeignThenable(promise, maybeThenable, then);
} else {
fulfill(promise, maybeThenable);
}
}
export function resolve(promise, value) {
if (promise === value) {
fulfill(promise, value);
} else if (objectOrFunction(value)) {
handleMaybeThenable(promise, value, getThen(value));
} else {
fulfill(promise, value);
}
}
export function publishRejection(promise) {
if (promise._onError) {
promise._onError(promise._result);
}
publish(promise);
}
export function fulfill(promise, value) {
if (promise._state !== PENDING) { return; }
promise._result = value;
promise._state = FULFILLED;
if (promise._subscribers.length === 0) {
if (config.instrument) {
instrument('fulfilled', promise);
}
} else {
config.async(publish, promise);
}
}
export function reject(promise, reason) {
if (promise._state !== PENDING) { return; }
promise._state = REJECTED;
promise._result = reason;
config.async(publishRejection, promise);
}
export function subscribe(parent, child, onFulfillment, onRejection) {
let subscribers = parent._subscribers;
let length = subscribers.length;
parent._onError = null;
subscribers[length] = child;
subscribers[length + FULFILLED] = onFulfillment;
subscribers[length + REJECTED] = onRejection;
if (length === 0 && parent._state) {
config.async(publish, parent);
}
}
export function publish(promise) {
let subscribers = promise._subscribers;
let settled = promise._state;
if (config.instrument) {
instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise);
}
if (subscribers.length === 0) { return; }
let child, callback, result = promise._result;
for (let i = 0; i < subscribers.length; i += 3) {
child = subscribers[i];
callback = subscribers[i + settled];
if (child) {
invokeCallback(settled, child, callback, result);
} else {
callback(result);
}
}
promise._subscribers.length = 0;
}
function ErrorObject() {
this.error = null;
}
const TRY_CATCH_ERROR = new ErrorObject();
function tryCatch(callback, result) {
try {
return callback(result);
} catch(e) {
TRY_CATCH_ERROR.error = e;
return TRY_CATCH_ERROR;
}
}
export function invokeCallback(state, promise, callback, result) {
let hasCallback = isFunction(callback);
let value, error;
if (hasCallback) {
value = tryCatch(callback, result);
if (value === TRY_CATCH_ERROR) {
error = value.error;
value.error = null; // release
} else if (value === promise) {
reject(promise, withOwnPromise());
return;
}
} else {
value = result;
}
if (promise._state !== PENDING) {
// noop
} else if (hasCallback && error === undefined) {
resolve(promise, value);
} else if (error !== undefined) {
reject(promise, error);
} else if (state === FULFILLED) {
fulfill(promise, value);
} else if (state === REJECTED) {
reject(promise, value);
}
}
export function initializePromise(promise, resolver) {
let resolved = false;
try {
resolver(value => {
if (resolved) { return; }
resolved = true;
resolve(promise, value);
}, reason => {
if (resolved) { return; }
resolved = true;
reject(promise, reason);
});
} catch(e) {
reject(promise, e);
}
}

76
node_modules/rsvp/lib/rsvp/all-settled.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
import {
default as Enumerator,
makeSettledResult
} from './enumerator';
import Promise from './promise';
import { isArray } from './utils';
class AllSettled extends Enumerator {
constructor(Constructor, entries, label) {
super(Constructor, entries, false /* don't abort on reject */, label);
}
}
AllSettled.prototype._makeResult = makeSettledResult;
/**
`RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing
a fail-fast method, it waits until all the promises have returned and
shows you all the results. This is useful if you want to handle multiple
promises' failure states together as a set.
Returns a promise that is fulfilled when all the given promises have been
settled. The return promise is fulfilled with an array of the states of
the promises passed into the `promises` array argument.
Each state object will either indicate fulfillment or rejection, and
provide the corresponding value or reason. The states will take one of
the following formats:
```javascript
{ state: 'fulfilled', value: value }
or
{ state: 'rejected', reason: reason }
```
Example:
```javascript
let promise1 = RSVP.Promise.resolve(1);
let promise2 = RSVP.Promise.reject(new Error('2'));
let promise3 = RSVP.Promise.reject(new Error('3'));
let promises = [ promise1, promise2, promise3 ];
RSVP.allSettled(promises).then(function(array){
// array == [
// { state: 'fulfilled', value: 1 },
// { state: 'rejected', reason: Error },
// { state: 'rejected', reason: Error }
// ]
// Note that for the second item, reason.message will be '2', and for the
// third item, reason.message will be '3'.
}, function(error) {
// Not run. (This block would only be called if allSettled had failed,
// for instance if passed an incorrect argument type.)
});
```
@method allSettled
@static
@for RSVP
@param {Array} entries
@param {String} label - optional string that describes the promise.
Useful for tooling.
@return {Promise} promise that is fulfilled with an array of the settled
states of the constituent promises.
*/
export default function allSettled(entries, label) {
if (!isArray(entries)) {
return Promise.reject(new TypeError("Promise.allSettled must be called with an array"), label);
}
return new AllSettled(Promise, entries, label).promise;
}

15
node_modules/rsvp/lib/rsvp/all.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import Promise from "./promise";
/**
This is a convenient alias for `RSVP.Promise.all`.
@method all
@static
@for RSVP
@param {Array} array Array of promises.
@param {String} label An optional label. This is useful
for tooling.
*/
export default function all(array, label) {
return Promise.all(array, label);
}

107
node_modules/rsvp/lib/rsvp/asap.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
let len = 0;
let vertxNext;
export default function asap(callback, arg) {
queue[len] = callback;
queue[len + 1] = arg;
len += 2;
if (len === 2) {
// If len is 1, that means that we need to schedule an async flush.
// If additional callbacks are queued before the queue is flushed, they
// will be processed by this flush that we are scheduling.
scheduleFlush();
}
}
const browserWindow = (typeof window !== 'undefined') ? window : undefined;
const browserGlobal = browserWindow || {};
const BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
const isNode = typeof self === 'undefined' &&
typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
// test for web worker but not in IE10
const isWorker = typeof Uint8ClampedArray !== 'undefined' &&
typeof importScripts !== 'undefined' &&
typeof MessageChannel !== 'undefined';
// node
function useNextTick() {
let nextTick = process.nextTick;
// node version 0.10.x displays a deprecation warning when nextTick is used recursively
// setImmediate should be used instead instead
let version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
if (Array.isArray(version) && version[1] === '0' && version[2] === '10') {
nextTick = setImmediate;
}
return () => nextTick(flush);
}
// vertx
function useVertxTimer() {
if (typeof vertxNext !== 'undefined') {
return function() {
vertxNext(flush);
};
}
return useSetTimeout();
}
function useMutationObserver() {
let iterations = 0;
let observer = new BrowserMutationObserver(flush);
let node = document.createTextNode('');
observer.observe(node, { characterData: true });
return () => node.data = (iterations = ++iterations % 2);
}
// web worker
function useMessageChannel() {
let channel = new MessageChannel();
channel.port1.onmessage = flush;
return () => channel.port2.postMessage(0);
}
function useSetTimeout() {
return () => setTimeout(flush, 1);
}
const queue = new Array(1000);
function flush() {
for (let i = 0; i < len; i+=2) {
let callback = queue[i];
let arg = queue[i+1];
callback(arg);
queue[i] = undefined;
queue[i+1] = undefined;
}
len = 0;
}
function attemptVertex() {
try {
let r = require;
let vertx = r('vertx');
vertxNext = vertx.runOnLoop || vertx.runOnContext;
return useVertxTimer();
} catch(e) {
return useSetTimeout();
}
}
let scheduleFlush;
// Decide what async method to use to triggering processing of queued callbacks:
if (isNode) {
scheduleFlush = useNextTick();
} else if (BrowserMutationObserver) {
scheduleFlush = useMutationObserver();
} else if (isWorker) {
scheduleFlush = useMessageChannel();
} else if (browserWindow === undefined && typeof require === 'function') {
scheduleFlush = attemptVertex();
} else {
scheduleFlush = useSetTimeout();
}

20
node_modules/rsvp/lib/rsvp/config.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import EventTarget from './events';
const config = {
instrument: false
};
EventTarget['mixin'](config);
function configure(name, value) {
if (arguments.length === 2) {
config[name] = value;
} else {
return config[name];
}
}
export {
config,
configure
};

45
node_modules/rsvp/lib/rsvp/defer.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
import Promise from "./promise";
/**
`RSVP.defer` returns an object similar to jQuery's `$.Deferred`.
`RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s
interface. New code should use the `RSVP.Promise` constructor instead.
The object returned from `RSVP.defer` is a plain object with three properties:
* promise - an `RSVP.Promise`.
* reject - a function that causes the `promise` property on this object to
become rejected
* resolve - a function that causes the `promise` property on this object to
become fulfilled.
Example:
```javascript
let deferred = RSVP.defer();
deferred.resolve("Success!");
deferred.promise.then(function(value){
// value here is "Success!"
});
```
@method defer
@static
@for RSVP
@param {String} label optional string for labeling the promise.
Useful for tooling.
@return {Object}
*/
export default function defer(label) {
let deferred = { resolve: undefined, reject: undefined };
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
}, label);
return deferred;
}

130
node_modules/rsvp/lib/rsvp/enumerator.js generated vendored Normal file
View File

@@ -0,0 +1,130 @@
import {
isArray,
isMaybeThenable
} from './utils';
import {
noop,
resolve,
handleMaybeThenable,
reject,
fulfill,
subscribe,
FULFILLED,
REJECTED,
PENDING,
getThen
} from './-internal';
import Promise from './promise';
import originalThen from './then';
import originalResolve from './promise/resolve';
export default class Enumerator {
constructor(Constructor, input, abortOnReject, label) {
this._instanceConstructor = Constructor;
this.promise = new Constructor(noop, label);
this._abortOnReject = abortOnReject;
this._init(...arguments);
}
_init(Constructor, input) {
let len = input.length || 0;
this.length = len;
this._remaining = len;
this._result = new Array(len);
this._enumerate(input);
if (this._remaining === 0) {
fulfill(this.promise, this._result);
}
}
_enumerate(input) {
let length = this.length;
let promise = this.promise;
for (let i = 0; promise._state === PENDING && i < length; i++) {
this._eachEntry(input[i], i);
}
}
_settleMaybeThenable(entry, i) {
let c = this._instanceConstructor;
let resolve = c.resolve;
if (resolve === originalResolve) {
let then = getThen(entry);
if (then === originalThen && entry._state !== PENDING) {
entry._onError = null;
this._settledAt(entry._state, i, entry._result);
} else if (typeof then !== 'function') {
this._remaining--;
this._result[i] = this._makeResult(FULFILLED, i, entry);
} else if (c === Promise) {
let promise = new c(noop);
handleMaybeThenable(promise, entry, then);
this._willSettleAt(promise, i);
} else {
this._willSettleAt(new c(resolve => resolve(entry)), i);
}
} else {
this._willSettleAt(resolve(entry), i);
}
}
_eachEntry(entry, i) {
if (isMaybeThenable(entry)) {
this._settleMaybeThenable(entry, i);
} else {
this._remaining--;
this._result[i] = this._makeResult(FULFILLED, i, entry);
}
}
_settledAt(state, i, value) {
let promise = this.promise;
if (promise._state === PENDING) {
if (this._abortOnReject && state === REJECTED) {
reject(promise, value);
} else {
this._remaining--;
this._result[i] = this._makeResult(state, i, value);
if (this._remaining === 0) {
fulfill(promise, this._result);
}
}
}
}
_makeResult(state, i, value) {
return value;
}
_willSettleAt(promise, i) {
let enumerator = this;
subscribe(
promise, undefined,
value => enumerator._settledAt(FULFILLED, i, value),
reason => enumerator._settledAt(REJECTED, i, reason)
);
}
}
export function makeSettledResult(state, position, value) {
if (state === FULFILLED) {
return {
state: 'fulfilled',
value: value
};
} else {
return {
state: 'rejected',
reason: value
};
}
}

205
node_modules/rsvp/lib/rsvp/events.js generated vendored Normal file
View File

@@ -0,0 +1,205 @@
function indexOf(callbacks, callback) {
for (let i=0, l=callbacks.length; i<l; i++) {
if (callbacks[i] === callback) { return i; }
}
return -1;
}
function callbacksFor(object) {
let callbacks = object._promiseCallbacks;
if (!callbacks) {
callbacks = object._promiseCallbacks = {};
}
return callbacks;
}
/**
@class RSVP.EventTarget
*/
export default {
/**
`RSVP.EventTarget.mixin` extends an object with EventTarget methods. For
Example:
```javascript
let object = {};
RSVP.EventTarget.mixin(object);
object.on('finished', function(event) {
// handle event
});
object.trigger('finished', { detail: value });
```
`EventTarget.mixin` also works with prototypes:
```javascript
let Person = function() {};
RSVP.EventTarget.mixin(Person.prototype);
let yehuda = new Person();
let tom = new Person();
yehuda.on('poke', function(event) {
console.log('Yehuda says OW');
});
tom.on('poke', function(event) {
console.log('Tom says OW');
});
yehuda.trigger('poke');
tom.trigger('poke');
```
@method mixin
@for RSVP.EventTarget
@private
@param {Object} object object to extend with EventTarget methods
*/
mixin(object) {
object['on'] = this['on'];
object['off'] = this['off'];
object['trigger'] = this['trigger'];
object._promiseCallbacks = undefined;
return object;
},
/**
Registers a callback to be executed when `eventName` is triggered
```javascript
object.on('event', function(eventInfo){
// handle the event
});
object.trigger('event');
```
@method on
@for RSVP.EventTarget
@private
@param {String} eventName name of the event to listen for
@param {Function} callback function to be called when the event is triggered.
*/
on(eventName, callback) {
if (typeof callback !== 'function') {
throw new TypeError('Callback must be a function');
}
let allCallbacks = callbacksFor(this), callbacks;
callbacks = allCallbacks[eventName];
if (!callbacks) {
callbacks = allCallbacks[eventName] = [];
}
if (indexOf(callbacks, callback) === -1) {
callbacks.push(callback);
}
},
/**
You can use `off` to stop firing a particular callback for an event:
```javascript
function doStuff() { // do stuff! }
object.on('stuff', doStuff);
object.trigger('stuff'); // doStuff will be called
// Unregister ONLY the doStuff callback
object.off('stuff', doStuff);
object.trigger('stuff'); // doStuff will NOT be called
```
If you don't pass a `callback` argument to `off`, ALL callbacks for the
event will not be executed when the event fires. For example:
```javascript
let callback1 = function(){};
let callback2 = function(){};
object.on('stuff', callback1);
object.on('stuff', callback2);
object.trigger('stuff'); // callback1 and callback2 will be executed.
object.off('stuff');
object.trigger('stuff'); // callback1 and callback2 will not be executed!
```
@method off
@for RSVP.EventTarget
@private
@param {String} eventName event to stop listening to
@param {Function} callback optional argument. If given, only the function
given will be removed from the event's callback queue. If no `callback`
argument is given, all callbacks will be removed from the event's callback
queue.
*/
off(eventName, callback) {
let allCallbacks = callbacksFor(this), callbacks, index;
if (!callback) {
allCallbacks[eventName] = [];
return;
}
callbacks = allCallbacks[eventName];
index = indexOf(callbacks, callback);
if (index !== -1) { callbacks.splice(index, 1); }
},
/**
Use `trigger` to fire custom events. For example:
```javascript
object.on('foo', function(){
console.log('foo event happened!');
});
object.trigger('foo');
// 'foo event happened!' logged to the console
```
You can also pass a value as a second argument to `trigger` that will be
passed as an argument to all event listeners for the event:
```javascript
object.on('foo', function(value){
console.log(value.name);
});
object.trigger('foo', { name: 'bar' });
// 'bar' logged to the console
```
@method trigger
@for RSVP.EventTarget
@private
@param {String} eventName name of the event to be triggered
@param {*} options optional value to be passed to any event handlers for
the given `eventName`
*/
trigger(eventName, options, label) {
let allCallbacks = callbacksFor(this), callbacks, callback;
if (callbacks = allCallbacks[eventName]) {
// Don't cache the callbacks.length since it may grow
for (let i=0; i<callbacks.length; i++) {
callback = callbacks[i];
callback(options, label);
}
}
}
};

138
node_modules/rsvp/lib/rsvp/filter.js generated vendored Normal file
View File

@@ -0,0 +1,138 @@
import Promise from './promise';
import {
isFunction,
isArray,
isObject
} from './utils';
/**
`RSVP.filter` is similar to JavaScript's native `filter` method, except that it
waits for all promises to become fulfilled before running the `filterFn` on
each item in given to `promises`. `RSVP.filter` returns a promise that will
become fulfilled with the result of running `filterFn` on the values the
promises become fulfilled with.
For example:
```javascript
let promise1 = RSVP.resolve(1);
let promise2 = RSVP.resolve(2);
let promise3 = RSVP.resolve(3);
let promises = [promise1, promise2, promise3];
let filterFn = function(item){
return item > 1;
};
RSVP.filter(promises, filterFn).then(function(result){
// result is [ 2, 3 ]
});
```
If any of the `promises` given to `RSVP.filter` are rejected, the first promise
that is rejected will be given as an argument to the returned promise's
rejection handler. For example:
```javascript
let promise1 = RSVP.resolve(1);
let promise2 = RSVP.reject(new Error('2'));
let promise3 = RSVP.reject(new Error('3'));
let promises = [ promise1, promise2, promise3 ];
let filterFn = function(item){
return item > 1;
};
RSVP.filter(promises, filterFn).then(function(array){
// Code here never runs because there are rejected promises!
}, function(reason) {
// reason.message === '2'
});
```
`RSVP.filter` will also wait for any promises returned from `filterFn`.
For instance, you may want to fetch a list of users then return a subset
of those users based on some asynchronous operation:
```javascript
let alice = { name: 'alice' };
let bob = { name: 'bob' };
let users = [ alice, bob ];
let promises = users.map(function(user){
return RSVP.resolve(user);
});
let filterFn = function(user){
// Here, Alice has permissions to create a blog post, but Bob does not.
return getPrivilegesForUser(user).then(function(privs){
return privs.can_create_blog_post === true;
});
};
RSVP.filter(promises, filterFn).then(function(users){
// true, because the server told us only Alice can create a blog post.
users.length === 1;
// false, because Alice is the only user present in `users`
users[0] === bob;
});
```
@method filter
@static
@for RSVP
@param {Array} promises
@param {Function} filterFn - function to be called on each resolved value to
filter the final results.
@param {String} label optional string describing the promise. Useful for
tooling.
@return {Promise}
*/
function resolveAll(promises, label) {
return Promise.all(promises, label);
}
function resolveSingle(promise, label) {
return Promise.resolve(promise, label).then(function(promises){
return resolveAll(promises, label);
});
}
export default function filter(promises, filterFn, label) {
if (!isArray(promises) && !(isObject(promises) && promises.then !== undefined )) {
return Promise.reject(new TypeError("RSVP.filter must be called with an array or promise"), label);
}
if (!isFunction(filterFn)) {
return Promise.reject(new TypeError("RSVP.filter expects function as a second argument"), label);
}
let promise = isArray(promises) ? resolveAll(promises, label) : resolveSingle(promises, label);
return promise.then(values => {
let length = values.length;
let filtered = new Array(length);
for (let i = 0; i < length; i++) {
filtered[i] = filterFn(values[i]);
}
return resolveAll(filtered, label).then(filtered => {
let results = new Array(length);
let newLength = 0;
for (let i = 0; i < length; i++) {
if (filtered[i]) {
results[newLength] = values[i];
newLength++;
}
}
results.length = newLength;
return results;
});
});
}

122
node_modules/rsvp/lib/rsvp/hash-settled.js generated vendored Normal file
View File

@@ -0,0 +1,122 @@
import Promise from './promise';
import PromiseHash from './promise-hash';
import { isObject } from './utils';
import { makeSettledResult } from './enumerator';
class HashSettled extends PromiseHash {
constructor(Constructor, object, label) {
super(Constructor, object, false, label);
}
}
HashSettled.prototype._makeResult = makeSettledResult;
/**
`RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object
instead of an array for its `promises` argument.
Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method,
but like `RSVP.allSettled`, `hashSettled` waits until all the
constituent promises have returned and then shows you all the results
with their states and values/reasons. This is useful if you want to
handle multiple promises' failure states together as a set.
Returns a promise that is fulfilled when all the given promises have been
settled, or rejected if the passed parameters are invalid.
The returned promise is fulfilled with a hash that has the same key names as
the `promises` object argument. If any of the values in the object are not
promises, they will be copied over to the fulfilled object and marked with state
'fulfilled'.
Example:
```javascript
let promises = {
myPromise: RSVP.Promise.resolve(1),
yourPromise: RSVP.Promise.resolve(2),
theirPromise: RSVP.Promise.resolve(3),
notAPromise: 4
};
RSVP.hashSettled(promises).then(function(hash){
// hash here is an object that looks like:
// {
// myPromise: { state: 'fulfilled', value: 1 },
// yourPromise: { state: 'fulfilled', value: 2 },
// theirPromise: { state: 'fulfilled', value: 3 },
// notAPromise: { state: 'fulfilled', value: 4 }
// }
});
```
If any of the `promises` given to `RSVP.hash` are rejected, the state will
be set to 'rejected' and the reason for rejection provided.
Example:
```javascript
let promises = {
myPromise: RSVP.Promise.resolve(1),
rejectedPromise: RSVP.Promise.reject(new Error('rejection')),
anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')),
};
RSVP.hashSettled(promises).then(function(hash){
// hash here is an object that looks like:
// {
// myPromise: { state: 'fulfilled', value: 1 },
// rejectedPromise: { state: 'rejected', reason: Error },
// anotherRejectedPromise: { state: 'rejected', reason: Error },
// }
// Note that for rejectedPromise, reason.message == 'rejection',
// and for anotherRejectedPromise, reason.message == 'more rejection'.
});
```
An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that
are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype
chains.
Example:
```javascript
function MyConstructor(){
this.example = RSVP.Promise.resolve('Example');
}
MyConstructor.prototype = {
protoProperty: RSVP.Promise.resolve('Proto Property')
};
let myObject = new MyConstructor();
RSVP.hashSettled(myObject).then(function(hash){
// protoProperty will not be present, instead you will just have an
// object that looks like:
// {
// example: { state: 'fulfilled', value: 'Example' }
// }
//
// hash.hasOwnProperty('protoProperty'); // false
// 'undefined' === typeof hash.protoProperty
});
```
@method hashSettled
@for RSVP
@param {Object} object
@param {String} label optional string that describes the promise.
Useful for tooling.
@return {Promise} promise that is fulfilled when when all properties of `promises`
have been settled.
@static
*/
export default function hashSettled(object, label) {
if (!isObject(object)) {
return Promise.reject(new TypeError("RSVP.hashSettled must be called with an object"), label);
}
return new HashSettled(Promise, object, false, label).promise;
}

99
node_modules/rsvp/lib/rsvp/hash.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
import Promise from './promise';
import PromiseHash from './promise-hash';
import { isObject } from './utils';
/**
`RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array
for its `promises` argument.
Returns a promise that is fulfilled when all the given promises have been
fulfilled, or rejected if any of them become rejected. The returned promise
is fulfilled with a hash that has the same key names as the `promises` object
argument. If any of the values in the object are not promises, they will
simply be copied over to the fulfilled object.
Example:
```javascript
let promises = {
myPromise: RSVP.resolve(1),
yourPromise: RSVP.resolve(2),
theirPromise: RSVP.resolve(3),
notAPromise: 4
};
RSVP.hash(promises).then(function(hash){
// hash here is an object that looks like:
// {
// myPromise: 1,
// yourPromise: 2,
// theirPromise: 3,
// notAPromise: 4
// }
});
````
If any of the `promises` given to `RSVP.hash` are rejected, the first promise
that is rejected will be given as the reason to the rejection handler.
Example:
```javascript
let promises = {
myPromise: RSVP.resolve(1),
rejectedPromise: RSVP.reject(new Error('rejectedPromise')),
anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')),
};
RSVP.hash(promises).then(function(hash){
// Code here never runs because there are rejected promises!
}, function(reason) {
// reason.message === 'rejectedPromise'
});
```
An important note: `RSVP.hash` is intended for plain JavaScript objects that
are just a set of keys and values. `RSVP.hash` will NOT preserve prototype
chains.
Example:
```javascript
function MyConstructor(){
this.example = RSVP.resolve('Example');
}
MyConstructor.prototype = {
protoProperty: RSVP.resolve('Proto Property')
};
let myObject = new MyConstructor();
RSVP.hash(myObject).then(function(hash){
// protoProperty will not be present, instead you will just have an
// object that looks like:
// {
// example: 'Example'
// }
//
// hash.hasOwnProperty('protoProperty'); // false
// 'undefined' === typeof hash.protoProperty
});
```
@method hash
@static
@for RSVP
@param {Object} object
@param {String} label optional string that describes the promise.
Useful for tooling.
@return {Promise} promise that is fulfilled when all properties of `promises`
have been fulfilled, or rejected if any of them become rejected.
*/
export default function hash(object, label) {
if (!isObject(object)) {
return Promise.reject(new TypeError("Promise.hash must be called with an object"), label);
}
return new PromiseHash(Promise, object, label).promise;
}

40
node_modules/rsvp/lib/rsvp/instrument.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import { config } from './config';
import { now } from './utils';
const queue = [];
function scheduleFlush() {
setTimeout(() => {
for (let i = 0; i < queue.length; i++) {
let entry = queue[i];
let payload = entry.payload;
payload.guid = payload.key + payload.id;
payload.childGuid = payload.key + payload.childId;
if (payload.error) {
payload.stack = payload.error.stack;
}
config['trigger'](entry.name, entry.payload);
}
queue.length = 0;
}, 50);
}
export default function instrument(eventName, promise, child) {
if (1 === queue.push({
name: eventName,
payload: {
key: promise._guidKey,
id: promise._id,
eventName: eventName,
detail: promise._result,
childId: child && child._id,
label: promise._label,
timeStamp: now(),
error: config["instrument-with-stack"] ? new Error(promise._label) : null
}})) {
scheduleFlush();
}
}

105
node_modules/rsvp/lib/rsvp/map.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
import Promise from './promise';
import {
isFunction,
isArray
} from './utils';
/**
`RSVP.map` is similar to JavaScript's native `map` method, except that it
waits for all promises to become fulfilled before running the `mapFn` on
each item in given to `promises`. `RSVP.map` returns a promise that will
become fulfilled with the result of running `mapFn` on the values the promises
become fulfilled with.
For example:
```javascript
let promise1 = RSVP.resolve(1);
let promise2 = RSVP.resolve(2);
let promise3 = RSVP.resolve(3);
let promises = [ promise1, promise2, promise3 ];
let mapFn = function(item){
return item + 1;
};
RSVP.map(promises, mapFn).then(function(result){
// result is [ 2, 3, 4 ]
});
```
If any of the `promises` given to `RSVP.map` are rejected, the first promise
that is rejected will be given as an argument to the returned promise's
rejection handler. For example:
```javascript
let promise1 = RSVP.resolve(1);
let promise2 = RSVP.reject(new Error('2'));
let promise3 = RSVP.reject(new Error('3'));
let promises = [ promise1, promise2, promise3 ];
let mapFn = function(item){
return item + 1;
};
RSVP.map(promises, mapFn).then(function(array){
// Code here never runs because there are rejected promises!
}, function(reason) {
// reason.message === '2'
});
```
`RSVP.map` will also wait if a promise is returned from `mapFn`. For example,
say you want to get all comments from a set of blog posts, but you need
the blog posts first because they contain a url to those comments.
```javscript
let mapFn = function(blogPost){
// getComments does some ajax and returns an RSVP.Promise that is fulfilled
// with some comments data
return getComments(blogPost.comments_url);
};
// getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled
// with some blog post data
RSVP.map(getBlogPosts(), mapFn).then(function(comments){
// comments is the result of asking the server for the comments
// of all blog posts returned from getBlogPosts()
});
```
@method map
@static
@for RSVP
@param {Array} promises
@param {Function} mapFn function to be called on each fulfilled promise.
@param {String} label optional string for labeling the promise.
Useful for tooling.
@return {Promise} promise that is fulfilled with the result of calling
`mapFn` on each fulfilled promise or value when they become fulfilled.
The promise will be rejected if any of the given `promises` become rejected.
@static
*/
export default function map(promises, mapFn, label) {
if (!isArray(promises)) {
return Promise.reject(new TypeError("RSVP.map must be called with an array"), label);
}
if (!isFunction(mapFn)) {
return Promise.reject(new TypeError("RSVP.map expects a function as a second argument"), label);
}
return Promise.all(promises, label).then(values => {
let length = values.length;
let results = new Array(length);
for (let i = 0; i < length; i++) {
results[i] = mapFn(values[i]);
}
return Promise.all(results, label);
});
}

278
node_modules/rsvp/lib/rsvp/node.js generated vendored Normal file
View File

@@ -0,0 +1,278 @@
import Promise from './promise';
import {
noop,
resolve,
reject
} from './-internal';
import { isArray } from './utils';
function Result() {
this.value = undefined;
}
const ERROR = new Result();
const GET_THEN_ERROR = new Result();
function getThen(obj) {
try {
return obj.then;
} catch(error) {
ERROR.value= error;
return ERROR;
}
}
function tryApply(f, s, a) {
try {
f.apply(s, a);
} catch(error) {
ERROR.value = error;
return ERROR;
}
}
function makeObject(_, argumentNames) {
let obj = {};
let length = _.length;
let args = new Array(length);
for (let x = 0; x < length; x++) {
args[x] = _[x];
}
for (let i = 0; i < argumentNames.length; i++) {
let name = argumentNames[i];
obj[name] = args[i + 1];
}
return obj;
}
function arrayResult(_) {
let length = _.length;
let args = new Array(length - 1);
for (let i = 1; i < length; i++) {
args[i - 1] = _[i];
}
return args;
}
function wrapThenable(then, promise) {
return {
then: function(onFulFillment, onRejection) {
return then.call(promise, onFulFillment, onRejection);
}
};
}
/**
`RSVP.denodeify` takes a 'node-style' function and returns a function that
will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the
browser when you'd prefer to use promises over using callbacks. For example,
`denodeify` transforms the following:
```javascript
let fs = require('fs');
fs.readFile('myfile.txt', function(err, data){
if (err) return handleError(err);
handleData(data);
});
```
into:
```javascript
let fs = require('fs');
let readFile = RSVP.denodeify(fs.readFile);
readFile('myfile.txt').then(handleData, handleError);
```
If the node function has multiple success parameters, then `denodeify`
just returns the first one:
```javascript
let request = RSVP.denodeify(require('request'));
request('http://example.com').then(function(res) {
// ...
});
```
However, if you need all success parameters, setting `denodeify`'s
second parameter to `true` causes it to return all success parameters
as an array:
```javascript
let request = RSVP.denodeify(require('request'), true);
request('http://example.com').then(function(result) {
// result[0] -> res
// result[1] -> body
});
```
Or if you pass it an array with names it returns the parameters as a hash:
```javascript
let request = RSVP.denodeify(require('request'), ['res', 'body']);
request('http://example.com').then(function(result) {
// result.res
// result.body
});
```
Sometimes you need to retain the `this`:
```javascript
let app = require('express')();
let render = RSVP.denodeify(app.render.bind(app));
```
The denodified function inherits from the original function. It works in all
environments, except IE 10 and below. Consequently all properties of the original
function are available to you. However, any properties you change on the
denodeified function won't be changed on the original function. Example:
```javascript
let request = RSVP.denodeify(require('request')),
cookieJar = request.jar(); // <- Inheritance is used here
request('http://example.com', {jar: cookieJar}).then(function(res) {
// cookieJar.cookies holds now the cookies returned by example.com
});
```
Using `denodeify` makes it easier to compose asynchronous operations instead
of using callbacks. For example, instead of:
```javascript
let fs = require('fs');
fs.readFile('myfile.txt', function(err, data){
if (err) { ... } // Handle error
fs.writeFile('myfile2.txt', data, function(err){
if (err) { ... } // Handle error
console.log('done')
});
});
```
you can chain the operations together using `then` from the returned promise:
```javascript
let fs = require('fs');
let readFile = RSVP.denodeify(fs.readFile);
let writeFile = RSVP.denodeify(fs.writeFile);
readFile('myfile.txt').then(function(data){
return writeFile('myfile2.txt', data);
}).then(function(){
console.log('done')
}).catch(function(error){
// Handle error
});
```
@method denodeify
@static
@for RSVP
@param {Function} nodeFunc a 'node-style' function that takes a callback as
its last argument. The callback expects an error to be passed as its first
argument (if an error occurred, otherwise null), and the value from the
operation as its second argument ('function(err, value){ }').
@param {Boolean|Array} [options] An optional paramter that if set
to `true` causes the promise to fulfill with the callback's success arguments
as an array. This is useful if the node function has multiple success
paramters. If you set this paramter to an array with names, the promise will
fulfill with a hash with these names as keys and the success parameters as
values.
@return {Function} a function that wraps `nodeFunc` to return an
`RSVP.Promise`
@static
*/
export default function denodeify(nodeFunc, options) {
let fn = function() {
let self = this;
let l = arguments.length;
let args = new Array(l + 1);
let promiseInput = false;
for (let i = 0; i < l; ++i) {
let arg = arguments[i];
if (!promiseInput) {
// TODO: clean this up
promiseInput = needsPromiseInput(arg);
if (promiseInput === GET_THEN_ERROR) {
let p = new Promise(noop);
reject(p, GET_THEN_ERROR.value);
return p;
} else if (promiseInput && promiseInput !== true) {
arg = wrapThenable(promiseInput, arg);
}
}
args[i] = arg;
}
let promise = new Promise(noop);
args[l] = function(err, val) {
if (err)
reject(promise, err);
else if (options === undefined)
resolve(promise, val);
else if (options === true)
resolve(promise, arrayResult(arguments));
else if (isArray(options))
resolve(promise, makeObject(arguments, options));
else
resolve(promise, val);
};
if (promiseInput) {
return handlePromiseInput(promise, args, nodeFunc, self);
} else {
return handleValueInput(promise, args, nodeFunc, self);
}
};
fn.__proto__ = nodeFunc;
return fn;
}
function handleValueInput(promise, args, nodeFunc, self) {
let result = tryApply(nodeFunc, self, args);
if (result === ERROR) {
reject(promise, result.value);
}
return promise;
}
function handlePromiseInput(promise, args, nodeFunc, self){
return Promise.all(args).then(args => {
let result = tryApply(nodeFunc, self, args);
if (result === ERROR) {
reject(promise, result.value);
}
return promise;
});
}
function needsPromiseInput(arg) {
if (arg && typeof arg === 'object') {
if (arg.constructor === Promise) {
return true;
} else {
return getThen(arg);
}
} else {
return false;
}
}

14
node_modules/rsvp/lib/rsvp/platform.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
let platform;
/* global self */
if (typeof self === 'object') {
platform = self;
/* global global */
} else if (typeof global === 'object') {
platform = global;
} else {
throw new Error('no global: `self` or `global` found');
}
export default platform;

46
node_modules/rsvp/lib/rsvp/promise-hash.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import Enumerator from './enumerator';
import {
PENDING,
FULFILLED,
fulfill
} from './-internal';
const hasOwnProperty = Object.prototype.hasOwnProperty;
export default class PromiseHash extends Enumerator {
constructor(Constructor, object, abortOnReject = true, label) {
super(Constructor, object, abortOnReject, label);
}
_init(Constructor, object) {
this._result = {};
this._enumerate(object);
if (this._remaining === 0) {
fulfill(this.promise, this._result);
}
}
_enumerate(input) {
let promise = this.promise;
let results = [];
for (let key in input) {
if (hasOwnProperty.call(input, key)) {
results.push({
position: key,
entry: input[key]
});
}
}
let length = results.length;
this._remaining = length;
let result;
for (let i = 0; promise._state === PENDING && i < length; i++) {
result = results[i];
this._eachEntry(result.entry, result.position);
}
}
}

443
node_modules/rsvp/lib/rsvp/promise.js generated vendored Normal file
View File

@@ -0,0 +1,443 @@
import { config } from './config';
import instrument from './instrument';
import then from './then';
import {
isFunction,
now
} from './utils';
import {
noop,
initializePromise
} from './-internal';
import all from './promise/all';
import race from './promise/race';
import Resolve from './promise/resolve';
import Reject from './promise/reject';
const guidKey = 'rsvp_' + now() + '-';
let counter = 0;
function needsResolver() {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
}
function needsNew() {
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
}
/**
Promise objects represent the eventual result of an asynchronous operation. The
primary way of interacting with a promise is through its `then` method, which
registers callbacks to receive either a promises eventual value or the reason
why the promise cannot be fulfilled.
Terminology
-----------
- `promise` is an object or function with a `then` method whose behavior conforms to this specification.
- `thenable` is an object or function that defines a `then` method.
- `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
- `exception` is a value that is thrown using the throw statement.
- `reason` is a value that indicates why a promise was rejected.
- `settled` the final resting state of a promise, fulfilled or rejected.
A promise can be in one of three states: pending, fulfilled, or rejected.
Promises that are fulfilled have a fulfillment value and are in the fulfilled
state. Promises that are rejected have a rejection reason and are in the
rejected state. A fulfillment value is never a thenable.
Promises can also be said to *resolve* a value. If this value is also a
promise, then the original promise's settled state will match the value's
settled state. So a promise that *resolves* a promise that rejects will
itself reject, and a promise that *resolves* a promise that fulfills will
itself fulfill.
Basic Usage:
------------
```js
let promise = new Promise(function(resolve, reject) {
// on success
resolve(value);
// on failure
reject(reason);
});
promise.then(function(value) {
// on fulfillment
}, function(reason) {
// on rejection
});
```
Advanced Usage:
---------------
Promises shine when abstracting away asynchronous interactions such as
`XMLHttpRequest`s.
```js
function getJSON(url) {
return new Promise(function(resolve, reject){
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = handler;
xhr.responseType = 'json';
xhr.setRequestHeader('Accept', 'application/json');
xhr.send();
function handler() {
if (this.readyState === this.DONE) {
if (this.status === 200) {
resolve(this.response);
} else {
reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
}
}
};
});
}
getJSON('/posts.json').then(function(json) {
// on fulfillment
}, function(reason) {
// on rejection
});
```
Unlike callbacks, promises are great composable primitives.
```js
Promise.all([
getJSON('/posts'),
getJSON('/comments')
]).then(function(values){
values[0] // => postsJSON
values[1] // => commentsJSON
return values;
});
```
@class RSVP.Promise
@param {function} resolver
@param {String} label optional string for labeling the promise.
Useful for tooling.
@constructor
*/
class Promise {
constructor(resolver, label) {
this._id = counter++;
this._label = label;
this._state = undefined;
this._result = undefined;
this._subscribers = [];
config.instrument && instrument('created', this);
if (noop !== resolver) {
typeof resolver !== 'function' && needsResolver();
this instanceof Promise ? initializePromise(this, resolver) : needsNew();
}
}
_onError(reason) {
config.after(() => {
if (this._onError) {
config.trigger('error', reason, this._label);
}
});
}
/**
`catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
as the catch block of a try/catch statement.
```js
function findAuthor(){
throw new Error('couldn\'t find that author');
}
// synchronous
try {
findAuthor();
} catch(reason) {
// something went wrong
}
// async with promises
findAuthor().catch(function(reason){
// something went wrong
});
```
@method catch
@param {Function} onRejection
@param {String} label optional string for labeling the promise.
Useful for tooling.
@return {Promise}
*/
catch(onRejection, label) {
return this.then(undefined, onRejection, label);
}
/**
`finally` will be invoked regardless of the promise's fate just as native
try/catch/finally behaves
Synchronous example:
```js
findAuthor() {
if (Math.random() > 0.5) {
throw new Error();
}
return new Author();
}
try {
return findAuthor(); // succeed or fail
} catch(error) {
return findOtherAuthor();
} finally {
// always runs
// doesn't affect the return value
}
```
Asynchronous example:
```js
findAuthor().catch(function(reason){
return findOtherAuthor();
}).finally(function(){
// author was either found, or not
});
```
@method finally
@param {Function} callback
@param {String} label optional string for labeling the promise.
Useful for tooling.
@return {Promise}
*/
finally(callback, label) {
let promise = this;
let constructor = promise.constructor;
return promise.then(value => constructor.resolve(callback()).then(() => value),
reason => constructor.resolve(callback()).then(() => { throw reason; }), label);
}
};
Promise.cast = Resolve; // deprecated
Promise.all = all;
Promise.race = race;
Promise.resolve = Resolve;
Promise.reject = Reject;
Promise.prototype._guidKey = guidKey;
/**
The primary way of interacting with a promise is through its `then` method,
which registers callbacks to receive either a promise's eventual value or the
reason why the promise cannot be fulfilled.
```js
findUser().then(function(user){
// user is available
}, function(reason){
// user is unavailable, and you are given the reason why
});
```
Chaining
--------
The return value of `then` is itself a promise. This second, 'downstream'
promise is resolved with the return value of the first promise's fulfillment
or rejection handler, or rejected if the handler throws an exception.
```js
findUser().then(function (user) {
return user.name;
}, function (reason) {
return 'default name';
}).then(function (userName) {
// If `findUser` fulfilled, `userName` will be the user's name, otherwise it
// will be `'default name'`
});
findUser().then(function (user) {
throw new Error('Found user, but still unhappy');
}, function (reason) {
throw new Error('`findUser` rejected and we\'re unhappy');
}).then(function (value) {
// never reached
}, function (reason) {
// if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
// If `findUser` rejected, `reason` will be '`findUser` rejected and we\'re unhappy'.
});
```
If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
```js
findUser().then(function (user) {
throw new PedagogicalException('Upstream error');
}).then(function (value) {
// never reached
}).then(function (value) {
// never reached
}, function (reason) {
// The `PedgagocialException` is propagated all the way down to here
});
```
Assimilation
------------
Sometimes the value you want to propagate to a downstream promise can only be
retrieved asynchronously. This can be achieved by returning a promise in the
fulfillment or rejection handler. The downstream promise will then be pending
until the returned promise is settled. This is called *assimilation*.
```js
findUser().then(function (user) {
return findCommentsByAuthor(user);
}).then(function (comments) {
// The user's comments are now available
});
```
If the assimliated promise rejects, then the downstream promise will also reject.
```js
findUser().then(function (user) {
return findCommentsByAuthor(user);
}).then(function (comments) {
// If `findCommentsByAuthor` fulfills, we'll have the value here
}, function (reason) {
// If `findCommentsByAuthor` rejects, we'll have the reason here
});
```
Simple Example
--------------
Synchronous Example
```javascript
let result;
try {
result = findResult();
// success
} catch(reason) {
// failure
}
```
Errback Example
```js
findResult(function(result, err){
if (err) {
// failure
} else {
// success
}
});
```
Promise Example;
```javascript
findResult().then(function(result){
// success
}, function(reason){
// failure
});
```
Advanced Example
--------------
Synchronous Example
```javascript
let author, books;
try {
author = findAuthor();
books = findBooksByAuthor(author);
// success
} catch(reason) {
// failure
}
```
Errback Example
```js
function foundBooks(books) {
}
function failure(reason) {
}
findAuthor(function(author, err){
if (err) {
failure(err);
// failure
} else {
try {
findBoooksByAuthor(author, function(books, err) {
if (err) {
failure(err);
} else {
try {
foundBooks(books);
} catch(reason) {
failure(reason);
}
}
});
} catch(error) {
failure(err);
}
// success
}
});
```
Promise Example;
```javascript
findAuthor().
then(findBooksByAuthor).
then(function(books){
// found books
}).catch(function(reason){
// something went wrong
});
```
@method then
@param {Function} onFulfillment
@param {Function} onRejection
@param {String} label optional string for labeling the promise.
Useful for tooling.
@return {Promise}
*/
Promise.prototype.then = then;
export default Promise;

56
node_modules/rsvp/lib/rsvp/promise/all.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
import Enumerator from '../enumerator';
import { isArray } from '../utils';
/**
`RSVP.Promise.all` accepts an array of promises, and returns a new promise which
is fulfilled with an array of fulfillment values for the passed promises, or
rejected with the reason of the first passed promise to be rejected. It casts all
elements of the passed iterable to promises as it runs this algorithm.
Example:
```javascript
let promise1 = RSVP.resolve(1);
let promise2 = RSVP.resolve(2);
let promise3 = RSVP.resolve(3);
let promises = [ promise1, promise2, promise3 ];
RSVP.Promise.all(promises).then(function(array){
// The array here would be [ 1, 2, 3 ];
});
```
If any of the `promises` given to `RSVP.all` are rejected, the first promise
that is rejected will be given as an argument to the returned promises's
rejection handler. For example:
Example:
```javascript
let promise1 = RSVP.resolve(1);
let promise2 = RSVP.reject(new Error("2"));
let promise3 = RSVP.reject(new Error("3"));
let promises = [ promise1, promise2, promise3 ];
RSVP.Promise.all(promises).then(function(array){
// Code here never runs because there are rejected promises!
}, function(error) {
// error.message === "2"
});
```
@method all
@static
@param {Array} entries array of promises
@param {String} label optional string for labeling the promise.
Useful for tooling.
@return {Promise} promise that is fulfilled when all `promises` have been
fulfilled, or rejected if any of them become rejected.
@static
*/
export default function all(entries, label) {
if (!isArray(entries)) {
return this.reject(new TypeError("Promise.all must be called with an array"), label);
}
return new Enumerator(this, entries, true /* abort on reject */, label).promise;
}

97
node_modules/rsvp/lib/rsvp/promise/race.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
import {
isArray
} from "../utils";
import {
noop,
resolve,
reject,
subscribe,
PENDING
} from '../-internal';
/**
`RSVP.Promise.race` returns a new promise which is settled in the same way as the
first passed promise to settle.
Example:
```javascript
let promise1 = new RSVP.Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 1');
}, 200);
});
let promise2 = new RSVP.Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 2');
}, 100);
});
RSVP.Promise.race([promise1, promise2]).then(function(result){
// result === 'promise 2' because it was resolved before promise1
// was resolved.
});
```
`RSVP.Promise.race` is deterministic in that only the state of the first
settled promise matters. For example, even if other promises given to the
`promises` array argument are resolved, but the first settled promise has
become rejected before the other promises became fulfilled, the returned
promise will become rejected:
```javascript
let promise1 = new RSVP.Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 1');
}, 200);
});
let promise2 = new RSVP.Promise(function(resolve, reject){
setTimeout(function(){
reject(new Error('promise 2'));
}, 100);
});
RSVP.Promise.race([promise1, promise2]).then(function(result){
// Code here never runs
}, function(reason){
// reason.message === 'promise 2' because promise 2 became rejected before
// promise 1 became fulfilled
});
```
An example real-world use case is implementing timeouts:
```javascript
RSVP.Promise.race([ajax('foo.json'), timeout(5000)])
```
@method race
@static
@param {Array} entries array of promises to observe
@param {String} label optional string for describing the promise returned.
Useful for tooling.
@return {Promise} a promise which settles in the same way as the first passed
promise to settle.
*/
export default function race(entries, label) {
/*jshint validthis:true */
let Constructor = this;
let promise = new Constructor(noop, label);
if (!isArray(entries)) {
reject(promise, new TypeError('Promise.race must be called with an array'));
return promise;
}
for (let i = 0; promise._state === PENDING && i < entries.length; i++) {
subscribe(Constructor.resolve(entries[i]), undefined,
value => resolve(promise, value),
reason => reject(promise, reason));
}
return promise;
}

47
node_modules/rsvp/lib/rsvp/promise/reject.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
import {
noop,
reject as _reject
} from '../-internal';
/**
`RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
It is shorthand for the following:
```javascript
let promise = new RSVP.Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
// Code here doesn't run because the promise is rejected!
}, function(reason){
// reason.message === 'WHOOPS'
});
```
Instead of writing the above, your code now simply becomes the following:
```javascript
let promise = RSVP.Promise.reject(new Error('WHOOPS'));
promise.then(function(value){
// Code here doesn't run because the promise is rejected!
}, function(reason){
// reason.message === 'WHOOPS'
});
```
@method reject
@static
@param {*} reason value that the returned promise will be rejected with.
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise rejected with the given `reason`.
*/
export default function reject(reason, label) {
/*jshint validthis:true */
let Constructor = this;
let promise = new Constructor(noop, label);
_reject(promise, reason);
return promise;
}

49
node_modules/rsvp/lib/rsvp/promise/resolve.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
import {
noop,
resolve as _resolve
} from '../-internal';
/**
`RSVP.Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new RSVP.Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
```
Instead of writing the above, your code now simply becomes the following:
```javascript
let promise = RSVP.Promise.resolve(1);
promise.then(function(value){
// value === 1
});
```
@method resolve
@static
@param {*} object value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise that will become fulfilled with the given
`value`
*/
export default function resolve(object, label) {
/*jshint validthis:true */
let Constructor = this;
if (object && typeof object === 'object' && object.constructor === Constructor) {
return object;
}
let promise = new Constructor(noop, label);
_resolve(promise, object);
return promise;
}

15
node_modules/rsvp/lib/rsvp/race.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import Promise from './promise';
/**
This is a convenient alias for `RSVP.Promise.race`.
@method race
@static
@for RSVP
@param {Array} array Array of promises.
@param {String} label An optional label. This is useful
for tooling.
*/
export default function race(array, label) {
return Promise.race(array, label);
}

16
node_modules/rsvp/lib/rsvp/reject.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import Promise from './promise';
/**
This is a convenient alias for `RSVP.Promise.reject`.
@method reject
@static
@for RSVP
@param {*} reason value that the returned promise will be rejected with.
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise rejected with the given `reason`.
*/
export default function reject(reason, label) {
return Promise.reject(reason, label);
}

17
node_modules/rsvp/lib/rsvp/resolve.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import Promise from './promise';
/**
This is a convenient alias for `RSVP.Promise.resolve`.
@method resolve
@static
@for RSVP
@param {*} value value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise that will become fulfilled with the given
`value`
*/
export default function resolve(value, label) {
return Promise.resolve(value, label);
}

46
node_modules/rsvp/lib/rsvp/rethrow.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/**
`RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event
loop in order to aid debugging.
Promises A+ specifies that any exceptions that occur with a promise must be
caught by the promises implementation and bubbled to the last handler. For
this reason, it is recommended that you always specify a second rejection
handler function to `then`. However, `RSVP.rethrow` will throw the exception
outside of the promise, so it bubbles up to your console if in the browser,
or domain/cause uncaught exception in Node. `rethrow` will also throw the
error again so the error can be handled by the promise per the spec.
```javascript
function throws(){
throw new Error('Whoops!');
}
let promise = new RSVP.Promise(function(resolve, reject){
throws();
});
promise.catch(RSVP.rethrow).then(function(){
// Code here doesn't run because the promise became rejected due to an
// error!
}, function (err){
// handle the error here
});
```
The 'Whoops' error will be thrown on the next turn of the event loop
and you can watch for it in your console. You can also handle it using a
rejection handler given to `.then` or `.catch` on the returned promise.
@method rethrow
@static
@for RSVP
@param {Error} reason reason the promise became rejected.
@throws Error
@static
*/
export default function rethrow(reason) {
setTimeout(() => {
throw reason;
});
throw reason;
}

36
node_modules/rsvp/lib/rsvp/then.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import { config } from './config';
import instrument from './instrument';
import {
noop,
subscribe,
FULFILLED,
REJECTED,
PENDING,
invokeCallback
} from './-internal';
export default function then(onFulfillment, onRejection, label) {
let parent = this;
let state = parent._state;
if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
config.instrument && instrument('chained', parent, parent);
return parent;
}
parent._onError = null;
let child = new parent.constructor(noop, label);
let result = parent._result;
config.instrument && instrument('chained', parent, child);
if (state === PENDING) {
subscribe(parent, child, onFulfillment, onRejection);
} else {
let callback = state === FULFILLED ? onFulfillment : onRejection;
config.async(() => invokeCallback(state, child, callback, result));
}
return child;
}

29
node_modules/rsvp/lib/rsvp/utils.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
export function objectOrFunction(x) {
let type = typeof x;
return x !== null && (type === 'object' || type === 'function');
}
export function isFunction(x) {
return typeof x === 'function';
}
export function isObject(x) {
return x !== null && typeof x === 'object';
}
export function isMaybeThenable(x) {
return x !== null && typeof x === 'object';
}
let _isArray;
if (Array.isArray) {
_isArray = Array.isArray;
} else {
_isArray = x => Object.prototype.toString.call(x) === '[object Array]';
}
export const isArray = _isArray;
// Date.now is not available in browsers < IE9
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
export const now = Date.now || (() => new Date().getTime());

151
node_modules/rsvp/package.json generated vendored Normal file
View File

@@ -0,0 +1,151 @@
{
"_args": [
[
"rsvp@^3.3.3",
"/home/bernhard/freifunk-app/node_modules/capture-exit"
]
],
"_from": "rsvp@>=3.3.3 <4.0.0",
"_id": "rsvp@3.6.2",
"_inCache": true,
"_installable": true,
"_location": "/rsvp",
"_nodeVersion": "8.1.3",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/rsvp-3.6.2.tgz_1500348550749_0.8795863993000239"
},
"_npmUser": {
"email": "stefan.penner@gmail.com",
"name": "stefanpenner"
},
"_npmVersion": "5.1.0",
"_phantomChildren": {},
"_requested": {
"name": "rsvp",
"raw": "rsvp@^3.3.3",
"rawSpec": "^3.3.3",
"scope": null,
"spec": ">=3.3.3 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/capture-exit"
],
"_resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz",
"_shasum": "2e96491599a96cde1b515d5674a8f7a91452926a",
"_shrinkwrap": null,
"_spec": "rsvp@^3.3.3",
"_where": "/home/bernhard/freifunk-app/node_modules/capture-exit",
"author": {
"name": "Tilde, Inc. & Stefan Penner"
},
"browser": {
"vertx": false
},
"bugs": {
"url": "https://github.com/tildeio/rsvp.js/issues"
},
"dependencies": {},
"description": "A lightweight library that provides tools for organizing asynchronous code",
"devDependencies": {
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-block-scoping": "^6.24.1",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-computed-properties": "^6.24.1",
"babel-plugin-transform-es2015-constants": "^6.1.4",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-es2015-template-literals": "^6.22.0",
"babel-preset-env": "^1.5.2",
"babel6-plugin-strip-class-callcheck": "^6.0.0",
"broccoli-babel-transpiler": "^6.0.0",
"broccoli-concat": "^3.2.2",
"broccoli-merge-trees": "^2.0.0",
"broccoli-rollup": "^1.3.0",
"broccoli-stew": "^1.5.0",
"broccoli-uglify-js": "^0.2.0",
"broccoli-watchify": "1.0.1",
"ember-cli": "2.13.2",
"ember-cli-dependency-checker": "2.0.0",
"ember-publisher": "0.0.7",
"git-repo-version": "0.4.1",
"json3": "^3.3.2",
"mocha": "3.4.2",
"promises-aplus-tests-phantom": "^2.1.0-revise"
},
"directories": {
"lib": "lib"
},
"dist": {
"integrity": "sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==",
"shasum": "2e96491599a96cde1b515d5674a8f7a91452926a",
"tarball": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz"
},
"engines": {
"node": "0.12.* || 4.* || 6.* || >= 7.*"
},
"files": [
"!dist/test",
"dist",
"lib"
],
"gitHead": "a8b79ea0fc2cba55a507383940b0753a089688fd",
"homepage": "https://github.com/tildeio/rsvp.js#readme",
"jsnext:main": "dist/rsvp.es.js",
"keywords": [
"futures",
"promises"
],
"license": "MIT",
"main": "dist/rsvp.js",
"maintainers": [
{
"name": "rwjblue",
"email": "me@rwjblue.com"
},
{
"name": "ryanflorence",
"email": "rpflorence@gmail.com"
},
{
"name": "stefanpenner",
"email": "stefan.penner@gmail.com"
},
{
"name": "fivetanley",
"email": "stanley@stan.li"
},
{
"name": "mixonic",
"email": "matt.beale@madhatted.com"
},
{
"name": "wycats",
"email": "wycats@gmail.com"
}
],
"module": "dist/rsvp.es.js",
"name": "rsvp",
"namespace": "RSVP",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"dist": "git@github.com:components/rsvp.js.git",
"type": "git",
"url": "git+https://github.com/tildeio/rsvp.js.git"
},
"scripts": {
"build": "ember build --environment production",
"build:production": "ember build --env production",
"lint": "jshint lib",
"prepublish": "ember build --environment production",
"start": "ember s",
"test": "ember test",
"test:node": "ember build && mocha ./dist/test/browserify",
"test:server": "ember test --server"
},
"version": "3.6.2"
}