{"id":13716573,"url":"https://github.com/syntax-tree/unist-util-is","last_synced_at":"2026-04-02T01:36:26.054Z","repository":{"id":52796447,"uuid":"41795086","full_name":"syntax-tree/unist-util-is","owner":"syntax-tree","description":"utility to check if a node passes a test","archived":false,"fork":false,"pushed_at":"2025-10-22T10:53:09.000Z","size":173,"stargazers_count":44,"open_issues_count":0,"forks_count":8,"subscribers_count":8,"default_branch":"main","last_synced_at":"2026-03-25T23:56:47.001Z","etag":null,"topics":["equal","equality","is","syntax-tree","unist","unist-util","util"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","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/syntax-tree.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"unifiedjs","open_collective":"unified","thanks_dev":"u/gh/syntax-tree"}},"created_at":"2015-09-02T10:26:37.000Z","updated_at":"2026-01-29T18:07:30.000Z","dependencies_parsed_at":"2023-02-13T09:05:11.500Z","dependency_job_id":"f570ad20-6479-4f68-89ea-cfe1cabdb857","html_url":"https://github.com/syntax-tree/unist-util-is","commit_stats":{"total_commits":116,"total_committers":5,"mean_commits":23.2,"dds":0.07758620689655171,"last_synced_commit":"02b0ca6abefff774c6c395069c75c4bf496dd4fb"},"previous_names":["wooorm/unist-util-is"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/unist-util-is","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-is","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-is/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-is/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-is/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/unist-util-is/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-util-is/sbom","scorecard":{"id":863522,"data":{"date":"2025-08-11","repo":{"name":"github.com/syntax-tree/unist-util-is","commit":"307d18895852b047f33e9f49285b2f75d771a085"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/bb.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-is/bb.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-is/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-is/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/unist-util-is/main.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:15","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/bb.yml:1","Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license:0","Info: FSF or OSI recognized license: MIT License: license:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/syntax-tree/.github/security.md:1","Info: Found linked content: github.com/syntax-tree/.github/security.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/syntax-tree/.github/security.md:1","Info: Found text in security policy: github.com/syntax-tree/.github/security.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T02:01:29.262Z","repository_id":52796447,"created_at":"2025-08-24T02:01:29.262Z","updated_at":"2025-08-24T02:01:29.262Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31284572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"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":["equal","equality","is","syntax-tree","unist","unist-util","util"],"created_at":"2024-08-03T00:01:11.943Z","updated_at":"2026-04-02T01:36:26.032Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# unist-util-is\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[unist][] utility to check if nodes pass a test.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`is(node[, test[, index, parent[, context]]])`](#isnode-test-index-parent-context)\n  * [`convert(test)`](#converttest)\n  * [`Check`](#check)\n  * [`Test`](#test)\n  * [`TestFunction`](#testfunction)\n* [Examples](#examples)\n  * [Example of `convert`](#example-of-convert)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Related](#related)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a small utility that checks that a node is a certain node.\n\n## When should I use this?\n\nUse this small utility if you find yourself repeating code for checking what\nnodes are.\n\nA similar package, [`hast-util-is-element`][hast-util-is-element], works on hast\nelements.\n\nFor more advanced tests, [`unist-util-select`][unist-util-select] can be used\nto match against CSS selectors.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install unist-util-is\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {is} from 'https://esm.sh/unist-util-is@6'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {is} from 'https://esm.sh/unist-util-is@6?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {is} from 'unist-util-is'\n\nconst node = {type: 'strong'}\nconst parent = {type: 'paragraph', children: [node]}\n\nis() // =\u003e false\nis({children: []}) // =\u003e false\nis(node) // =\u003e true\nis(node, 'strong') // =\u003e true\nis(node, 'emphasis') // =\u003e false\n\nis(node, node) // =\u003e true\nis(parent, {type: 'paragraph'}) // =\u003e true\nis(parent, {type: 'strong'}) // =\u003e false\n\nis(node, test) // =\u003e false\nis(node, test, 4, parent) // =\u003e false\nis(node, test, 5, parent) // =\u003e true\n\nfunction test(node, n) {\n  return n === 5\n}\n```\n\n## API\n\nThis package exports the identifiers [`convert`][api-convert] and\n[`is`][api-is].\nThere is no default export.\n\n### `is(node[, test[, index, parent[, context]]])`\n\nCheck if `node` is a `Node` and whether it passes the given test.\n\n###### Parameters\n\n* `node` (`unknown`, optional)\n  — thing to check, typically [`Node`][node]\n* `test` ([`Test`][api-test], optional)\n  — a test for a specific element\n* `index` (`number`, optional)\n  — the node’s position in its parent\n* `parent` ([`Node`][node], optional)\n  — the node’s parent\n* `context` (`unknown`, optional)\n  — context object (`this`) to call `test` with\n\n###### Returns\n\nWhether `node` is a [`Node`][node] and passes a test (`boolean`).\n\n###### Throws\n\nWhen an incorrect `test`, `index`, or `parent` is given.\nThere is no error thrown when `node` is not a node.\n\n### `convert(test)`\n\nGenerate a check from a test.\n\nUseful if you’re going to test many nodes, for example when creating a\nutility where something else passes a compatible test.\n\nThe created function is a bit faster because it expects valid input only:\na `node`, `index`, and `parent`.\n\n###### Parameters\n\n* `test` ([`Test`][api-test], optional)\n  — a test for a specific node\n\n###### Returns\n\nA check ([`Check`][api-check]).\n\n### `Check`\n\nCheck that an arbitrary value is a node (TypeScript type).\n\n###### Parameters\n\n* `this` (`unknown`, optional)\n  — context object (`this`) to call `test` with\n* `node` (`unknown`)\n  — anything (typically a node)\n* `index` (`number`, optional)\n  — the node’s position in its parent\n* `parent` ([`Node`][node], optional)\n  — the node’s parent\n\n###### Returns\n\nWhether this is a node and passes a test (`boolean`).\n\n### `Test`\n\nCheck for an arbitrary node (TypeScript type).\n\n###### Type\n\n```ts\ntype Test =\n  | Array\u003cRecord\u003cstring, unknown\u003e | TestFunction | string\u003e\n  | Record\u003cstring, unknown\u003e\n  | TestFunction\n  | string\n  | null\n  | undefined\n```\n\nChecks that the given thing is a node, and then:\n\n* when `string`, checks that the node has that tag name\n* when `function`, see  [`TestFunction`][api-test-function]\n* when `object`, checks that all keys in test are in node, and that they have\n  (strictly) equal values\n* when `Array`, checks if one of the subtests pass\n\n### `TestFunction`\n\nCheck if a node passes a test (TypeScript type).\n\n###### Parameters\n\n* `node` ([`Node`][node])\n  — a node\n* `index` (`number` or `undefined`)\n  — the node’s position in its parent\n* `parent` ([`Node`][node] or `undefined`)\n  — the node’s parent\n\n###### Returns\n\nWhether this node passes the test (`boolean`, optional).\n\n## Examples\n\n### Example of `convert`\n\n```js\nimport {u} from 'unist-builder'\nimport {convert} from 'unist-util-is'\n\nconst test = convert('leaf')\n\nconst tree = u('tree', [\n  u('node', [u('leaf', '1')]),\n  u('leaf', '2'),\n  u('node', [u('leaf', '3'), u('leaf', '4')]),\n  u('leaf', '5')\n])\n\nconst leafs = tree.children.filter(function (child, index) {\n  return test(child, index, tree)\n})\n\nconsole.log(leafs)\n```\n\nYields:\n\n```js\n[{type: 'leaf', value: '2'}, {type: 'leaf', value: '5'}]\n```\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types [`Check`][api-check],\n[`Test`][api-test],\n[`TestFunction`][api-test-function].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `unist-util-is@^6`,\ncompatible with Node.js 16.\n\n## Related\n\n* [`unist-util-find-after`](https://github.com/syntax-tree/unist-util-find-after)\n  — find a node after another node\n* [`unist-util-find-before`](https://github.com/syntax-tree/unist-util-find-before)\n  — find a node before another node\n* [`unist-util-find-all-after`](https://github.com/syntax-tree/unist-util-find-all-after)\n  — find all nodes after another node\n* [`unist-util-find-all-before`](https://github.com/syntax-tree/unist-util-find-all-before)\n  — find all nodes before another node\n* [`unist-util-find-all-between`](https://github.com/mrzmmr/unist-util-find-all-between)\n  — find all nodes between two nodes\n* [`unist-util-filter`](https://github.com/syntax-tree/unist-util-filter)\n  — create a new tree with nodes that pass a check\n* [`unist-util-remove`](https://github.com/syntax-tree/unist-util-remove)\n  — remove nodes from tree\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[api-check]: #check\n\n[api-convert]: #converttest\n\n[api-is]: #isnode-test-index-parent-context\n\n[api-test]: #test\n\n[api-test-function]: #testfunction\n\n[author]: https://wooorm.com\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[build]: https://github.com/syntax-tree/unist-util-is/actions\n\n[build-badge]: https://github.com/syntax-tree/unist-util-is/workflows/main/badge.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[collective]: https://opencollective.com/unified\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[coverage]: https://codecov.io/github/syntax-tree/unist-util-is\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-is.svg\n\n[downloads]: https://www.npmjs.com/package/unist-util-is\n\n[downloads-badge]: https://img.shields.io/npm/dm/unist-util-is.svg\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[hast-util-is-element]: https://github.com/syntax-tree/hast-util-is-element\n\n[health]: https://github.com/syntax-tree/.github\n\n[license]: license\n\n[node]: https://github.com/syntax-tree/unist#node\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[size]: https://bundlejs.com/?q=unist-util-is\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=unist-util-is\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[typescript]: https://www.typescriptlang.org\n\n[unist]: https://github.com/syntax-tree/unist\n\n[unist-util-select]: https://github.com/syntax-tree/unist-util-select\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified","https://thanks.dev/u/gh/syntax-tree"],"categories":["unist utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-util-is","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Funist-util-is","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-util-is/lists"}