39 lines
9.2 KiB
JSON
39 lines
9.2 KiB
JSON
|
{
|
||
|
"name": "promise",
|
||
|
"version": "5.0.0",
|
||
|
"description": "Bare bones Promises/A+ implementation",
|
||
|
"main": "index.js",
|
||
|
"scripts": {
|
||
|
"test": "mocha -R spec --timeout 200 --slow 99999",
|
||
|
"test-resolve": "mocha test/resolver-tests.js -R spec --timeout 200 --slow 999999",
|
||
|
"test-extensions": "mocha test/extensions-tests.js -R spec --timeout 200 --slow 999999"
|
||
|
},
|
||
|
"repository": {
|
||
|
"type": "git",
|
||
|
"url": "https://github.com/then/promise.git"
|
||
|
},
|
||
|
"author": {
|
||
|
"name": "ForbesLindesay"
|
||
|
},
|
||
|
"license": "MIT",
|
||
|
"devDependencies": {
|
||
|
"promises-aplus-tests": "*",
|
||
|
"better-assert": "*",
|
||
|
"mocha": "*"
|
||
|
},
|
||
|
"dependencies": {
|
||
|
"asap": "~1.0.0"
|
||
|
},
|
||
|
"readme": "<a href=\"http://promises-aplus.github.com/promises-spec\"><img src=\"http://promises-aplus.github.com/promises-spec/assets/logo-small.png\" align=\"right\" /></a>\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[![Build Status](https://travis-ci.org/then/promise.png)](https://travis-ci.org/then/promise)\n[![Dependency Status](https://gemnasium.com/then/promise.png)](https://gemnasium.com/then/promise)\n[![NPM version](https://badge.fury.io/js/promise.png)](http://badge.fury.io/js/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 pollyfill.\n\n```html\n<script src=\"https://www.promisejs.org/polyfills/promise-4.0.0.js\"></script>\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). 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\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.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. Otherwise it returns a promise for an array that conatins its arguments, except with promises replaced by their resolution values. e.g.\n\n```js\nPromise.all([Promise.from('a'), 'b', Promise.from('c')])\n .then(function (res) {\n assert(res[0] === 'a')\n assert(res[1] === 'b')\n assert(res[2] === 'c')\n })\n\nPromise.all(Promise.from('a'), 'b', Promise.from('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
|
||
|
"readmeFilename": "Readme.md",
|
||
|
"bugs": {
|
||
|
"url": "https://github.com/then/promise/issues"
|
||
|
},
|
||
|
"_id": "promise@5.0.0",
|
||
|
"dist": {
|
||
|
"shasum": "da04456fbe2c05cc6bca0aafc42df1c4802026b3"
|
||
|
},
|
||
|
"_from": "promise@",
|
||
|
"_resolved": "https://registry.npmjs.org/promise/-/promise-5.0.0.tgz"
|
||
|
}
|