{"id":16384781,"url":"https://github.com/saber2pr/fp","last_synced_at":"2025-02-22T03:25:51.163Z","repository":{"id":108570543,"uuid":"192750119","full_name":"Saber2pr/fp","owner":"Saber2pr","description":":heavy_minus_sign: A library for Javascript in functional programing in async | sync | lazy.","archived":false,"fork":false,"pushed_at":"2019-06-22T07:51:24.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T05:03:48.692Z","etag":null,"topics":["async","functional-programming","lazy","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Saber2pr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-06-19T14:37:17.000Z","updated_at":"2019-06-25T13:56:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"ff803694-8acc-4a6f-81ed-6b716072fd18","html_url":"https://github.com/Saber2pr/fp","commit_stats":{"total_commits":30,"total_committers":1,"mean_commits":30.0,"dds":0.0,"last_synced_commit":"1eda801bc858cee887f815fad429dbecb75bce76"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Ffp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Ffp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Ffp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Ffp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saber2pr","download_url":"https://codeload.github.com/Saber2pr/fp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240121624,"owners_count":19751063,"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","functional-programming","lazy","typescript"],"created_at":"2024-10-11T04:12:20.732Z","updated_at":"2025-02-22T03:25:51.145Z","avatar_url":"https://github.com/Saber2pr.png","language":"TypeScript","readme":"# @saber2pr/fp\n\n[![npm](https://img.shields.io/npm/v/@saber2pr/fp.svg?color=%237712c9)](https://www.npmjs.com/package/@saber2pr/fp)\n\n\u003e functional programing in async | sync | lazy.\n\n```bash\n# from npm\nnpm install @saber2pr/fp\n\n# from github\ngit clone https://github.com/Saber2pr/fp.git\n```\n\n# Why\n\nIf you often program with node.js, there will be some bad cases in async, like this:\n\n```ts\nconst contents = await Promise.all(\n  ['./1.txt', './2.txt'].map(async file_name =\u003e ({\n    content1: await readFile(file_name).then(buffer =\u003e buffer.toString()),\n    content2: await readFile(file_name).then(buffer =\u003e buffer.toString())\n  }))\n)\n```\n\nthen you get a bad result, the `contents.content1` and `contents.content2` is a Promise\n\n#### How to deal with it?\n\nNow, there is a function named `async_map` to it:\n\n```ts\nconst contents = async_map(['./1.txt', './2.txt'], async file_name =\u003e ({\n  content1: await readFile(file_name).then(buffer =\u003e buffer.toString()),\n  content2: await readFile(file_name).then(buffer =\u003e buffer.toString())\n}))\n```\n\nyou will get a result and the `contents.content1` and `contents.content2` is the correct type \"string\".\n\nwhat's more...\n\n# API\n\ncompose\n\npipe\n\nsetter\n\nasync_reduce\n\nasync_reduceRight\n\nasync_compose\n\nasync_pipe\n\nasync_setter\n\nasync_forEach\n\nasync_filter\n\nasync_intercept\n\nasync_map\n\n\\*range\n\n\\*map\n\n\\*filter\n\n\\*reduce\n\ntoIt\n\nfrom\n\n---\n\n## start\n\n```bash\nnpm install\n```\n\n```bash\nnpm start\n\nnpm test\n\n```\n\n\u003e Author: saber2pr\n\n---\n\n## develope and test\n\n\u003e you should write ts in /src\n\n\u003e you should make test in /src/test\n\n\u003e export your core in /src/index.ts!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Ffp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaber2pr%2Ffp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Ffp/lists"}