{"id":23338216,"url":"https://github.com/yisraelx/promises","last_synced_at":"2025-04-09T22:30:54.165Z","repository":{"id":57138254,"uuid":"95319901","full_name":"yisraelx/promises","owner":"yisraelx","description":"Promises is utilities modules for promises, written in typescript.","archived":false,"fork":false,"pushed_at":"2018-07-16T20:36:04.000Z","size":611,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T17:09:21.101Z","etag":null,"topics":["async","await","deferred","javascript","modular","modules","parallel","promise","promises","series","typescript","utilities","utils"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/yisraelx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-24T20:03:33.000Z","updated_at":"2021-06-15T18:28:04.000Z","dependencies_parsed_at":"2022-08-25T10:01:34.142Z","dependency_job_id":null,"html_url":"https://github.com/yisraelx/promises","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/yisraelx%2Fpromises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisraelx%2Fpromises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisraelx%2Fpromises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisraelx%2Fpromises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yisraelx","download_url":"https://codeload.github.com/yisraelx/promises/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248123283,"owners_count":21051436,"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":["async","await","deferred","javascript","modular","modules","parallel","promise","promises","series","typescript","utilities","utils"],"created_at":"2024-12-21T03:12:47.411Z","updated_at":"2025-04-09T22:30:54.116Z","avatar_url":"https://github.com/yisraelx.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Promises\n[![Travis build](https://travis-ci.org/yisraelx/promises.svg?branch=master)](https://travis-ci.org/yisraelx/promises)\n[![Codecov](https://codecov.io/gh/yisraelx/promises/branch/master/graph/badge.svg)](https://codecov.io/gh/yisraelx/promises)\n[![MIT License](https://img.shields.io/npm/l/@promises/core.svg)](https://github.com/yisraelx/promises/blob/master/LICENSE)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)\n\n**Promises is utilities modules for promises, written in typescript.**\n\n## Packages structure\n* **The code is divided into many small modules and each module is a package in itself ([Packages List](https://github.com/yisraelx/promises/blob/master/PACKAGES.md)).**\n* **Each package in the scoop has only one function or class and it in the default export of the package.**\n* **Group package brings together several modules from the scope, and in the export has access to all modules.**\n\n**Marks:**\n* \"**-**\": **@{scope}/-{name}** - Group package\n* \"**_**\": **@{scope}/_{name}** - Internal package\n\n## Install\n*Installation of a group of all packages in scoop @promises*\n```sh\n$ npm install --save @promises/-all\n```\n*Installation of a single package from scoop @promises*\n```sh\n$ npm install --save @promises/for-each-series\n```\n\n## Use\n**Modules**\n```typescript\nimport { filterSeries } from '@promises/-all';\n```\n*Or import only the module you need*\n```typescript\nimport { default as forEachSeries } from '@promises/for-each-series'; \n```\n**Browser**\n```html\n\u003cscript src=\"https://unpkg.com/@promises/-all/bundle.umd.min.js\"\u003e\u003cscript\u003e\n```\n*Or import only the module you need*\n```html\n\u003cscript src=\"https://unpkg.com/@promises/for-each-series/bundle.umd.min.js\"\u003e\u003cscript\u003e\n```\n```typescript\nlet { forEachSeries } = P;\n```\n**Example**\n```typescript\nimport mapSeries from '@promises/map-series';\nlet array: number[] = [1, 2, 3];\nlet map: Promise\u003cnumber[]\u003e = mapSeries(array, (value: number, index: number, array: number[]) =\u003e {\n    return value * index;\n});\nmap.then((result: number[]) =\u003e {\n    console.log(result) // =\u003e [0, 2, 6]\n});\n```\n\n### Functional programming\n**Modules**\n```typescript\nimport { rejectSeries } from '@promises/-all/fp';\n```\n*Or import only the module you need*\n```typescript\nimport { default as mapParallel } from '@promises/map-parallel/fp'; \n```\n**Browser**\n```html\n\u003cscript src=\"https://unpkg.com/@promises/-all/fp/bundle.umd.min.js\"\u003e\u003cscript\u003e\n```\n*Or import only the module you need*\n```html\n\u003cscript src=\"https://unpkg.com/@promises/every-parallel/fp/bundle.umd.min.js\"\u003e\u003cscript\u003e\n```\n```typescript\nlet { everyParallel } = PF;\n```\n**Example**\n```typescript\nimport filterParallel from '@promises/filter-parallel/fp';\nimport mapParallel from '@promises/map-parallel/fp';\nimport { sleep } from '@promises/-all/fp';\n\nlet array: number[] = [1, 2, 3];\nlet filterOdd = filterParallel((value: number) =\u003e value % 2 !== 0)(Infinity);\nlet sleepSecond = sleep(1000);\n\nPromise\n    .resolve(array)\n    .then(filterOdd)\n    .then(mapParallel((value: number, index: number) =\u003e value + index, void 0))\n    .then(sleepSecond)\n    .then((result: number[]) =\u003e {\n        console.log(result) // =\u003e [1, 4]\n    });\n    \n```\n\n### wrapper\n**Modules**\n\n*it will add all the modules in the group to Promises*\n```typescript\nimport Promises from '@promises/core';\nimport '@promises/-all/add';\n```\n*Or*\n```typescript\nimport Promises from '@promises/-all/add';\n```\n*Or add all modules in specific groups*\n```typescript\nimport Promises from '@promises/core';\nimport '@promises/-series/add';\nimport '@promises/-rxjs/add';\n```\n*Or add specific modules*\n```typescript\nimport Promises from '@promises/core';\nimport '@promises/filter-parallel/add';\nimport '@promises/map-parallel/add';\nimport '@promises/sleep/add';\n```\n*Note: for bundles add only the modules needed, because Tree-shaking can not remove the unnecessary modules*\n\n**Browser**\n```html\n\u003cscript src=\"https://unpkg.com/@promises/core/bundle.umd.min.js\"\u003e\u003cscript\u003e\n\u003cscript src=\"https://unpkg.com/@promises/-all/add/bundle.umd.min.js\"\u003e\u003cscript\u003e\n```\n```typescript\nlet { Promises } = P;\n```\n**Example**\n```typescript\nimport Promises from '@promises/-all/add';\nlet array: number[] = [1, 2, 3];\nlet promises: Promises\u003cnumber[]\u003e = Promises.resolve(array);\nlet filter: Promises\u003cnumber[]\u003e = promises.filterParallel((value: number) =\u003e value % 2 !== 0);\nlet map: Promises\u003cnumber[]\u003e = filter.mapParallel((value: number, index: number) =\u003e value + index);\nlet sleep: Promises\u003cnumber[]\u003e = map.sleep(1000);\nsleep.then((result: number[]) =\u003e {\n    console.log(result) // =\u003e [1, 4]\n});\n```\n\n## Behavior\n\n```typescript\nimport timeout from '@promises/timeout';\n\nfunction run(forEach: Function) {\n    let array: number[] = [3, 7, 1, 5];\n\n    console.log('before');\n    forEach(array, (value: number) =\u003e {\n        console.log(`start: ${value}`);\n        return timeout((resolve) =\u003e {\n            console.log(`end: ${value}`);\n            resolve();\n        }, value);\n    }).then(() =\u003e {\n        console.log('complete');\n    });\n    console.log('after');\n}\n```\n**Parallel**\n```typescript\nimport forEachParallel from '@promises/for-each-parallel';\n\nrun(forEachParallel);\n\n// =\u003e before\n// =\u003e after\n// =\u003e start 3\n// =\u003e start 7\n// =\u003e start 1\n// =\u003e start 5\n// =\u003e end 1\n// =\u003e end 3\n// =\u003e end 5\n// =\u003e end 7\n// =\u003e complete\n```\n**Series**\n```typescript\nimport forEachSeries from '@promises/for-each-series';\n\nrun(forEachSeries);\n\n// =\u003e before\n// =\u003e after\n// =\u003e start 3\n// =\u003e end 3\n// =\u003e start 7\n// =\u003e end 7\n// =\u003e start 1\n// =\u003e end 1\n// =\u003e start 5\n// =\u003e end 5\n// =\u003e complete\n```\n**Wrap**\n```typescript\nimport forEach from '@pakal/for-each';\nimport wrap from '@promises/wrap';\n\nlet forEachWrap = wrap(forEach);\n\nrun(forEachWrap);\n\n// =\u003e before\n// =\u003e after\n// =\u003e start 3\n// =\u003e start 7\n// =\u003e start 1\n// =\u003e start 5\n// =\u003e complete    \n// =\u003e end 1\n// =\u003e end 3\n// =\u003e end 5\n// =\u003e end 7\n```\n\n## Compatibility\nThese modules are written in typescript and available in ES5 and ES6 standard, the requirements are a global __Promise__ (native or polyfill).\n\n* main - commonjs module and es5 standard (index.js)\n* module - es2015 module and es5 standard (index.esm.js)\n* browser - bundle in umd format includes all scope dependencies in es5 standard (bundle.umd.js, bundle.umd.min.js)\n* es2015 - commonjs module and es2015 standard (index.es6.js)\n* typings - typescript declaration file (index.d.ts)\n\n## License\nCopyright © 2017 [Yisrael Eliav](https://github.com/yisraelx),\nLicensed under the [MIT license](https://github.com/yisraelx/promises/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisraelx%2Fpromises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyisraelx%2Fpromises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisraelx%2Fpromises/lists"}