{"_id":"promto","_rev":"300385","name":"promto","description":"Create a promise with a timeout.","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"zvr","email":""}],"time":{"modified":"2024-01-31T16:08:28.000Z","created":"2017-05-14T22:21:29.294Z","1.2.0":"2019-11-24T22:20:17.354Z","1.1.2":"2019-05-01T15:50:56.084Z","1.1.1":"2019-04-29T19:28:17.006Z","1.1.0":"2019-04-29T19:22:37.805Z","1.0.1":"2017-05-14T22:35:07.517Z","1.0.0":"2017-05-14T22:21:29.294Z"},"users":{},"author":{"name":"Anton","email":"anton@adc.sh"},"repository":{"type":"git","url":"git://github.com/artdecocode/promto.git"},"versions":{"1.2.0":{"name":"promto","version":"1.2.0","description":"Create a promise with a timeout.","main":"build/index.js","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","spec":"yarn t test/spec","mask":"yarn t test/mask","test-build":"ALAMODE_ENV=test-build yarn test","lint":"eslint .","doc":"NODE_DEBUG=doc doc -o README.md","b":"alamode src -o build -s","d":"yarn-s d1","d1":"typal src/index.js -c","externs":"typal externs.js -e","build":"yarn-s d b doc","e":"alanode","example/":"yarn e example/example.js"},"repository":{"type":"git","url":"git://github.com/artdecocode/promto.git"},"keywords":["promise","timeout","async"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/Sobesednik/promto/issues"},"homepage":"https://github.com/Sobesednik/promto#readme","devDependencies":{"alamode":"^3.2.0","documentary":"^1.34.1","zoroaster":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2019 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"promto@1.2.0","dist":{"shasum":"fab897b6435a1386cf20eba0c133cdd878c6706a","size":3181,"noattachment":false,"key":"/promto/-/promto-1.2.0.tgz","tarball":"http://name.csiicloud.com:7001/promto/download/promto-1.2.0.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promto_1.2.0_1574634017183_0.7231827303730374"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:17:07.941Z","publish_time":1574634017354,"_cnpm_publish_time":1574634017354},"1.1.2":{"name":"promto","version":"1.1.2","description":"Create a promise with a timeout.","main":"build/index.js","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","spec":"yarn t test/spec","mask":"yarn t test/mask","test-build":"ALAMODE_ENV=test-build yarn test","lint":"eslint .","doc":"NODE_DEBUG=doc doc -o README.md","b":"alamode src -o build -s","d":"yarn-s d1","d1":"typal src/index.js -c","externs":"typal externs.js -e","build":"yarn-s d b doc","e":"alanode","example/":"yarn e example/example.js"},"repository":{"type":"git","url":"git://github.com/artdecocode/promto.git"},"keywords":["promise","timeout","async"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/Sobesednik/promto/issues"},"homepage":"https://github.com/Sobesednik/promto#readme","devDependencies":{"alamode":"^2.0.0","documentary":"^1.26.2","zoroaster":"^3.13.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"promto@1.1.2","dist":{"shasum":"cf45f80c3140004069060bb709c8130175eed387","size":3055,"noattachment":false,"key":"/promto/-/promto-1.1.2.tgz","tarball":"http://name.csiicloud.com:7001/promto/download/promto-1.1.2.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promto_1.1.2_1556725855972_0.5367264321425094"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:17:07.058Z","publish_time":1556725856084,"_cnpm_publish_time":1556725856084},"1.1.1":{"name":"promto","version":"1.1.1","description":"Create a promise with a timeout.","main":"build/index.js","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","spec":"yarn t test/spec","mask":"yarn t test/mask","test-build":"ALAMODE_ENV=test-build yarn test","lint":"eslint .","doc":"NODE_DEBUG=doc doc -o README.md","b":"alamode src -o build -s","d":"yarn-s d1","d1":"typal src/index.js -c","externs":"typal externs.js -e","build":"yarn-s d b doc","e":"alanode","example/":"yarn e example/example.js"},"repository":{"type":"git","url":"git://github.com/artdecocode/promto.git"},"keywords":["promise","timeout","async"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/Sobesednik/promto/issues"},"homepage":"https://github.com/Sobesednik/promto#readme","devDependencies":{"alamode":"^2.0.0","documentary":"^1.26.2","zoroaster":"^3.13.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"promto@1.1.1","dist":{"shasum":"b5079e7c2ae5d1d356f84846d4b97b0d3b5002f2","size":3000,"noattachment":false,"key":"/promto/-/promto-1.1.1.tgz","tarball":"http://name.csiicloud.com:7001/promto/download/promto-1.1.1.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promto_1.1.1_1556566096870_0.0884579667827865"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:17:06.194Z","publish_time":1556566097006,"_cnpm_publish_time":1556566097006},"1.1.0":{"name":"promto","version":"1.1.0","description":"Create a promise with a timeout.","build":"build/index.js","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","spec":"yarn t test/spec","mask":"yarn t test/mask","test-build":"ALAMODE_ENV=test-build yarn test","lint":"eslint .","doc":"NODE_DEBUG=doc doc -o README.md","b":"alamode src -o build -s","d":"yarn-s d1","d1":"typal src/index.js -c","externs":"typal externs.js -e","build":"yarn-s d b doc","e":"alanode","example/":"yarn e example/example.js"},"repository":{"type":"git","url":"git://github.com/artdecocode/promto.git"},"keywords":["promise","timeout","async"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/Sobesednik/promto/issues"},"homepage":"https://github.com/Sobesednik/promto#readme","devDependencies":{"alamode":"^2.0.0","documentary":"^1.26.2","zoroaster":"^3.13.0"},"licenseText":"MIT License\n\nCopyright (c) 2019 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"promto@1.1.0","dist":{"shasum":"99d4bca6c22b7be463342858d7afb7af610d1dd1","size":2891,"noattachment":false,"key":"/promto/-/promto-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/promto/download/promto-1.1.0.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promto_1.1.0_1556565757637_0.34924489123182934"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:17:05.312Z","publish_time":1556565757805,"_cnpm_publish_time":1556565757805},"1.0.1":{"name":"promto","version":"1.0.1","description":"Create a promise with timeout","main":"src/index.js","scripts":{"test":"zoroaster test/spec"},"repository":{"type":"git","url":"git+https://github.com/Sobesednik/promto.git"},"keywords":["promise","timeout"],"author":{"name":"Anton","email":"anton@sobesednik.media"},"license":"MIT","bugs":{"url":"https://github.com/Sobesednik/promto/issues"},"homepage":"https://github.com/Sobesednik/promto#readme","devDependencies":{"zoroaster":"^0.4.3"},"gitHead":"0ddf7707140e086283d81ae30e46b3f7ea90fbbe","_id":"promto@1.0.1","_shasum":"0a169fc7bd8f48cef1ee9faeace61a100305a536","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.9.0","_npmUser":{"name":"zvr","email":"anton@sobesednik.media"},"dist":{"shasum":"0a169fc7bd8f48cef1ee9faeace61a100305a536","size":3218,"noattachment":false,"key":"/promto/-/promto-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/promto/download/promto-1.0.1.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/promto-1.0.1.tgz_1494801306910_0.9307916855905205"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T19:17:04.411Z","publish_time":1494801307517,"_cnpm_publish_time":1494801307517},"1.0.0":{"name":"promto","version":"1.0.0","description":"Create a promise with timeout","main":"src/index.js","scripts":{"test":"zoroaster test/spec"},"repository":{"type":"git","url":"git+https://github.com/Sobesednik/promto.git"},"keywords":["promise","timeout"],"author":{"name":"Anton","email":"anton@sobesednik.media"},"license":"MIT","bugs":{"url":"https://github.com/Sobesednik/promto/issues"},"homepage":"https://github.com/Sobesednik/promto#readme","devDependencies":{"zoroaster":"^0.4.3"},"gitHead":"092a27195917593b624d60e42e007fe72338f0f7","_id":"promto@1.0.0","_shasum":"feb7aa5b24185ab7c4a26f9674776429a7196fba","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.9.0","_npmUser":{"name":"zvr","email":"anton@sobesednik.media"},"dist":{"shasum":"feb7aa5b24185ab7c4a26f9674776429a7196fba","size":3250,"noattachment":false,"key":"/promto/-/promto-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/promto/download/promto-1.0.0.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/promto-1.0.0.tgz_1494800487412_0.9837807023432106"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T19:17:03.537Z","publish_time":1494800489294,"_cnpm_publish_time":1494800489294}},"readme":"# promto\n\n[![npm version](https://badge.fury.io/js/promto.svg)](https://www.npmjs.com/package/promto)\n\n`promto` Wrappes A Promise In Timeout.\n\n```sh\nyarn add promto\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [`async promto(promise: Promise, timeout: number, description: string?): Promise`](#async-promtopromise-promisetimeout-numberdescription-string-promise)\n- [Copyright](#copyright)\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/0.svg?sanitize=true\">\n</a></p>\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport promto from 'promto'\n```\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/1.svg?sanitize=true\">\n</a></p>\n\n## <code>async <ins>promto</ins>(</code><sub><br/>&nbsp;&nbsp;`promise: Promise,`<br/>&nbsp;&nbsp;`timeout: number,`<br/>&nbsp;&nbsp;`description: string?,`<br/></sub><code>): <i>Promise</i></code>\n\nCreates a new promise which will be rejected upon timeout (after N milliseconds). It will be resolved with the promise value or rejected with the promise error when not timed out.\n\n```js\nimport promto from 'promto'\n\n/**\n * @param {number} timeout\n * @param {string|Error} result\n */\nconst makePromise = async (timeout, result) => {\n  await new Promise((resolve) => {\n    setTimeout(resolve, timeout || 200)\n  })\n  if (result instanceof Error) throw result\n  return result\n}\n\n(async () => {\n  // ok\n  const res = await promto(makePromise(50, 'hello'), 100)\n  console.log(res)\n  // rejected timeout\n  try {\n    await promto(makePromise(150, 'world'), 100)\n  } catch (err) {\n    console.log(err.message)\n  }\n  // rejected timeout with description\n  try {\n    await promto(makePromise(150, 'world'), 100, 'Example')\n  } catch (err) {\n    console.log(err.message)\n  }\n  // rejected promise\n  try {\n    await promto(makePromise(50, new Error('Error in promise')), 100)\n  } catch (err) {\n    console.log(err.message)\n  }\n})()\n```\n```\nhello\nPromise has timed out after 100ms\nExample has timed out after 100ms\nError in promise\n```\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/2.svg?sanitize=true\">\n</a></p>\n\n## Copyright\n\n<table>\n  <tr>\n    <th>\n      <a href=\"https://artd.eco\">\n        <img width=\"100\" src=\"https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png\"\n          alt=\"Art Deco\">\n      </a>\n    </th>\n    <th>© <a href=\"https://artd.eco\">Art Deco</a>   2019</th>\n    <th>\n      <a href=\"https://www.technation.sucks\" title=\"Tech Nation Visa\">\n        <img width=\"100\" src=\"https://raw.githubusercontent.com/idiocc/cookies/master/wiki/arch4.jpg\"\n          alt=\"Tech Nation Visa\">\n      </a>\n    </th>\n    <th><a href=\"https://www.technation.sucks\">Tech Nation Visa Sucks</a></th>\n  </tr>\n</table>\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/-1.svg?sanitize=true\">\n</a></p>","_attachments":{},"homepage":"https://github.com/Sobesednik/promto#readme","bugs":{"url":"https://github.com/Sobesednik/promto/issues"},"license":"MIT"}