{"id":19245096,"url":"https://github.com/rxtoolkit/utils","last_synced_at":"2025-02-23T15:15:44.143Z","repository":{"id":214798641,"uuid":"555894937","full_name":"rxtoolkit/utils","owner":"rxtoolkit","description":"🛠️ RxJS operators for very common data transformation tasks","archived":false,"fork":false,"pushed_at":"2024-01-01T18:12:56.000Z","size":575,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T05:50:02.824Z","etag":null,"topics":["fp","functional-programming","observables","package","reactive-programming","rxjs"],"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/rxtoolkit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-10-22T15:32:41.000Z","updated_at":"2024-01-02T15:43:00.000Z","dependencies_parsed_at":"2023-12-30T22:07:06.450Z","dependency_job_id":"1ab7168b-9a2e-44bf-aa2d-459e8e78c285","html_url":"https://github.com/rxtoolkit/utils","commit_stats":null,"previous_names":["rxtoolkit/utils"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Futils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Futils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Futils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Futils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxtoolkit","download_url":"https://codeload.github.com/rxtoolkit/utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240331361,"owners_count":19784646,"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":["fp","functional-programming","observables","package","reactive-programming","rxjs"],"created_at":"2024-11-09T17:26:37.558Z","updated_at":"2025-02-23T15:15:44.118Z","avatar_url":"https://github.com/rxtoolkit.png","language":"JavaScript","readme":"# @rxtk/utils\n\u003e 🔌 Re-usable operators and utilities for rxjs\n\n```bash\nnpm i @rxtk/utils\n```\n\n```bash\nyarn add @rxtk/utils\n```\n\n## API\n\n### `debug`\nAdd a debugger to an RXJS pipeline.\n```js\nimport {from} from 'rxjs';\nimport {map} from 'rxjs/operators';\nimport {debug,toConsole} from '@rxtk/utils';\n\nconst input$ = from([2, 3]);\nconst output$ = input$.pipe(\n  toConsole('input'),\n  debug(), // inserts breakpoint here\n  map(n =\u003e n * n),\n  toConsole('squared'),\n  debug() // inserts a second breakpoint here\n);\noutput$.subscribe();\n// 2\n// debugger will pause here!\n// squared 4\n// debugger will pause here!\n// 3\n// debugger will pause here!\n// squared 9\n// debugger will pause here!\n```\n\n### `delayUntil`\nDelays emissions from a source observable until another observable emits.\n```js\nimport {from,timer} from 'rxjs';\nimport {map} from 'rxjs/operators';\nimport {tap} from 'rxjs/operators';\nimport {delayUntil} from '@rxtk/utils';\n\n// this code delay emitting items from the source observable until 5 seconds \n// have passed\nconst string$ = from(['foo', 'bar']);\nconst start$ = timer(5000).pipe(tap(console.log));\nconst output$ = string$.pipe(delayUntil(start$));\noutput$.subscribe(console.log); \n// Output:\n// 5000\n// foo\n// bar\n```\n\n### `listToSingleResult`\nGets the item from a single-item array and throws if the array is empty or has multiple items.\n```js\nimport {of} from 'rxjs';\nimport {listToSingleResult} from '@rxtk/utils';\n\n// this code delay emitting items from the source observable until 5 seconds \n// have passed\nconst input$ = of([{'foo': 'bar'}]);\nconst output$ = string$.pipe(listToSingleResult());\noutput$.subscribe(console.log); \n// Output:\n// {foo: bar}\n```\n\n### `reduceToString`\nConcatenates items into a string.\n```js\nimport {from,takeLast} from 'rxjs';\nimport {listToSingleResult} from '@rxtk/utils';\n\n// this code delay emitting items from the source observable until 5 seconds \n// have passed\nconst input$ = from(['always ', 'money ', 'in ', 'the ', 'banana ', 'stand']);\nconst output$ = string$.pipe(\n  reduceToString(),\n  takeLast(1)\n);\noutput$.subscribe(console.log); \n// Output:\n// \"always money in the banana stand\"\n```\n\n### `parseJSON`\nMap JSON strings to JavaScript objects.\n```js\nimport {from} from 'rxjs';\nimport {toConsole, parseJSON} from '@rxtk/utils';\n\nconst input$ = from(['{\"foo\": \"bar\"}']);\nconst output$ = input$.pipe(\n  parseJSON(),\n  toConsole()\n);\noutput$.subscribe();\n// {foo: 'bar'}\n```\n\n### `toConsole`\nAdd log an RXJS pipeline's data to the console.\n```js\nimport {from} from 'rxjs';\nimport {toConsole} from '@rxtk/utils';\n\nconst input$ = from([1, 2, 3]);\nconst output$ = input$.pipe(\n  toConsole(),\n  map(n =\u003e n * n),\n  toConsole('squared')\n);\noutput$.subscribe();\n// 1\n// squared 1\n// 2\n// squared 4\n// 3\n// squared 4\n```\n\n### `toJSON`\nMap each item to a JSON string.\n```js\nimport {from} from 'rxjs';\nimport {toConsole, toJSON} from '@rxtk/utils';\n\nconst input$ = from([{foo: 'bar'1}]);\nconst output$ = input$.pipe(\n  toJSON(),\n  toConsole('squared')\n);\noutput$.subscribe();\n// '{\"foo\": \"bar\"}'\n```\n\n### `withIndex`\nAdd an index to data in the stream.\n```js\nimport {from} from 'rxjs';\nimport {withIndex} from '@rxtk/utils';\n\nconst input$ = from(['there\\'s', 'no', 'place', 'like', 'home']);\nconst output$ = input$.pipe(\n  withIndex()\n);\noutput$.subscribe(console.log);\n// [\"there's\", 0]\n// [\"no\", 1]\n// [\"place\", 2]\n// [\"like\", 3]\n// [\"home\", 4]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxtoolkit%2Futils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxtoolkit%2Futils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxtoolkit%2Futils/lists"}