{ "_args": [ [ { "raw": "promise@^7.1.1", "scope": null, "escapedName": "promise", "name": "promise", "rawSpec": "^7.1.1", "spec": ">=7.1.1 <8.0.0", "type": "range" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/fbjs" ] ], "_from": "promise@>=7.1.1 <8.0.0", "_id": "promise@7.3.1", "_inCache": true, "_location": "/promise", "_nodeVersion": "8.0.0", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/promise-7.3.1.tgz_1497910542099_0.35927393985912204" }, "_npmUser": { "name": "forbeslindesay", "email": "forbes@lindesay.co.uk" }, "_npmVersion": "5.0.3", "_phantomChildren": {}, "_requested": { "raw": "promise@^7.1.1", "scope": null, "escapedName": "promise", "name": "promise", "rawSpec": "^7.1.1", "spec": ">=7.1.1 <8.0.0", "type": "range" }, "_requiredBy": [ "/fbjs" ], "_resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", "_shasum": "064b72602b18f90f29192b8b1bc418ffd1ebd3bf", "_shrinkwrap": null, "_spec": "promise@^7.1.1", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/fbjs", "author": { "name": "ForbesLindesay" }, "bugs": { "url": "https://github.com/then/promise/issues" }, "dependencies": { "asap": "~2.0.3" }, "description": "Bare bones Promises/A+ implementation", "devDependencies": { "acorn": "^1.0.1", "better-assert": "*", "istanbul": "^0.3.13", "mocha": "*", "promises-aplus-tests": "*", "rimraf": "^2.3.2" }, "directories": {}, "dist": { "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", "shasum": "064b72602b18f90f29192b8b1bc418ffd1ebd3bf", "tarball": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz" }, "gitHead": "cebfa6049cc08843f428c6fc92dde918f8687e6d", "homepage": "https://github.com/then/promise#readme", "license": "MIT", "main": "index.js", "maintainers": [ { "name": "forbeslindesay", "email": "forbes@lindesay.co.uk" }, { "name": "nathan7", "email": "nathan@nathan7.eu" } ], "name": "promise", "optionalDependencies": {}, "readme": "\n# promise\n\nThis is a simple implementation of Promises. It is a super set of ES6 Promises designed to have readable, performant code and to provide just the extensions that are absolutely necessary for using promises today.\n\nFor detailed tutorials on its use, see www.promisejs.org\n\n**N.B.** This promise exposes internals via underscore (`_`) prefixed properties. If you use these, your code will break with each new release.\n\n[![travis][travis-image]][travis-url]\n[![dep][dep-image]][dep-url]\n[![npm][npm-image]][npm-url]\n[![downloads][downloads-image]][downloads-url]\n\n[travis-image]: https://img.shields.io/travis/then/promise.svg?style=flat\n[travis-url]: https://travis-ci.org/then/promise\n[dep-image]: https://img.shields.io/david/then/promise.svg?style=flat\n[dep-url]: https://david-dm.org/then/promise\n[npm-image]: https://img.shields.io/npm/v/promise.svg?style=flat\n[npm-url]: https://npmjs.org/package/promise\n[downloads-image]: https://img.shields.io/npm/dm/promise.svg?style=flat\n[downloads-url]: https://npmjs.org/package/promise\n\n## Installation\n\n**Server:**\n\n $ npm install promise\n\n**Client:**\n\nYou can use browserify on the client, or use the pre-compiled script that acts as a polyfill.\n\n```html\n\n```\n\nNote that the [es5-shim](https://github.com/es-shims/es5-shim) must be loaded before this library to support browsers pre IE9.\n\n```html\n\n```\n\n## Usage\n\nThe example below shows how you can load the promise library (in a way that works on both client and server using node or browserify). It then demonstrates creating a promise from scratch. You simply call `new Promise(fn)`. There is a complete specification for what is returned by this method in [Promises/A+](http://promises-aplus.github.com/promises-spec/).\n\n```javascript\nvar Promise = require('promise');\n\nvar promise = new Promise(function (resolve, reject) {\n get('http://www.google.com', function (err, res) {\n if (err) reject(err);\n else resolve(res);\n });\n});\n```\n\nIf you need [domains](https://iojs.org/api/domain.html) support, you should instead use:\n\n```js\nvar Promise = require('promise/domains');\n```\n\nIf you are in an environment that implements `setImmediate` and don't want the optimisations provided by asap, you can use:\n\n```js\nvar Promise = require('promise/setimmediate');\n```\n\nIf you only want part of the features, e.g. just a pure ES6 polyfill:\n\n```js\nvar Promise = require('promise/lib/es6-extensions');\n// or require('promise/domains/es6-extensions');\n// or require('promise/setimmediate/es6-extensions');\n```\n\n## Unhandled Rejections\n\nBy default, promises silence any unhandled rejections.\n\nYou can enable logging of unhandled ReferenceErrors and TypeErrors via:\n\n```js\nrequire('promise/lib/rejection-tracking').enable();\n```\n\nDue to the performance cost, you should only do this during development.\n\nYou can enable logging of all unhandled rejections if you need to debug an exception you think is being swallowed by promises:\n\n```js\nrequire('promise/lib/rejection-tracking').enable(\n {allRejections: true}\n);\n```\n\nDue to the high probability of false positives, I only recommend using this when debugging specific issues that you think may be being swallowed. For the preferred debugging method, see `Promise#done(onFulfilled, onRejected)`.\n\n`rejection-tracking.enable(options)` takes the following options:\n\n - allRejections (`boolean`) - track all exceptions, not just reference errors and type errors. Note that this has a high probability of resulting in false positives if your code loads data optimisticly\n - whitelist (`Array`) - this defaults to `[ReferenceError, TypeError]` but you can override it with your own list of error constructors to track.\n - `onUnhandled(id, error)` and `onHandled(id, error)` - you can use these to provide your own customised display for errors. Note that if possible you should indicate that the error was a false positive if `onHandled` is called. `onHandled` is only called if `onUnhandled` has already been called.\n\nTo reduce the chance of false-positives there is a delay of up to 2 seconds before errors are logged. This means that if you attach an error handler within 2 seconds, it won't be logged as a false positive. ReferenceErrors and TypeErrors are only subject to a 100ms delay due to the higher likelihood that the error is due to programmer error.\n\n## API\n\nBefore all examples, you will need:\n\n```js\nvar Promise = require('promise');\n```\n\n### new Promise(resolver)\n\nThis creates and returns a new promise. `resolver` must be a function. The `resolver` function is passed two arguments:\n\n 1. `resolve` should be called with a single argument. If it is called with a non-promise value then the promise is fulfilled with that value. If it is called with a promise (A) then the returned promise takes on the state of that new promise (A).\n 2. `reject` should be called with a single argument. The returned promise will be rejected with that argument.\n\n### Static Functions\n\n These methods are invoked by calling `Promise.methodName`.\n\n#### Promise.resolve(value)\n\n(deprecated aliases: `Promise.from(value)`, `Promise.cast(value)`)\n\nConverts values and foreign promises into Promises/A+ promises. If you pass it a value then it returns a Promise for that value. If you pass it something that is close to a promise (such as a jQuery attempt at a promise) it returns a Promise that takes on the state of `value` (rejected or fulfilled).\n\n#### Promise.reject(value)\n\nReturns a rejected promise with the given value.\n\n#### Promise.all(array)\n\nReturns a promise for an array. If it is called with a single argument that `Array.isArray` then this returns a promise for a copy of that array with any promises replaced by their fulfilled values. e.g.\n\n```js\nPromise.all([Promise.resolve('a'), 'b', Promise.resolve('c')])\n .then(function (res) {\n assert(res[0] === 'a')\n assert(res[1] === 'b')\n assert(res[2] === 'c')\n })\n```\n\n#### Promise.denodeify(fn)\n\n_Non Standard_\n\nTakes a function which accepts a node style callback and returns a new function that returns a promise instead.\n\ne.g.\n\n```javascript\nvar fs = require('fs')\n\nvar read = Promise.denodeify(fs.readFile)\nvar write = Promise.denodeify(fs.writeFile)\n\nvar p = read('foo.json', 'utf8')\n .then(function (str) {\n return write('foo.json', JSON.stringify(JSON.parse(str), null, ' '), 'utf8')\n })\n```\n\n#### Promise.nodeify(fn)\n\n_Non Standard_\n\nThe twin to `denodeify` is useful when you want to export an API that can be used by people who haven't learnt about the brilliance of promises yet.\n\n```javascript\nmodule.exports = Promise.nodeify(awesomeAPI)\nfunction awesomeAPI(a, b) {\n return download(a, b)\n}\n```\n\nIf the last argument passed to `module.exports` is a function, then it will be treated like a node.js callback and not parsed on to the child function, otherwise the API will just return a promise.\n\n### Prototype Methods\n\nThese methods are invoked on a promise instance by calling `myPromise.methodName`\n\n### Promise#then(onFulfilled, onRejected)\n\nThis method follows the [Promises/A+ spec](http://promises-aplus.github.io/promises-spec/). It explains things very clearly so I recommend you read it.\n\nEither `onFulfilled` or `onRejected` will be called and they will not be called more than once. They will be passed a single argument and will always be called asynchronously (in the next turn of the event loop).\n\nIf the promise is fulfilled then `onFulfilled` is called. If the promise is rejected then `onRejected` is called.\n\nThe call to `.then` also returns a promise. If the handler that is called returns a promise, the promise returned by `.then` takes on the state of that returned promise. If the handler that is called returns a value that is not a promise, the promise returned by `.then` will be fulfilled with that value. If the handler that is called throws an exception then the promise returned by `.then` is rejected with that exception.\n\n#### Promise#catch(onRejected)\n\nSugar for `Promise#then(null, onRejected)`, to mirror `catch` in synchronous code.\n\n#### Promise#done(onFulfilled, onRejected)\n\n_Non Standard_\n\nThe same semantics as `.then` except that it does not return a promise and any exceptions are re-thrown so that they can be logged (crashing the application in non-browser environments)\n\n#### Promise#nodeify(callback)\n\n_Non Standard_\n\nIf `callback` is `null` or `undefined` it just returns `this`. If `callback` is a function it is called with rejection reason as the first argument and result as the second argument (as per the node.js convention).\n\nThis lets you write API functions that look like:\n\n```javascript\nfunction awesomeAPI(foo, bar, callback) {\n return internalAPI(foo, bar)\n .then(parseResult)\n .then(null, retryErrors)\n .nodeify(callback)\n}\n```\n\nPeople who use typical node.js style callbacks will be able to just pass a callback and get the expected behavior. The enlightened people can not pass a callback and will get awesome promises.\n\n## License\n\n MIT\n", "readmeFilename": "Readme.md", "repository": { "type": "git", "url": "git+https://github.com/then/promise.git" }, "scripts": { "coverage": "istanbul cover node_modules/mocha/bin/_mocha -- --bail --timeout 200 --slow 99999 -R dot", "prepublish": "node build", "pretest": "node build", "pretest-extensions": "node build", "pretest-memory-leak": "node build", "pretest-resolve": "node build", "test": "mocha --bail --timeout 200 --slow 99999 -R dot && npm run test-memory-leak", "test-extensions": "mocha test/extensions-tests.js --timeout 200 --slow 999999", "test-memory-leak": "node --expose-gc test/memory-leak.js", "test-resolve": "mocha test/resolver-tests.js --timeout 200 --slow 999999" }, "version": "7.3.1" }