{"id":23050236,"url":"https://github.com/krivega/stack-promises","last_synced_at":"2025-04-24T04:35:28.871Z","repository":{"id":42925993,"uuid":"242939519","full_name":"Krivega/stack-promises","owner":"Krivega","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-28T06:10:15.000Z","size":1315,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T22:07:46.866Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Krivega.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-25T07:41:08.000Z","updated_at":"2025-01-28T06:10:19.000Z","dependencies_parsed_at":"2023-02-07T12:30:24.698Z","dependency_job_id":"41542179-9a87-4ddb-8c57-5290a803da70","html_url":"https://github.com/Krivega/stack-promises","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":0.05882352941176472,"last_synced_commit":"718db7ba9ab6bd1f6a9a9dc32dd467b2fb1c1f88"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Fstack-promises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Fstack-promises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Fstack-promises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivega%2Fstack-promises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Krivega","download_url":"https://codeload.github.com/Krivega/stack-promises/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566298,"owners_count":21451227,"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":[],"created_at":"2024-12-15T23:30:41.401Z","updated_at":"2025-04-24T04:35:28.842Z","avatar_url":"https://github.com/Krivega.png","language":"TypeScript","readme":"# stack-promises\n\n[![npm](https://img.shields.io/npm/v/stack-promises?style=flat-square)](https://www.npmjs.com/package/stack-promises)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/stack-promises?style=flat-square)\n\nA stack of tasks that are executed one by one, but the result is taken from the last.\nIdentical functions on the stack (check by reference) are executed only once.\n\n## Install\n\nnpm\n\n```sh\nnpm install stack-promises\n```\n\nyarn\n\n```sh\nyarn add stack-promises\n```\n\n## Usage\n\n```js\nimport creteStackPromises from 'stack-promises';\n\nconst stackPromises = creteStackPromises();\n\nstackPromises.add(() =\u003e Promise.resolve(1));\nstackPromises.add(() =\u003e Promise.resolve(2));\n\nstackPromises().then(data =\u003e {\n  console.log(data); /// 2\n});\n```\n\n### Execute after add\n\n```js\nimport creteStackPromises from 'stack-promises';\n\nconst stackPromises = creteStackPromises();\n\nstackPromises\n  .add(() =\u003e Promise.resolve(1))() // execute\n  .then(data =\u003e {\n    console.log(data); // 1\n  });\nstackPromises\n  .add(() =\u003e Promise.resolve(2))() // execute\n  .then(data =\u003e {\n    console.log(data); // 2\n  });\n\nstackPromises().then(data =\u003e {\n  console.log(data); // 2\n});\n```\n\n### Add after execute\n\n```js\nimport creteStackPromises, { isPromiseIsNotActualError } from 'stack-promises';\nimport delayPromise from 'promise-delay';\n\nconst stackPromises = creteStackPromises();\n\nlet checkQue = 0;\nconst request1 = () =\u003e\n  delayPromise(3000, 1).finally(() =\u003e {\n    checkQue += 1;\n  });\nconst resultAfter1 = stackPromises.add(request1)();\n\nconst request2 = () =\u003e\n  delayPromise(1000, 2).finally(() =\u003e {\n    checkQue *= 2;\n  });\nconst resultAfter2 = stackPromises.add(request2)();\n\nPromise.allSettled([resultAfter1, resultAfter2]).then(([{ reason }, { value }]) =\u003e {\n  isPromiseIsNotActualError(reason); // true\n  value; // 2\n  checkQue; // 2\n  // request1 called 1 times\n  // request2 called 1 times\n});\n```\n\n### Chaining\n\n```js\nstackPromises.add(() =\u003e Promise.resolve(1)).add(() =\u003e Promise.resolve(2));\n```\n\n## Run tests\n\n```sh\nnpm test\n```\n\n## Maintainer\n\n**Krivega Dmitriy**\n\n- Website: https://krivega.com\n- Github: [@Krivega](https://github.com/Krivega)\n\n## Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/Krivega/stack-promises/issues). You can also take a look at the [contributing guide](https://github.com/Krivega/stack-promises/blob/master/CONTRIBUTING.md).\n\n## 📝 License\n\nCopyright © 2020 [Krivega Dmitriy](https://github.com/Krivega).\u003cbr /\u003e\nThis project is [MIT](https://github.com/Krivega/stack-promises/blob/master/LICENSE) licensed.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrivega%2Fstack-promises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrivega%2Fstack-promises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrivega%2Fstack-promises/lists"}