{"id":15011240,"url":"https://github.com/playfulprogramming/unist-util-flat-filter","last_synced_at":"2026-02-06T18:03:01.245Z","repository":{"id":42943577,"uuid":"234016458","full_name":"playfulprogramming/unist-util-flat-filter","owner":"playfulprogramming","description":"Create a new Unist tree by filtering with the provided function and getting all of the returned results in a flat list, not including parent nodes","archived":false,"fork":false,"pushed_at":"2023-03-04T05:41:42.000Z","size":1319,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-27T00:33:10.697Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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}},"created_at":"2020-01-15T06:45:21.000Z","updated_at":"2024-12-09T01:53:10.000Z","dependencies_parsed_at":"2023-02-03T12:00:30.423Z","dependency_job_id":null,"html_url":"https://github.com/playfulprogramming/unist-util-flat-filter","commit_stats":{"total_commits":12,"total_committers":3,"mean_commits":4.0,"dds":"0.41666666666666663","last_synced_commit":"3f81d63cadcaa4794e3d8be5c34937c5ccf378a1"},"previous_names":["playfulprogramming/unist-util-flat-filter","unicorn-utterances/unist-util-flat-filter"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/playfulprogramming/unist-util-flat-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-flat-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-flat-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-flat-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-flat-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playfulprogramming","download_url":"https://codeload.github.com/playfulprogramming/unist-util-flat-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playfulprogramming%2Funist-util-flat-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29171046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T16:33:35.550Z","status":"ssl_error","status_checked_at":"2026-02-06T16:33:30.716Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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-09-24T19:39:50.050Z","updated_at":"2026-02-06T18:03:01.230Z","avatar_url":"https://github.com/playfulprogramming.png","language":"JavaScript","readme":"# unist-util-filter\n\n[**unist**](https://github.com/syntax-tree/unist) utility to create a new tree with all nodes that pass the\ngiven test.\n\n## Install\n\n[npm](https://docs.npmjs.com/cli/install):\n\n```sh\nnpm install unist-util-flat-filter\n```\n\n## Usage\n\n```js\nimport u from 'unist-builder';\nimport flatFilter from 'unist-util-flat-filter';\n\nconst tree = u('root', [\n  u('leaf', '1'),\n  u('node', [u('leaf', '2'), u('node', [u('leaf', '3')])]),\n  u('leaf', '4')\n])\n\nconst newTree = flatFilter(tree, node =\u003e node.type === 'leaf')\n\nconsole.dir(newTree, {depth: null})\n```\n\nYields:\n\n```js\n{\n  type: 'root',\n  children: [\n    { type: 'leaf', value: '1' },\n    { type: 'leaf', value: '2' },\n    { type: 'leaf', value: '3' },\n    { type: 'leaf', value: '4' }\n  ]\n}\n```\n\n## API\n\n### `filter(tree[, test])`\n\nCreate a new [tree](https://github.com/syntax-tree/unist#tree) consisting of copies of all nodes that pass `test`.\nThe tree is walked in [inorder](https://www.geeksforgeeks.org/tree-traversals-inorder-preorder-and-postorder/), visiting the parent, then the children nodes node itself, etc.\n\n###### Parameters\n\n*   `tree` ([`Node?`](https://github.com/syntax-tree/unist#node))\n    — [Tree](https://github.com/syntax-tree/unist#tree) to filter\n*   `test` ([`Test`](https://github.com/syntax-tree/unist-util-is), optional) — [`is`](https://github.com/syntax-tree/unist-util-is)-compatible test (such as a\n    [type](https://github.com/syntax-tree/unist#type))\n\n###### Returns\n\n[`Node?`](https://github.com/syntax-tree/unist#node) — New filtered [tree](https://github.com/syntax-tree/unist#tree).\n`null` is returned if `tree` itself didn’t pass the test, or is cascaded away.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayfulprogramming%2Funist-util-flat-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplayfulprogramming%2Funist-util-flat-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayfulprogramming%2Funist-util-flat-filter/lists"}