{"name":"promiscuous","version":"0.3.0","description":"A minimal and fast promise/deferred implementation","author":{"name":"Ruben Verborgh","email":"ruben.verborgh@gmail.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/RubenVerborgh/promiscuous.git"},"bugs":{"url":"https://github.com/RubenVerborgh/promiscuous/issues"},"main":"promiscuous.js","scripts":{"test":"promises-aplus-tests test/adapter"},"devDependencies":{"promises-aplus-tests":"*","uglify-js":"2.2.x"},"_id":"promiscuous@0.3.0","dist":{"shasum":"47c31b5ecdb93aea01b291c5d6c6bbe3272b83ac","tarball":"http://registry-npm.ywwl.com/promiscuous/download/promiscuous-0.3.0.tgz","integrity":"sha512-8LAYeSpQjVuAi+K5zdRz6rNH2hh2apuFMso1iWDg8X+D46SUu9KCq8Ts70YN4RtoZwclkVeKBnzxtaMIj8j0sA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDTYCN4vUSQaSS8hwY4CiK+14pgzj38hXV3VqBU9yzQ2AIhAN4uKE+p9xjRpyHsWLmo0/RmzG2Z0Oj065EoeWFisbYc"}],"size":3160,"noattachment":false,"key":"/promiscuous/-/promiscuous-0.3.0.tgz"},"_npmVersion":"1.1.62","_npmUser":{"name":"rubenverborgh","email":"ruben.verborgh@gmail.com"},"maintainers":[{"name":"rubenverborgh","email":"ruben.verborgh@gmail.com"}],"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","readme":"# promiscuous\n<a href=\"http://promises-aplus.github.com/promises-spec\">\n  <img src=\"http://promises-aplus.github.com/promises-spec/assets/logo-small.png\"\n       alt=\"Promises/A+ logo\" title=\"Promises/A+ 1.0 compliant\" align=\"right\" />\n</a>\n\npromiscuous is a tiny implementation of the [Promises/A+ spec](http://promises-aplus.github.com/promises-spec/).\n\nIt is promise library in JavaScript, **small** (< 1kb [minified](https://raw.github.com/RubenVerborgh/promiscuous/dist/promiscuous-node.js) / < 0.6kb gzipped) and **fast**.\n\n## Installation and usage\n### Node\nFirst, install promiscuous with npm.\n```bash\n$ npm install promiscuous\n```\n\nThen, include promiscuous in your code file.\n```javascript\nvar Promise = require('promiscuous');\n```\n\n### Browsers\nInclude [promiscuous](https://raw.github.com/RubenVerborgh/promiscuous/dist/promiscuous-browser.js) in your HTML file.\n```html\n<script src=\"promiscuous-browser.js\"></script>\n```\n\nThis version (and a minified one) can be built with:\n```bash\n$ build/build.js\n```\n\n## API\n### Create a resolved promise\n```javascript\nvar promise = Promise.resolve(\"one\");\npromise.then(function (value) { console.log(value); });\n/* one */\n```\n\n### Create a rejected promise\n```javascript\nvar brokenPromise = Promise.reject(new Error(\"Could not keep promise.\"));\nbrokenPromise.then(null, function (error) { console.error(error.message); });\n/* \"Could not keep promise.\" */\n```\n\nYou can also use the `catch` method if there is no success callback:\n\n```javascript\nbrokenPromise.catch(function (error) { console.error(error.message); });\n/* \"Could not keep promise.\" */\n```\n\n### Write a function that returns a promise\n```javascript\nfunction promiseLater(something) {\n  return new Promise(function (resolve, reject) {\n    setTimeout(function () {\n      if (something)\n        resolve(something);\n      else\n        reject(new Error(\"nothing\"));\n    }, 1000);\n  });\n}\npromiseLater(\"something\").then(\n  function (value) { console.log(value); },\n  function (error) { console.error(error.message); });\n/* something */\n\npromiseLater(null).then(\n  function (value) { console.log(value); },\n  function (error) { console.error(error.message); });\n/* nothing */\n```\n\n### Convert an array of promises into a promise for an array\n```javascript\nvar promises = [promiseLater(1), promiseLater(2), promiseLater(3)];\nPromise.all(promises).then(function (values) { console.log(values); });\n/* [1, 2, 3] */\n```\n","publish_time":1375433320667,"_cnpm_publish_time":1375433320667,"dist-tags":{"latest":"0.7.2"}}