{"id":26343951,"url":"https://github.com/iplaylf2/collection-query","last_synced_at":"2025-03-16T05:19:46.042Z","repository":{"id":54683332,"uuid":"278875212","full_name":"iplaylf2/collection-query","owner":"iplaylf2","description":"A collection processing library.","archived":false,"fork":false,"pushed_at":"2021-02-19T09:55:18.000Z","size":170,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T22:09:03.587Z","etag":null,"topics":["collection","query","stream","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iplaylf2.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":"2020-07-11T14:14:23.000Z","updated_at":"2021-11-28T13:46:25.000Z","dependencies_parsed_at":"2022-08-14T00:00:19.812Z","dependency_job_id":null,"html_url":"https://github.com/iplaylf2/collection-query","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iplaylf2%2Fcollection-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iplaylf2%2Fcollection-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iplaylf2%2Fcollection-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iplaylf2%2Fcollection-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iplaylf2","download_url":"https://codeload.github.com/iplaylf2/collection-query/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243827697,"owners_count":20354361,"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":["collection","query","stream","typescript"],"created_at":"2025-03-16T05:19:45.461Z","updated_at":"2025-03-16T05:19:46.028Z","avatar_url":"https://github.com/iplaylf2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# collection-query\n\nA collection processing library.\n\nEnglish | [中文](https://github.com/Iplaylf2/collection-query/blob/master/doc/README.cn.md)\n-\n\n## Feature\n\n- Simple to use.\n- The entity which represent the collection is close to the native object.\n- Methods are few and common.\n\n## Install\n\n``` bash\nnpm install collection-query\n```\n\n## Usage\n\n``` typescript\nimport { take } from \"collection-query/pull\";\n\n// Create a pull stream\nconst s = function* () {\n  let count = 0;\n  while (true) {\n    yield count++;\n  }\n};\n\n// Convert the stream to another\nconst new_s = take(3)(s);\n\n// Each the pull stream\nfor (const x of new_s()) {\n  console.log(x);\n}\n\n\n// Print 0 1 2\n```\n\n## Pull and push\n\nPull and push are inspired by rxjs.\n\nThere are 2 ways to generate data.\n- `pull` data: Produced passively, consumed actively\n- `push` data: Produced actively, consumed passively\n\n`collection-query` provides 4 streams to implement the pull and push respectively.\n\n\"pull\", \"async-pull\", \"push\", \"async-push\"\n\n### Pull\n\nThe streams `pull` and `async-pull` base on javascript generator.\n\n``` typescript\nconst pull_stream = function* () {\n  yield 0;\n};\n```\n\nPull stream always generates data synchronously.\n\n``` typescript\nconst async_pull_stream = async function* () {\n  yield 0;\n};\n```\n\nAsync pull stream always generates data asynchronously.\n\n### Push\n\nThe streams `push` and `async-push` base on `Emitter`\n\n``` typescript\nconst push_stream = create(function (emit) {\n  emit(EmitType.Next, 0);\n  emit(EmitType.Complete);\n});\n```\n\nPush stream can generate data synchronously or asynchronously.\n\n``` typescript\nconst async_push_stream = create_async(function (emit) {\n  emit(EmitType.Next, 0);\n  emit(EmitType.Complete);\n});\n```\n\nAsync push stream always generates data asynchronously.\n\n## Method\n\n`collection-query` provides different set of methods to access the stream, but they almost always have the same name and the same semantics.\n\n``` typescript\nimport * as pull from \"collection-query/pull\";\nimport * as asyncPull from \"collection-query/async-pull\";\nimport * as push from \"collection-query/push\";\nimport * as asyncPush from \"collection-query/async-push\";\n\n// For example, they all have a \"take\" method.\n```\n\n[Document](https://github.com/Iplaylf2/collection-query/blob/master/doc/document.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiplaylf2%2Fcollection-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiplaylf2%2Fcollection-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiplaylf2%2Fcollection-query/lists"}