{"id":21730510,"url":"https://github.com/andy2046/promisu","last_synced_at":"2025-03-20T23:24:02.691Z","repository":{"id":65475860,"uuid":"111051864","full_name":"andy2046/promisu","owner":"andy2046","description":"functional promise with operators Map Filter Reduce Scan and more","archived":false,"fork":false,"pushed_at":"2018-03-14T04:35:37.000Z","size":163,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T08:04:31.295Z","etag":null,"topics":["all","debounce","every","few","filter","finally","functional","javascript","map","promise","queue","race","reducer","scan","some","throttle","waitfor"],"latest_commit_sha":null,"homepage":"","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/andy2046.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-11-17T03:17:40.000Z","updated_at":"2019-06-09T02:38:41.000Z","dependencies_parsed_at":"2023-01-25T06:15:20.520Z","dependency_job_id":null,"html_url":"https://github.com/andy2046/promisu","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fpromisu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fpromisu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fpromisu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fpromisu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andy2046","download_url":"https://codeload.github.com/andy2046/promisu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244217951,"owners_count":20417677,"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":["all","debounce","every","few","filter","finally","functional","javascript","map","promise","queue","race","reducer","scan","some","throttle","waitfor"],"created_at":"2024-11-26T04:16:12.509Z","updated_at":"2025-03-20T23:24:02.668Z","avatar_url":"https://github.com/andy2046.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# promisu\npromisu is a JavaScript lib for functional promise with the following operators: **Map**, **Filter**, **Reduce**, **Scan**, **Every**, **Some**, **Few**, **Finally**, **All**, **Race**, **Try**, **WaitFor**, **Queue**, **Debounce**, **Throttle**.\n\n## Examples\n```js\nimport {\n  PromisuAll,\n  PromisuMap,\n  PromisuEvery,\n  PromisuFew,\n  PromisuFilter,\n  PromisuFinally,\n  PromisuQueue,\n  PromisuRace,\n  PromisuReduce,\n  PromisuSome,\n  PromisuTry,\n  PromisuWaitFor,\n  PromisuScan,\n  PromisuDebounce,\n  PromisuThrottle\n} from 'promisu';\n\nconst asyncTask = (time) =\u003e () =\u003e { return new Promise(resolve =\u003e {\n  setTimeout(() =\u003e resolve(time), time)\n})};\n\nconst testPromisuQueue = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuQueue\n  console.log('// PromisuQueue');\n\n  const promisuQueue = PromisuQueue.of({ concurrency: 1 });\n\n  promisuQueue.add(asyncTask(1000), { priority: 1 }).then(() =\u003e {\n    console.log('async task 1000 Done');\n  });\n\n  promisuQueue.addAll([asyncTask(2000), asyncTask(4000)], { priority: 2 }).then(() =\u003e {\n    console.log('async task 2000/4000 Done');\n    resolve()\n  });\n\n  promisuQueue.add(asyncTask(3000), { priority: 3 }).then(() =\u003e {\n    console.log('async task 3000 Done');\n  });\n\n  // async task 1000 Done\n  // async task 3000 Done\n  // async task 2000/4000 Done\n\n})\n\nconst testPromisuAll = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuAll\n  console.log('// PromisuAll');\n\n  PromisuAll([asyncTask(2000), asyncTask(4000)], { concurrency: 2 })\n    .then((result) =\u003e {\n      console.log('PromisuAll done', result);\n      resolve()\n    })\n\n  // PromisuAll done [ 2000, 4000 ]\n\n})\n\nconst testPromisuRace = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuRace\n  console.log('// PromisuRace');\n\n  PromisuRace([asyncTask(2000)(), asyncTask(1000)()])\n    .then((result) =\u003e {\n      console.log('PromisuRace done', result);\n      resolve()\n    })\n\n  // PromisuRace done 1000\n\n})\n\nconst testPromisuEvery = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuEvery\n  console.log('// PromisuEvery');\n\n  const testFn = x =\u003e x \u003e 1000;\n\n  PromisuEvery([asyncTask(2000)(), 3000], testFn)\n    .then((result) =\u003e {\n      console.log('PromisuEvery done', result);\n      resolve()\n    })\n\n  // PromisuEvery done true\n\n})\n\nconst testPromisuSome = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuSome\n  console.log('// PromisuSome');\n\n  const testFn = x =\u003e x \u003e 2000;\n\n  PromisuSome([asyncTask(2000)(), 3000], testFn)\n    .then((result) =\u003e {\n      console.log('PromisuSome done', result);\n      resolve()\n    })\n\n  // PromisuSome done true\n\n})\n\nconst testPromisuFew = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuFew\n  console.log('// PromisuFew');\n\n  PromisuFew([asyncTask(2000)(), 3000, asyncTask(1000)()], { count: 2 })\n    .then((result) =\u003e {\n      console.log('PromisuFew done', result);\n      resolve()\n    })\n\n  // PromisuFew done [ 3000, 1000 ]\n\n})\n\nconst testPromisuMap = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuMap\n  console.log('// PromisuMap');\n\n  const mapFn = x =\u003e new Promise(resolve =\u003e { resolve(x + 1) })\n\n  PromisuMap([asyncTask(2000)(), 3000, asyncTask(1000)()], mapFn, { concurrency: 2 })\n    .then((result) =\u003e {\n      console.log('PromisuMap done', result);\n      resolve()\n    })\n\n  // PromisuMap done [ 2001, 3001, 1001 ]\n\n})\n\nconst testPromisuFilter = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuFilter\n  console.log('// PromisuFilter');\n\n  const filterFn = x =\u003e new Promise(resolve =\u003e { resolve(x \u003e 1000) })\n\n  PromisuFilter([asyncTask(2000)(), 3000, asyncTask(1000)()], filterFn, { concurrency: 2 })\n    .then((result) =\u003e {\n      console.log('PromisuFilter done', result);\n      resolve()\n    })\n\n  // PromisuFilter done [ 2000, 3000 ]\n\n})\n\nconst testPromisuReduce = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuReduce\n  console.log('// PromisuReduce');\n\n  const reduceFn = (acc, curr) =\u003e new Promise(resolve =\u003e { resolve(acc + curr) })\n\n  PromisuReduce([asyncTask(2000)(), 3000, asyncTask(1000)()], reduceFn, 0)\n    .then((result) =\u003e {\n      console.log('PromisuReduce done', result);\n      resolve()\n    })\n\n  // PromisuReduce done 6000\n\n})\n\nconst testPromisuScan = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuScan\n  console.log('// PromisuScan');\n\n  const scanFn = (acc, curr) =\u003e new Promise(resolve =\u003e { resolve(acc + curr) })\n\n  PromisuScan([asyncTask(2000)(), 3000, asyncTask(1000)()], scanFn, 0)\n    .then((result) =\u003e {\n      console.log('PromisuScan done', result);\n      resolve()\n    })\n\n  // PromisuScan done [ 0, 2000, 5000, 6000 ]\n\n})\n\nconst testPromisuWaitFor = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuWaitFor\n  console.log('// PromisuWaitFor');\n\n  const waitFn = x =\u003e () =\u003e new Promise(resolve =\u003e { resolve(x) })\n\n  PromisuWaitFor(waitFn(true), 200)\n    .then(() =\u003e {\n      console.log('PromisuWaitFor done');\n    })\n\n  PromisuWaitFor(waitFn(false), 200)\n    .catch(() =\u003e {\n      // console.log('PromisuWaitFor done');\n      resolve()\n    })\n\n  // PromisuWaitFor done\n\n})\n\nconst testPromisuFinally = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuFinally\n  console.log('// PromisuFinally');\n\n  // TODO\n  resolve()\n\n})\n\nconst testPromisuTry = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuTry\n  console.log('// PromisuTry');\n\n  // TODO\n  resolve()\n\n})\n\nconst testPromisuDebounce = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuDebounce\n  console.log('// PromisuDebounce');\n\n  // TODO\n  resolve()\n\n})\n\nconst testPromisuThrottle = () =\u003e new Promise(resolve =\u003e {\n\n  // PromisuThrottle\n  console.log('// PromisuThrottle');\n\n  // TODO\n  resolve()\n\n})\n\nconst testArr = [\n  testPromisuQueue,\n  testPromisuAll,\n  testPromisuRace,\n  testPromisuEvery,\n  testPromisuSome,\n  testPromisuFew,\n  testPromisuMap,\n  testPromisuFilter,\n  testPromisuReduce,\n  testPromisuScan,\n  testPromisuWaitFor,\n  testPromisuFinally,\n  testPromisuTry,\n  testPromisuDebounce,\n  testPromisuThrottle\n]\n\nconst run = async (testArr) =\u003e {\n  for (let next of testArr) {\n    await next()\n  }\n}\n\nrun(testArr)\n\n```\n\n## Installation\n\n```\nnpm install --save promisu\n```\n\n## Usage\nYou can import one or multiple operators from `promisu`:\n\n```js\nimport {\n  PromisuAll,\n  PromisuMap,\n  PromisuEvery,\n  PromisuFew,\n  PromisuFilter,\n  PromisuFinally,\n  PromisuQueue,\n  PromisuRace,\n  PromisuReduce,\n  PromisuSome,\n  PromisuTry,\n  PromisuWaitFor,\n  PromisuScan,\n  PromisuDebounce,\n  PromisuThrottle\n} from 'promisu';\n// or\nconst {\n  PromisuAll,\n  PromisuMap,\n  PromisuEvery,\n  PromisuFew,\n  PromisuFilter,\n  PromisuFinally,\n  PromisuQueue,\n  PromisuRace,\n  PromisuReduce,\n  PromisuSome,\n  PromisuTry,\n  PromisuWaitFor,\n  PromisuScan,\n  PromisuDebounce,\n  PromisuThrottle\n} = require('promisu');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Fpromisu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandy2046%2Fpromisu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Fpromisu/lists"}