{"id":21290117,"url":"https://github.com/jumpn/utils-promise","last_synced_at":"2025-03-15T16:12:30.387Z","repository":{"id":57100333,"uuid":"104287534","full_name":"jumpn/utils-promise","owner":"jumpn","description":"Promise Utilities","archived":false,"fork":false,"pushed_at":"2017-10-30T22:55:37.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-21T20:43:46.022Z","etag":null,"topics":["deferred","functional-programming","promise","promise-utilities","utilities","utils"],"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/jumpn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-21T01:43:44.000Z","updated_at":"2017-10-30T22:57:30.000Z","dependencies_parsed_at":"2022-08-20T21:40:48.817Z","dependency_job_id":null,"html_url":"https://github.com/jumpn/utils-promise","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jumpn","download_url":"https://codeload.github.com/jumpn/utils-promise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243754093,"owners_count":20342542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["deferred","functional-programming","promise","promise-utilities","utilities","utils"],"created_at":"2024-11-21T12:44:55.874Z","updated_at":"2025-03-15T16:12:30.361Z","avatar_url":"https://github.com/jumpn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @jumpn/utils-promise\n\n\u003e Promise utilities\n\u003e\n\u003e **NOTE**: All the functions described in [API](#API) are curried\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\u003c!-- END doctoc --\u003e\n\n- [Installation](#installation)\n  - [Using npm](#using-npm)\n  - [Using yarn](#using-yarn)\n- [Types](#types)\n- [API](#api)\n  - [allByName](#allbyname)\n  - [booleanize](#booleanize)\n  - [chain](#chain)\n  - [createDeferred](#createdeferred)\n  - [promisifyFunction](#promisifyfunction)\n  - [promisifyObject](#promisifyobject)\n  - [track](#track)\n  - [promiseTry](#promisetry)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\n### Using [npm](https://docs.npmjs.com/cli/npm)\n\n    $ npm install --save @jumpn/utils-promise\n\n### Using [yarn](https://yarnpkg.com)\n\n    $ yarn add @jumpn/utils-promise\n\n## Types\n\n```flowtype\ntype Deferred\u003cResult\u003e = {\n  promise: Promise\u003cResult\u003e,\n  resolve: (result: Result) =\u003e void,\n  reject: (error: any) =\u003e void\n};\n\ntype PromiseInfo\u003cResult\u003e = {\n  result: Result,\n  status: void | \"rejected\" | \"resolved\"\n};\n```\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### allByName\n\nReturns a promise that will be resolved with an object the results of all the\ngiven promises or it will reject with an Error that will have an additional\nproperty \"from\" with the name of the promise that caused the rejection.\n\n**Parameters**\n\n-   `promisesByName` **PromisesByName** \n\nReturns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;ResultsByName\u003e** \n\n### booleanize\n\nReturns a new promise which follows the one given returning true in case\nthere was no error, or false otherwise\n\n**Parameters**\n\n-   `promise` **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;any\u003e** \n\nReturns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** \n\n### chain\n\nChains all promises starting from initialPromise and binding chainers to\nnext methods\n\n**Parameters**\n\n-   `chainers` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)\u003e** \n-   `initialPromise` **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;any\u003e** \n\nReturns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;any\u003e** \n\n### createDeferred\n\nCreates a Deferred\n\nReturns **Deferred\u0026lt;any\u003e** \n\n### promisifyFunction\n\nReturns a new function that:\n\n-   if last argument is a callback =\u003e\n    it will mimic the function given.\n-   if last argument is not a callback =\u003e\n    it will return a promise which will be resolved or rejected following the\n    execution of the function given.\n\n**Parameters**\n\n-   `fn` **function (): Result** \n\n### promisifyObject\n\nReturns a new object with the result of having promisified all the methods of\nthe one given.\n\n**Parameters**\n\n-   `object` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n\nReturns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n\n### track\n\nReturns an object with status and value properties that are updated as soon\nas the promise is resolved or rejected\n\n**Parameters**\n\n-   `promise` **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;Result\u003e** \n\nReturns **PromiseInfo\u0026lt;$Supertype\u0026lt;Result\u003e\u003e** \n\n### promiseTry\n\nReturns a promise that will be resolved with the result of execute,\nor rejected with the error thrown by it (if any).\n\n**Parameters**\n\n-   `execute` **function (): Result** \n\nReturns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;Result\u003e** \n\n## License\n\n[MIT](LICENSE.txt) :copyright: **Jumpn Limited** / Mauro Titimoli (mauro@jumpn.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumpn%2Futils-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjumpn%2Futils-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumpn%2Futils-promise/lists"}