{"_id":"promise.coffee","_rev":"27-83c64e73bab4c3535420c035a5f17f5f","name":"promise.coffee","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.0":{"name":"promise.coffee","version":"1.0.0","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","keywords":["promise","promises","async","asynchronous","deferred"],"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"main":"./promise.js","devDependencies":{"coffee-script":">= 1.4.0","promises-aplus-tests":"","jshint":">= 0.9.1"},"scripts":{"test":"promises-aplus-tests test/promise_coffee-adapter.js","lint":"jshint promise.js"},"_id":"promise.coffee@1.0.0","dist":{"shasum":"06a4d3f6366fa2279e059101e6c01be66fcbf0fe","tarball":"https://registry.npmjs.org/promise.coffee/-/promise.coffee-1.0.0.tgz","integrity":"sha512-rqekDXb1yS67o3UAXtR8lLogpnDEsWbpceFJJ6i6uPHQ1IjJJlQtD9skWf4Qdr0aB/fDilSx+0w3vO+2rj1/Sw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCodcfEOcDuJA97Z583EIsg2tvTi/UB1jshcSGL8xUXfQIgKJCtvkRjQUM20o5uvVbCZ+2bTOjbp7DMFFwVBJTCYOw="}]},"_npmVersion":"1.1.69","_npmUser":{"name":"codecatalyst","email":"jmy@codecatalyst.com"},"maintainers":[{"name":"codecatalyst","email":"jmy@codecatalyst.com"}],"directories":{}},"1.0.1":{"name":"promise.coffee","version":"1.0.1","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","keywords":["promise","promises","async","asynchronous","deferred"],"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"main":"./promise.js","devDependencies":{"coffee-script":">= 1.4.0","promises-aplus-tests":"","jshint":">= 0.9.1"},"scripts":{"test":"promises-aplus-tests test/promise_coffee-adapter.js","lint":"jshint promise.js"},"_id":"promise.coffee@1.0.1","dist":{"shasum":"34e3b42c1eb431b0ee0fe0a13697a0a3bf58b505","tarball":"https://registry.npmjs.org/promise.coffee/-/promise.coffee-1.0.1.tgz","integrity":"sha512-nCsUKa5rRFRWphfb9I2MgaodayrC9CMwwUDHcutoz7PA7WB4RRJGPyj5jQvQfeaFgOriyVcm9+Y1wMbgTayiNA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD+q255IIqg7Sq+XlCW9rwb9xIdpv0sg1z4FC4f/SuwuwIhAIcUFbc16DWR0HNha7s12v40WL79V3jdOOcv+M/Dds7l"}]},"_resolved":"git://github.com/CodeCatalyst/promise.coffee.git#4cce552ebcca6f4b17b45b979b84893974653b43","_npmVersion":"1.2.2","_npmUser":{"name":"codecatalyst","email":"jmy@codecatalyst.com"},"maintainers":[{"name":"codecatalyst","email":"jmy@codecatalyst.com"}]},"1.0.2":{"name":"promise.coffee","version":"1.0.2","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","keywords":["promise","promises","promises-aplus","async","asynchronous","deferred"],"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"main":"./promise.js","devDependencies":{"coffee-script":">= 1.6.3","promises-aplus-tests":"*","jshint":"~1"},"scripts":{"test":"promises-aplus-tests test/promise_coffee-adapter.js","lint":"jshint promise.js"},"_id":"promise.coffee@1.0.2","dist":{"shasum":"2b2f2ecc173fa3a88012a00a71bf1b25b47ea9b9","tarball":"https://registry.npmjs.org/promise.coffee/-/promise.coffee-1.0.2.tgz","integrity":"sha512-7m2b0BaI7n92sDWrGPh/9By0JRqIy2Omp/wxnbM7mWyUE0yKUMYwB+ovamUNUMisBVun/nmYw4UADATmUludCA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSUDJGjhfIj2rk0yV6gDrZ6Vnyn1BgPwlfxk/N9nVBYAIhAP5177nh6ZkbvL42LFsM2xNs3YZr/CG7BEjQQusuXoql"}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"codecatalyst","email":"jmy@codecatalyst.com"},"maintainers":[{"name":"codecatalyst","email":"jmy@codecatalyst.com"}]},"1.0.3":{"name":"promise.coffee","version":"1.0.3","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","keywords":["promise","promises","promises-aplus","async","asynchronous","deferred"],"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"main":"./promise.js","devDependencies":{"coffee-script":">= 1.6.3","promises-aplus-tests":"*","jshint":"~1"},"scripts":{"test":"promises-aplus-tests test/promise_coffee-adapter.js","lint":"jshint promise.js"},"_id":"promise.coffee@1.0.3","dist":{"shasum":"24d672928b735bf23f567667888176a7a2a3190e","tarball":"https://registry.npmjs.org/promise.coffee/-/promise.coffee-1.0.3.tgz","integrity":"sha512-Zbl0RBH8usQ6Vh40bp2OLWoLnQadgvFnQpSScg9JAxI/wmXJIDz5dFKtLEOSzzwAEHMgOCeBFq/NRZ6ls2K/QA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDv+Wxf+a488RTuOcBScIxwwzeuHS0q76VwD4hnDeVJlwIgPgupG8keomh/wLwOhyP/5ypFIDJt4AlD7NZyR2rkjOE="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"codecatalyst","email":"jmy@codecatalyst.com"},"maintainers":[{"name":"codecatalyst","email":"jmy@codecatalyst.com"}]},"1.0.4":{"name":"promise.coffee","version":"1.0.4","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","keywords":["promise","promises","promises-aplus","async","asynchronous","deferred"],"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"main":"./promise.js","devDependencies":{"coffee-script":">= 1.6.3","promises-aplus-tests":"*","jshint":"~1"},"scripts":{"test":"promises-aplus-tests test/promise_coffee-adapter.js","lint":"jshint promise.js"},"_id":"promise.coffee@1.0.4","dist":{"shasum":"bd5fc17ca692782b1a0eaaad064396183dc023f5","tarball":"https://registry.npmjs.org/promise.coffee/-/promise.coffee-1.0.4.tgz","integrity":"sha512-KNy36UaOktDTMvJQssHM8Pl8soGBLSVSZ8YbptFi0KUx5dumLJmw7GZfumsQB1dGk0r9Pu5A9An7ZsJ7ayiAvw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDE9lcIAFvmQHZGjWd302HVbU/Tr3BhFQqVIcSifZcLSQIhALkNatfRhXk5XrZHcO4UE4j0GUEokHYfJthJ7ULtrnhr"}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"codecatalyst","email":"jmy@codecatalyst.com"},"maintainers":[{"name":"codecatalyst","email":"jmy@codecatalyst.com"}]},"1.0.5":{"name":"promise.coffee","version":"1.0.5","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","keywords":["promise","promises","promises-aplus","async","asynchronous","deferred"],"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"main":"./promise.js","devDependencies":{"coffee-script":">= 1.6.3","promises-aplus-tests":"*","jshint":"~1"},"scripts":{"test":"promises-aplus-tests test/promise_coffee-adapter.js","lint":"jshint promise.js"},"_id":"promise.coffee@1.0.5","dist":{"shasum":"2f7858d669b3701d7b21be83597607c4d6cd2db0","tarball":"https://registry.npmjs.org/promise.coffee/-/promise.coffee-1.0.5.tgz","integrity":"sha512-cH3iQqDM7Uq4SfxgP6ytqqCEB4Vzp6cD8rS96Io5ciaF3T7pi8+t2eAkNXpsuW/F1gHFIAAl/vP4VnpTA/ESMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCV9QKLIQd/8CkhkOW8EEt79+c35CnleW8fUtw5HHht8wIgDDx/o04qdKbRbW8um6JChlnUwVgbOA32jjeD61Ap1Gs="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"codecatalyst","email":"jmy@codecatalyst.com"},"maintainers":[{"name":"codecatalyst","email":"jmy@codecatalyst.com"}]},"1.0.6":{"name":"promise.coffee","version":"1.0.6","description":"Promises/A+ compliant implementation in object-oriented CoffeeScript","keywords":["promise","promises","promises-aplus","async","asynchronous","deferred"],"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"main":"./promise.js","devDependencies":{"coffee-script":">= 1.6.3","promises-aplus-tests":"*","jshint":"~1"},"scripts":{"test":"promises-aplus-tests test/promise_coffee-adapter.js","lint":"jshint promise.js"},"_id":"promise.coffee@1.0.6","dist":{"shasum":"ff370a0a2a80211f6a863f1c528609eb75dc7101","tarball":"https://registry.npmjs.org/promise.coffee/-/promise.coffee-1.0.6.tgz","integrity":"sha512-CTkc9EeuN8CIVOYk7H3lVAMiU8qUEfLHHpri7hzPe4p9hZGTeUKxuDkAZJ7dkk2aG1JFiLT6EOKCWynWLJipqg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAt1mo10U/LLnjyJxcZ9jRAiI++4TwVIjfe3D5/k2jqsAiEA8N62YZfN096qSVlKcdN+HFiahX57i5v+kCNDvtR3MtM="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"codecatalyst","email":"jmy@codecatalyst.com"},"maintainers":[{"name":"codecatalyst","email":"jmy@codecatalyst.com"}]}},"readme":"<img src=\"https://raw.github.com/CodeCatalyst/promise.coffee/master/promise_coffee-logo.png\" width=\"580\" height=\"115\">\n<a href=\"http://promisesaplus.com/\"><img src=\"http://promisesaplus.com/assets/logo-small.png\" alt=\"Promises/A+ logo\" title=\"Promises/A+ 1.1 compliant\" align=\"right\" /></a>\n\n[![Build Status](https://travis-ci.org/CodeCatalyst/promise.coffee.png?branch=master)](https://travis-ci.org/CodeCatalyst/promise.coffee)\n\n## About\n\npromise.coffee is an ultra-lean (~100 lines) object-oriented [CoffeeScript](http://coffeescript.org/) implementation of the [Promises/A+ Specification](https://github.com/promises-aplus/promises-spec) that passes the [Promises/A+ Compliance Test Suite](https://github.com/promises-aplus/promises-tests).\n\nInspired by [avow.js](https://github.com/briancavalier/avow), promise.coffee differs by providing a reference implementation that decomposes Promise/A+ functionality into object-oriented classes.  The approach demonstrated here offers a model for how Promises might be implemented in stricter class oriented languages.\n\nIt is fully asynchronous, ensuring that the `onFulfilled` and `onRejected` callbacks are not executed in the same turn of the event loop as the call to `then()` with which they were registered.  To schedule execution of these callbacks, it uses `process.nextTick()` or `setImmediate()` if available (see [NobleJS's setImmediate() polyfill](https://github.com/NobleJS/setImmediate)) and will otherwise fall back to `setTimeout()`.\n\nIt supports foreign promises returned by callbacks as long as they support the standard Promise `then()` method signature.\n\n## API\n\nCreate a deferred:\n\n\tvar deferred = new Deferred();\n\nResolve that deferred:\n\t\n\tdeferred.resolve( value );\n\nOr, reject that deferred:\n\n\tdeferred.reject( reason );\n\nObtain the promise linked to that deferred to pass to external consumers:\n\n\tvar promise = deferred.promise;\n\nAdd (optional) handlers to that promise:\n\n\tpromise.then( onFulfilled, onRejected );\n\n## Installation\n\n### Node.js\n\nDownload, clone or:\n\n\tnpm install promise.coffee\n\t\nand then:\n\n\tvar Deferred = require( 'promise.coffee' ).Deferred;\n\n### AMD:\n\nAssuming you have configured your loader to map the promise.coffee files to the 'promise' module identifier.\n\n\tdefine( function ( require, exports, module ) {\n\t\tvar Deferred = require( 'promise' ).Deferred;\n\t\t\n\t\t...\n\t});\n\n### &lt;script&gt; tag:\n\nReference the appropriate script file from your HTML file:\n\n\t<script src=\"promise.js\"></script>\n\nor, for the minified version of the script:\n\n\t<script src=\"promise.min.js\"></script>\n\n\nor, in the unlikely case you are using the browser-based CoffeeScript compiler:\n\n\t<script type=\"text/coffeescript\" src=\"promise.coffee\"></script>\n\n## Internal Anatomy\n\nThis implementation decomposes Promise functionality into four classes:\n\n### Promise\n\nPromises represent a future value; i.e., a value that may not yet be available.\n\nA Promise's `then()` method is used to specify `onFulfilled` and `onRejected` callbacks that will be notified when the future value becomes available.  Those callbacks can subsequently transform the value that was fulfilled or the reason that was rejected.  Each call to `then()` returns a new Promise of that transformed value; i.e., a Promise that is fulfilled with the callback return value or rejected with any error thrown by the callback.\n\n### Deferred\n\nA Deferred is typically used within the body of a function that performs an asynchronous operation.  When that operation succeeds, the Deferred should be resolved; if that operation fails, the Deferred should be rejected.\n\nA Deferred is resolved by calling its `resolve()` method with an optional value, and is rejected by calling its `reject()` method with an optional reason.  Once a Deferred has been fulfilled or rejected, it is considered to be complete and subsequent calls to `resolve()` or `reject()` are ignored.\n\nDeferreds are the mechanism used to create new Promises.  A Deferred has a single associated Promise that can be safely returned to external consumers to ensure they do not interfere with the resolution or rejection of the deferred operation.\n\n### Resolver\n\nResolvers are used internally by Deferreds to create, resolve and reject Promises, and to propagate fulfillment and rejection.\n\nDevelopers never directly interact with a Resolver.\n\nEach Deferred has an associated Resolver, and each Resolver has an associated Promise.  A Deferred delegates `resolve()` and `reject()` calls to its Resolver's `resolve()` and `reject()` methods.  A Promise delegates `then()` calls to its Resolver's `then()` method.  In this way, access to Resolver operations are divided between producer (Deferred) and consumer (Promise) roles.\n\nWhen a Resolver's `resolve()` method is called, it fulfills with the optionally specified value.  If `resolve()` is called with a then-able (i.e. a Function or Object with a `then()` function, such as another Promise) it assimilates the then-able's result; the Resolver provides its own `resolve()` and `reject()` methods as the `onFulfilled` or `onRejected` arguments in a call to that then-able's `then()` function.  If an error is thrown while calling the then-able's `then()` function (prior to any call back to the specified `resolve()` or `reject()` methods), the Resolver rejects with that error.  If a Resolver's `resolve()` method is called with its own Promise, it rejects with a `TypeError`.\n\nWhen a Resolver's `reject()` method is called, it rejects with the optionally specified reason.\n\nEach time a Resolver's `then()` method is called, it captures a pair of optional `onFulfilled` and `onRejected` callbacks and returns a Promise of the Resolver's future value as transformed by those callbacks.\n\n### Consequence\n\nConsequences are used internally by Resolvers to capture and notify callbacks, and propagate their transformed results as fulfillment or rejection.\n\nDevelopers never directly interact with a Consequence.\n\nA Consequence forms a chain between two Resolvers, where the result of the first Resolver is transformed by the corresponding callback before being applied to the second Resolver.\n\nEach time a Resolver's `then()` method is called, it creates a new Consequence that will be triggered once its originating Resolver has been fulfilled or rejected.  A Consequence captures a pair of optional `onFulfilled` and `onRejected` callbacks. \n\nEach Consequence has its own Resolver (which in turn has a Promise) that is resolved or rejected when the Consequence is triggered.  When a Consequence is triggered by its originating Resolver, it calls the corresponding callback and propagates the transformed result to its own Resolver; resolved with the callback return value or rejected with any error thrown by the callback.\n\n## Running the Promises/A+ Test Suite\n\n1. `npm install`\n2. `npm test`\n\n## Reference and Reading\n\n* [Common JS Promises/A Specification](http://wiki.commonjs.org/wiki/Promises/A)\n* [Promises/A+ Specification](https://github.com/promises-aplus/promises-spec)\n* [You're Missing the Point of Promises](https://gist.github.com/3889970)\n\n\n## Acknowledgements\n\n* [Kris Zyp](https://github.com/kriszyp), who proposed the original [Common JS Promises/A Specification](http://wiki.commonjs.org/wiki/Promises/A) and created [node-promise](https://github.com/kriszyp/node-promise) and [promised-io](https://github.com/kriszyp/promised-io),\n* [Domenic Denicola](https://github.com/domenic) for the [Promises/A+ Specification](https://github.com/promises-aplus/promises-spec) and [Promises/A+ Compliance Test Suite](https://github.com/promises-aplus/promises-tests), and for his work with:\n* [Kris Kowal](https://github.com/kriskowal), who created [q](https://github.com/kriskowal/q), a JavaScript promise library that pioneered many of the practices now codified in the [Promises/A+ Specification](https://github.com/promises-aplus/promises-spec),\n* [Brian Cavalier](https://github.com/briancavalier) for his contributions to the [Promises/A+ Specification](https://github.com/promises-aplus/promises-spec) and [Promises/A+ Compliance Test Suite](https://github.com/promises-aplus/promises-tests), and the inspiration that [avow.js](https://github.com/briancavalier/avow) and [when.js](https://github.com/cujojs/when) (with [John Hann](https://github.com/unscriptable)) and [past GitHub issue discussions](https://github.com/cujojs/when/issues/60) have provided; and\n* [Yehor Lvivski](http://lvivski.com/), whose [Davy Jones](https://github.com/lvivski/davy) Promises/A+ implementation and our discussion around optimizing its performance inspired improvements to promise.coffee's implementation; and\n* [Jason Barry](http://dribbble.com/artifactdesign), who designed the promise.coffee logo.\n\n## License\n\nCopyright (c) 2012-2013 [CodeCatalyst, LLC](http://www.codecatalyst.com/)\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n","maintainers":[{"name":"johnyanarella","email":"jmy@codecatalyst.com"}],"time":{"modified":"2022-06-24T19:19:20.350Z","created":"2013-01-29T17:37:00.449Z","1.0.0":"2013-01-29T17:37:01.779Z","1.0.1":"2013-03-06T19:04:42.357Z","1.0.2":"2013-10-09T06:25:32.880Z","1.0.3":"2013-10-10T16:00:40.776Z","1.0.4":"2013-10-15T21:15:56.856Z","1.0.5":"2013-10-28T23:52:18.609Z","1.0.6":"2013-11-07T20:25:28.283Z"},"author":{"name":"John Yanarella","email":"jmy@codecatalyst.com","url":"http://codecatalyst.com"},"repository":{"type":"git","url":"https://github.com/CodeCatalyst/promise.coffee"},"users":{"elidiazgt":true},"keywords":["promise","promises","promises-aplus","async","asynchronous","deferred"],"bugs":{"url":"http://github.com/CodeCatalyst/promise.coffee/issues"},"license":"MIT","readmeFilename":"README.md"}