{"id":15365601,"url":"https://github.com/tunnckocore/dush-promise","last_synced_at":"2026-02-13T10:08:55.101Z","repository":{"id":48000595,"uuid":"86889718","full_name":"tunnckoCore/dush-promise","owner":"tunnckoCore","description":"Plugin for `dush` that makes it a Deferred promise and adds `.resolve`, `.reject`, `.than` and `.catch` methods for more better error handling experience","archived":false,"fork":false,"pushed_at":"2023-01-12T05:39:53.000Z","size":500,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-24T06:36:39.949Z","etag":null,"topics":["baseplugin","deferred","deferred-promise","dush","dushplugin","minibaseplugin","promise"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tunnckoCore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-01T06:26:52.000Z","updated_at":"2024-10-04T10:38:59.000Z","dependencies_parsed_at":"2023-02-09T10:16:02.097Z","dependency_job_id":null,"html_url":"https://github.com/tunnckoCore/dush-promise","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tunnckoCore/dush-promise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fdush-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fdush-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fdush-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fdush-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tunnckoCore","download_url":"https://codeload.github.com/tunnckoCore/dush-promise/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fdush-promise/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29401233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["baseplugin","deferred","deferred-promise","dush","dushplugin","minibaseplugin","promise"],"created_at":"2024-10-01T13:15:12.519Z","updated_at":"2026-02-13T10:08:55.075Z","avatar_url":"https://github.com/tunnckoCore.png","language":"JavaScript","funding_links":["https://www.paypal.me/tunnckoCore"],"categories":[],"sub_categories":[],"readme":"# dush-promise [![npm version][npmv-img]][npmv-url] [![github tags][ghtag-img]][ghtag-url] [![mit license][license-img]][license-url]\n\n\u003e Plugin for `dush` that makes it a Deferred promise and adds `.resolve`, `.reject`, `.than` and `.catch` methods for more better error handling experience\n\nYou might also be interested in [dush](https://github.com/tunnckocore/dush#readme).\n\n## Quality 👌\n\n\u003e By using [commitizen][czfriendly-url] and [conventional commit messages][conventional-messages-url], \nmaintaining meaningful [ChangeLog][changelogmd-url] \nand commit history based on [global conventions][conventions-url], \nfollowing [StandardJS][standard-url] code style through [ESLint][eslint-url] and\nhaving always up-to-date dependencies through integrations\nlike [GreenKeeper][gk-integration-url] and [David-DM][daviddm-url] service,\nthis package has top quality.\n\n[![code climate][codeclimate-img]][codeclimate-url] \n[![code style][standard-img]][standard-url] \n[![commitizen friendly][czfriendly-img]][czfriendly-url] \n[![greenkeeper friendly][gkfriendly-img]][gkfriendly-url] \n[![dependencies][daviddm-deps-img]][daviddm-deps-url] \n\u003c!-- uncomment when need --\u003e\n\u003c!-- [![develop deps][daviddm-devdeps-img]][daviddm-devdeps-url] --\u003e\n\n## Stability 💯\n\n\u003e By following [Semantic Versioning][semver-url] through [standard-version][] releasing tool, \nthis package is very stable and its tests are passing both on [Windows (AppVeyor)][appveyor-ci-url] \nand [Linux (CircleCI)][circle-ci-url] with results \nfrom 100% to [400%][absolute-coverage-url] test coverage, reported respectively\nby [CodeCov][codecov-coverage-url] and [nyc (istanbul)][nyc-istanbul-url].\n\n[![following semver][following-semver-img]][following-semver-url] \n[![semantic releases][strelease-img]][strelease-url] \n[![linux build][circle-img]][circle-url] \n[![windows build][appveyor-img]][appveyor-url] \n[![code coverage][codecov-img]][codecov-url] \n[![nyc coverage][istanbulcov-img]][istanbulcov-url] \n\n## Support :clap:\n\n\u003e If you have any problems, consider opening [an issue][open-issue-url],\nping me on twitter ([@tunnckoCore][tunnckocore-twitter-url]),\njoin the [support chat][supportchat-url] room\nor queue a [live session][codementor-url] on CodeMentor with me.\nIf you don't have any problems, you're using it somewhere or\nyou just enjoy this product, then please consider [donating some cash][paypalme-url] at PayPal,\nsince this is [OPEN Open Source][opensource-project-url] project made\nwith love at [Sofia, Bulgaria][bulgaria-url] 🇧🇬.\n\n[![tunnckoCore support][supportchat-img]][supportchat-url] \n[![code mentor][codementor-img]][codementor-url] \n[![paypal donate][paypalme-img]][paypalme-url] \n[![NPM monthly downloads](https://img.shields.io/npm/dm/dush-promise.svg?style=flat)](https://npmjs.org/package/dush-promise) \n[![npm total downloads][downloads-img]][downloads-url] \n\n## Table of Contents\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n  * [dushPromise](#dushpromise)\n  * [.then](#then)\n  * [.catch](#catch)\n  * [.resolve](#resolve)\n  * [.reject](#reject)\n- [Related](#related)\n- [Contributing](#contributing)\n- [Building docs](#building-docs)\n- [Running tests](#running-tests)\n- [Author](#author)\n- [License](#license)\n\n_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_\n\n## Install\nInstall with [npm](https://www.npmjs.com/)\n\n```\n$ npm install dush-promise --save\n```\n\nor install using [yarn](https://yarnpkg.com)\n\n```\n$ yarn add dush-promise\n```\n\n## Usage\n\u003e For more use-cases see the [tests](test.js)\n\n```js\nconst dushPromise = require('dush-promise')\n```\n\n## API\n\n### [dushPromise](index.js#L38)\n\u003e Adds a Promise methods such as `.resolve`, `.reject` `.then` and `.catch` to your [dush][] application. Useful from inside plugins. This plugin also emits `error` event when `app.reject` is used.\n\n**Params**\n\n* `opts` **{Object}**: optional, passed directly to [native-promise-deferred][]    \n* `returns` **{Function}**: a plugin function that should be passed to `.use` method of [dush][]  \n\n**Example**\n\n```js\nvar dush = require('dush')\nvar promise = require('dush-promise')\n\nvar app = dush().use(promise())\n\nconsole.log(app.then)\nconsole.log(app.catch)\nconsole.log(app.reject)\nconsole.log(app.resolve)\n```\n\n### [.then](index.js#L68)\n\u003e Handle resolved promise with `onresolved` or rejected promise with `onrejected`. It is as any usual Promise `.then` method.\n\n**Params**\n\n* `onresolved` **{Function}**    \n* `onrejected` **{Function}**    \n* `returns` **{Promise}**  \n\n**Example**\n\n```js\napp.then((res) =\u003e {\n  console.log(res) // =\u003e 123\n})\napp.resolve(123)\n\n// or handle rejected promise\napp.then(null, (er) =\u003e {\n  console.log('err!', er) // =\u003e Error: foo bar\n})\napp.reject(new Error('foo bar'))\n```\n\n### [.catch](index.js#L95)\n\u003e Catch a rejected promise error. This method is mirror of any usual promise `.catch` method.\n\n**Params**\n\n* `onrejected` **{Function}**    \n* `returns` **{Promise}**  \n\n**Example**\n\n```js\napp.on('error', (err) =\u003e {\n  console.log('er!', err) // =\u003e Error: sad err\n})\napp.catch((err) =\u003e {\n  console.log('oops, error!', err) // =\u003e Error: sad err\n})\n\napp.reject(new Error('sad err'))\n```\n\n### [.resolve](index.js#L123)\n\u003e As any usual `Promise.resolve` method.\n\n**Params**\n\n* `val` **{any}**    \n* `returns` **{Promise}**  \n\n**Example**\n\n```js\napp.use((app) =\u003e {\n  app.foo = () =\u003e {\n    return app.resolve(1222)\n  }\n})\n\nconst promise = app.foo()\npromise.then((val) =\u003e {\n  console.log('res:', val) // =\u003e 1222\n})\n```\n\n### [.reject](index.js#L145)\n\u003e As any usual `Promise.reject` method.\n\n**Params**\n\n* `err` **{Error}**    \n* `returns` **{Promise}**  \n\n**Example**\n\n```js\napp.on('error', (err) =\u003e {\n  console.log('some error:', err) // =\u003e Error: quxie\n})\napp.reject(new Error('quxie'))\n```\n\n## Related\n- [dush-methods](https://www.npmjs.com/package/dush-methods): Plugin for `dush` and anything based on it. It adds helper `.define` and `.delegate` methods | [homepage](https://github.com/tunnckocore/dush-methods#readme \"Plugin for `dush` and anything based on it. It adds helper `.define` and `.delegate` methods\")\n- [dush-no-chaining](https://www.npmjs.com/package/dush-no-chaining): A plugin that removes the emitter methods chaining support for `dush`, `base`, `minibase` or anything based on them | [homepage](https://github.com/tunnckocore/dush-no-chaining#readme \"A plugin that removes the emitter methods chaining support for `dush`, `base`, `minibase` or anything based on them\")\n- [dush-options](https://www.npmjs.com/package/dush-options): Adds `.option`, `.enable` and `.disable` methods to your `dush` application | [homepage](https://github.com/tunnckocore/dush-options#readme \"Adds `.option`, `.enable` and `.disable` methods to your `dush` application\")\n- [dush-router](https://www.npmjs.com/package/dush-router): A simple regex-based router for `dush`, `base`, `minibase` and anything based on them. Works on Browser and Node.js | [homepage](https://github.com/tunnckocore/dush-router#readme \"A simple regex-based router for `dush`, `base`, `minibase` and anything based on them. Works on Browser and Node.js\")\n- [dush-tap-report](https://www.npmjs.com/package/dush-tap-report): A simple TAP report producer based on event system. A plugin for `dush` event emitter or anything based on it | [homepage](https://github.com/tunnckocore/dush-tap-report#readme \"A simple TAP report producer based on event system. A plugin for `dush` event emitter or anything based on it\")\n- [dush](https://www.npmjs.com/package/dush): Microscopic \u0026 functional event emitter in ~260 bytes, extensible through plugins. | [homepage](https://github.com/tunnckocore/dush#readme \"Microscopic \u0026 functional event emitter in ~260 bytes, extensible through plugins.\")\n- [minibase-create-plugin](https://www.npmjs.com/package/minibase-create-plugin): Utility for [minibase][] and [base][] that helps you create plugins | [homepage](https://github.com/node-minibase/minibase-create-plugin#readme \"Utility for [minibase][] and [base][] that helps you create plugins\")\n- [minibase](https://www.npmjs.com/package/minibase): Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing… [more](https://github.com/node-minibase/minibase#readme) | [homepage](https://github.com/node-minibase/minibase#readme \"Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing [base][] plugins.\")\n- [native-or-another](https://www.npmjs.com/package/native-or-another): Guaranteed way for getting a Promise. Always native Promise if available, otherwise looks for common promise libraries and loads which… [more](https://github.com/tunnckocore/native-or-another#readme) | [homepage](https://github.com/tunnckocore/native-or-another#readme \"Guaranteed way for getting a Promise. Always native Promise if available, otherwise looks for common promise libraries and loads which is installed. Allows registering custom Promise implementation in node \u003c 0.12 versions\")\n- [native-promise-deferred](https://www.npmjs.com/package/native-promise-deferred): A deferred Promise, using `native-or-another` behind and so it work on Node.js v0.10 too! | [homepage](https://github.com/tunnckocore/native-promise-deferred#readme \"A deferred Promise, using `native-or-another` behind and so it work on Node.js v0.10 too!\")\n- [native-promise](https://www.npmjs.com/package/native-promise): Get native `Promise` or falsey value if not available. | [homepage](https://github.com/tunnckocore/native-promise#readme \"Get native `Promise` or falsey value if not available.\")\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue][open-issue-url].  \nPlease read the [contributing guidelines][contributing-url] for advice on opening issues, pull requests, and coding standards.  \nIf you need some help and can spent some cash, feel free to [contact me at CodeMentor.io][codementor-url] too.\n\n**In short:** If you want to contribute to that project, please follow these things\n\n1. Please DO NOT edit [README.md](README.md), [CHANGELOG.md][changelogmd-url] and [.verb.md](.verb.md) files. See [\"Building docs\"](#building-docs) section.\n2. Ensure anything is okey by installing the dependencies and run the tests. See [\"Running tests\"](#running-tests) section.\n3. Always use `npm run commit` to commit changes instead of `git commit`, because it is interactive and user-friendly. It uses [commitizen][] behind the scenes, which follows Conventional Changelog idealogy.\n4. Do NOT bump the version in package.json. For that we use `npm run release`, which is [standard-version][] and follows Conventional Changelog idealogy.\n\nThanks a lot! :)\n\n## Building docs\nDocumentation and that readme is generated using [verb-generate-readme][], which is a [verb][] generator, so you need to install both of them and then run `verb` command like that\n\n```\n$ npm install verbose/verb#dev verb-generate-readme --global \u0026\u0026 verb\n```\n\n_Please don't edit the README directly. Any changes to the readme must be made in [.verb.md](.verb.md)._\n\n## Running tests\nClone repository and run the following in that cloned directory\n\n```\n$ npm install \u0026\u0026 npm test\n```\n\n## Author\n**Charlike Mike Reagent**\n\n+ [github/tunnckoCore](https://github.com/tunnckoCore)\n+ [twitter/tunnckoCore](https://twitter.com/tunnckoCore)\n+ [codementor/tunnckoCore](https://codementor.io/tunnckoCore)\n\n## License\nCopyright © 2017, [Charlike Mike Reagent](https://i.am.charlike.online). Released under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on April 02, 2017._  \n_Project scaffolded using [charlike][] cli._\n\n[always-done]: https://github.com/hybridables/always-done\n[async-done]: https://github.com/gulpjs/async-done\n[base]: https://github.com/node-base/base\n[charlike]: https://github.com/tunnckocore/charlike\n[commitizen]: https://github.com/commitizen/cz-cli\n[dezalgo]: https://github.com/npm/dezalgo\n[dush]: https://github.com/tunnckocore/dush\n[native-promise-deferred]: https://github.com/tunnckocore/native-promise-deferred\n[once]: https://github.com/isaacs/once\n[standard-version]: https://github.com/conventional-changelog/standard-version\n[type]: https://github.com/Gozala/type\n[verb-generate-readme]: https://github.com/verbose/verb-generate-readme\n[verb]: https://github.com/verbose/verb\n\n[license-url]: https://github.com/tunnckoCore/dush-promise/blob/master/LICENSE\n[license-img]: https://img.shields.io/npm/l/dush-promise.svg\n\n[downloads-url]: https://www.npmjs.com/package/dush-promise\n[downloads-img]: https://img.shields.io/npm/dt/dush-promise.svg\n\n[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/dush-promise\n[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/dush-promise.svg\n\n[circle-url]: https://circleci.com/gh/tunnckoCore/dush-promise\n[circle-img]: https://img.shields.io/circleci/project/github/tunnckoCore/dush-promise/master.svg?label=linux\n\n[appveyor-url]: https://ci.appveyor.com/project/tunnckoCore/dush-promise\n[appveyor-img]: https://img.shields.io/appveyor/ci/tunnckoCore/dush-promise/master.svg?label=windows\n\n[codecov-url]: https://codecov.io/gh/tunnckoCore/dush-promise\n[codecov-img]: https://img.shields.io/codecov/c/github/tunnckoCore/dush-promise/master.svg?label=codecov\n\n[daviddm-deps-url]: https://david-dm.org/tunnckoCore/dush-promise\n[daviddm-deps-img]: https://img.shields.io/david/tunnckoCore/dush-promise.svg\n\n[daviddm-devdeps-url]: https://david-dm.org/tunnckoCore/dush-promise?type=dev\n[daviddm-devdeps-img]: https://img.shields.io/david/dev/tunnckoCore/dush-promise.svg\n\n[ghtag-url]: https://github.com/tunnckoCore/dush-promise/tags\n[ghtag-img]: https://img.shields.io/github/tag/tunnckoCore/dush-promise.svg?label=github%20tag\n\n[npmv-url]: https://www.npmjs.com/package/dush-promise\n[npmv-img]: https://img.shields.io/npm/v/dush-promise.svg?label=npm%20version\n\n[standard-url]: https://github.com/feross/standard\n[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n\n[paypalme-url]: https://www.paypal.me/tunnckoCore\n[paypalme-img]: https://img.shields.io/badge/paypal-donate-brightgreen.svg\n\n[czfriendly-url]: http://commitizen.github.io/cz-cli\n[czfriendly-img]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg\n\n[gkfriendly-url]: https://greenkeeper.io/\n[gkfriendly-img]: https://img.shields.io/badge/greenkeeper-friendly-brightgreen.svg\n\n[codementor-url]: https://www.codementor.io/tunnckocore?utm_source=github\u0026utm_medium=button\u0026utm_term=tunnckocore\u0026utm_campaign=github\n[codementor-img]: https://img.shields.io/badge/code%20mentor-live%20session-brightgreen.svg\n\n[istanbulcov-url]: https://twitter.com/tunnckoCore/status/841768516965568512\n[istanbulcov-img]: https://img.shields.io/badge/istanbul-400%25-brightgreen.svg\n\n[following-semver-url]: http://semver.org\n[following-semver-img]: https://img.shields.io/badge/following-semver-brightgreen.svg\n\n[strelease-url]: https://github.com/conventional-changelog/standard-version\n[strelease-img]: https://img.shields.io/badge/using-standard%20version-brightgreen.svg\n\n[supportchat-url]: https://gitter.im/tunnckoCore/support\n[supportchat-img]: https://img.shields.io/gitter/room/tunnckoCore/support.svg\n\n[bulgaria-url]: https://www.google.bg/search?q=Sofia%2C+Bulgaria \"One of the top 10 best places for start-up business in the world, especially in IT technologies\"\n\n[changelogmd-url]: https://github.com/tunnckoCore/dush-promise/blob/master/CHANGELOG.md\n[conventions-url]: https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md\n[tunnckocore-twitter-url]: https://twitter.com/tunnckoCore\n[opensource-project-url]: http://openopensource.org\n[nyc-istanbul-url]: https://istanbul.js.org\n[circle-ci-url]: https://circleci.com\n[appveyor-ci-url]: https://appveyor.com\n[codecov-coverage-url]: https://codecov.io\n[semver-url]: http://semver.org\n[eslint-url]: http://eslint.org\n[conventional-messages-url]: https://github.com/conventional-changelog/conventional-changelog\n[gk-integration-url]: https://github.com/integration/greenkeeper\n[daviddm-url]: https://david-dm.org\n[open-issue-url]: https://github.com/tunnckoCore/dush-promise/issues/new\n[contributing-url]: https://github.com/tunnckoCore/dush-promise/blob/master/CONTRIBUTING.md\n[absolute-coverage-url]: https://github.com/tunnckoCore/dush-promise/blob/master/package.json\n\n[minibase]: https://github.com/node-minibase/minibase","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fdush-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftunnckocore%2Fdush-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fdush-promise/lists"}