{"id":18265793,"url":"https://github.com/playfulprogramming/unist-util-replace-all-between","last_synced_at":"2026-01-27T05:33:03.645Z","repository":{"id":57386395,"uuid":"413625133","full_name":"playfulprogramming/unist-util-replace-all-between","owner":"playfulprogramming","description":"Replace section of nodes in Unist parent using selections for start/end","archived":false,"fork":false,"pushed_at":"2024-06-24T15:25:03.000Z","size":515,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-24T00:30:53.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/playfulprogramming.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},"funding":{"open_collective":"unicorn-utterances"}},"created_at":"2021-10-05T00:33:47.000Z","updated_at":"2025-01-30T23:29:20.000Z","dependencies_parsed_at":"2024-08-10T23:06:24.245Z","dependency_job_id":null,"html_url":"https://github.com/playfulprogramming/unist-util-replace-all-between","commit_stats":null,"previous_names":["playfulprogramming/unist-util-replace-all-between","unicorn-utterances/unist-util-replace-all-between"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/playfulprogramming/unist-util-replace-all-between","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-replace-all-between","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-replace-all-between/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-replace-all-between/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-replace-all-between/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playfulprogramming","download_url":"https://codeload.github.com/playfulprogramming/unist-util-replace-all-between/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-replace-all-between/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28804004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-05T11:19:45.531Z","updated_at":"2026-01-27T05:33:03.625Z","avatar_url":"https://github.com/playfulprogramming.png","language":"JavaScript","readme":"# unist-util-replace-all-between\n\n[**unist**](https://github.com/syntax-tree/unist) utility to modify an existing child list to replace all elements between all\ninstances of two nodes\n\n## Install\n\n[npm](https://docs.npmjs.com/cli/install):\n\n```sh\nnpm install unist-util-replace-all-between\n```\n\n## Usage\n\n```js\nimport u from 'unist-builder'\nimport replaceAllBetween from 'unist-util-replace-all-between'\n\nconst tree = u('root', [\n  u('start', '1'),\n  u('node', [u('leaf', '2'), u('node', [u('leaf', '3')])]),\n  u('end', '4'),\n  u('middle', '1'),\n  u('start', '1'),\n  u('node', '2'),\n  u('end', '4'),\n])\n\nconst newChildren = replaceAllBetween(tree, {type: 'start'}, {type: 'end'}, () =\u003e [u('replaced', '1')])\n\nconsole.dir(newChildren, {depth: null})\n```\n\nYields:\n\n```js\n[\n    { type: 'replaced', value: '1' },\n    { type: 'middle', value: '2' },\n    { type: 'replaced', value: '1' },\n]\n```\n\n## API\n\n### `replaceAllBetween(parent, start, end, func)`\n\nMutate an existing parent's children to reflect function return\n\nParent's children are only search. None of their children (or further down) are searched\n\n###### Parameters\n\n* `parent` ([`Parent`](https://github.com/syntax-tree/unist#parent))\n    — Parent to walk through children of\n* `start` ([`Test`](https://github.com/syntax-tree/unist-util-is)) — [`is`](https://github.com/syntax-tree/unist-util-is)-compatible test (such as a\n    [type](https://github.com/syntax-tree/unist#type)) to find the start of each section\n* `end` ([`Test`](https://github.com/syntax-tree/unist-util-is)) — [`is`](https://github.com/syntax-tree/unist-util-is)-compatible test (such as a\n    [type](https://github.com/syntax-tree/unist#type)) to find the end of each section\n* `func` ((`nodes`: [`Node[]`](https://github.com/syntax-tree/unist#node)) `=\u003e` [`Node[]`](https://github.com/syntax-tree/unist#node)) — Function\n    used to change nodes. Return value is then set to the parent.children value\n\n###### Returns\n\n[`Node[]`](https://github.com/syntax-tree/unist#node) — List of children from `parent` post-mutation\n","funding_links":["https://opencollective.com/unicorn-utterances"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayfulprogramming%2Funist-util-replace-all-between","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplayfulprogramming%2Funist-util-replace-all-between","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayfulprogramming%2Funist-util-replace-all-between/lists"}