{"id":13717132,"url":"https://github.com/syntax-tree/nlcst-test","last_synced_at":"2025-07-12T07:37:59.787Z","repository":{"id":21609245,"uuid":"24929541","full_name":"syntax-tree/nlcst-test","owner":"syntax-tree","description":"utility to check assert an nlcst node","archived":false,"fork":false,"pushed_at":"2023-07-17T13:19:03.000Z","size":105,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-11T21:34:55.533Z","etag":null,"topics":["assert","nlcst","nlcst-util","syntax-tree","test","unist","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":{"funding":{"github":"unifiedjs","open_collective":"unified"},"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}},"created_at":"2014-10-08T07:33:09.000Z","updated_at":"2022-05-28T14:10:59.000Z","dependencies_parsed_at":"2024-01-14T22:03:42.279Z","dependency_job_id":"3975ffad-66c3-48d2-9f17-ea0638b386e8","html_url":"https://github.com/syntax-tree/nlcst-test","commit_stats":{"total_commits":87,"total_committers":1,"mean_commits":87.0,"dds":0.0,"last_synced_commit":"961584cf340f6a3781c6000a7ee958e6d8ad9bd9"},"previous_names":["wooorm/nlcst-test"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fnlcst-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fnlcst-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fnlcst-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fnlcst-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/nlcst-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252826899,"owners_count":21810201,"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":["assert","nlcst","nlcst-util","syntax-tree","test","unist","util"],"created_at":"2024-08-03T00:01:18.306Z","updated_at":"2025-05-07T06:31:55.160Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# nlcst-test\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[nlcst][] utility to assert trees.\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    *   [`assert(tree[, parent])`](#asserttree-parent)\n    *   [`parent(tree[, parent])`](#parenttree-parent)\n    *   [`literal(node[, parent])`](#literalnode-parent)\n    *   [`_void(node[, parent])`](#_voidnode-parent)\n    *   [`wrap(fn)`](#wrapfn)\n    *   [`AssertionError`](#assertionerror)\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 tiny utility that helps you deal with nodes.\n\n## When should I use this?\n\nThis utility is typically useful when you expect certain nodes in your APIs\nand want to make sure they’re valid and as expected.\n\nA different utility, [`unist-util-assert`][unist-util-assert], does the same but\nfor any [unist][] node.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install nlcst-test\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {assert} from 'https://esm.sh/nlcst-test@4'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {assert} from 'https://esm.sh/nlcst-test@4?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {assert} from 'nlcst-test'\n\nassert({type: 'RootNode', children: []})\nassert({type: 'SourceNode', value: 'fn()'})\nassert({type: 'WordNode', children: [{type: 'TextNode', value: 'Hi'}]})\n// All OK.\n\nassert({children: []})\n// AssertionError: node should have a type: `{ children: [] }`\n\nassert({type: 'WordNode', value: 'foo'})\n// AssertionError: parent should have children: `{ type: 'WordNode', value: 'foo' }`\n```\n\n## API\n\nThis package exports the identifiers [`_void`][api-void],\n[`assert`][api-assert],\n[`literal`][api-literal],\n[`parent`][api-parent], and\n[`wrap`][api-wrap].\nThere is no default export.\n\n### `assert(tree[, parent])`\n\nAssert that `tree` is a valid nlcst [`Node`][node].\n\nIf `tree` is a parent, all children will be asserted too.\n\nSupports unknown nlcst nodes.\n\n###### Parameters\n\n*   `tree` (`unknown`)\n    — thing to assert\n*   `parent` ([`Parent`][parent-node], optional)\n    — optional, valid parent\n\n###### Returns\n\nNothing.\n\n###### Throws\n\nWhen `tree` (or its descendants) is not an nlcst node\n([`AssertionError`][api-assertion-error]).\n\n### `parent(tree[, parent])`\n\nAssert that `tree` is a valid nlcst [`Parent`][parent-node].\n\nAll children will be asserted too.\n\nSupports unknown nlcst nodes.\n\n###### Parameters\n\n*   `tree` (`unknown`)\n    — thing to assert\n*   `parent` ([`Parent`][parent-node], optional)\n    — optional, valid parent\n\n###### Returns\n\nNothing.\n\n###### Throws\n\nWhen `tree` is not a parent or its descendants are not nodes\n([`AssertionError`][api-assertion-error])\n\n### `literal(node[, parent])`\n\nAssert that `node` is a valid nlcst [`Literal`][literal-node].\n\nSupports unknown nlcst nodes.\n\n###### Parameters\n\n*   `node` (`unknown`)\n    — thing to assert\n*   `parent` ([`Parent`][parent-node], optional)\n    — optional, valid parent\n\n###### Returns\n\nNothing.\n\n###### Throws\n\nWhen `node` is not an nlcst literal ([`AssertionError`][api-assertion-error]).\n\n### `_void(node[, parent])`\n\nRe-exported from [`unist-util-assert`][unist-util-assert-void].\n\n### `wrap(fn)`\n\nRe-exported from [`unist-util-assert`][unist-util-assert-wrap].\n\n### `AssertionError`\n\nRe-exported from [`unist-util-assert`][unist-util-assert-assertion-error].\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`AssertionError`][api-assertion-error].\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, `nlcst-test@^4`,\ncompatible with Node.js 16.\n\n## Related\n\n*   [`unist-util-assert`](https://github.com/syntax-tree/unist-util-assert)\n    — assert unist trees\n*   [`mdast-util-assert`](https://github.com/syntax-tree/mdast-util-assert)\n    — assert mdast trees\n*   [`hast-util-assert`](https://github.com/syntax-tree/hast-util-assert)\n    — assert hast trees\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[build-badge]: https://github.com/syntax-tree/nlcst-test/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/nlcst-test/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/nlcst-test.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/nlcst-test\n\n[downloads-badge]: https://img.shields.io/npm/dm/nlcst-test.svg\n\n[downloads]: https://www.npmjs.com/package/nlcst-test\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=nlcst-test\n\n[size]: https://bundlejs.com/?q=nlcst-test\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[unist-util-assert]: https://github.com/syntax-tree/unist-util-assert\n\n[unist]: https://github.com/syntax-tree/unist\n\n[node]: https://github.com/syntax-tree/unist#nodes\n\n[parent-node]: https://github.com/syntax-tree/unist#parent-1\n\n[literal-node]: https://github.com/syntax-tree/unist#literal\n\n[nlcst]: https://github.com/syntax-tree/nlcst\n\n[api-assert]: #asserttree-parent\n\n[api-literal]: #literalnode-parent\n\n[api-parent]: #parenttree-parent\n\n[api-void]: #_voidnode-parent\n\n[api-wrap]: #wrapfn\n\n[api-assertion-error]: #assertionerror\n\n[unist-util-assert-void]: https://github.com/syntax-tree/unist-util-assert#_voidnode-parent\n\n[unist-util-assert-wrap]: https://github.com/syntax-tree/unist-util-assert#wrapfn\n\n[unist-util-assert-assertion-error]: https://github.com/syntax-tree/unist-util-assert#assertionerror\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["nlcst utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fnlcst-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fnlcst-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fnlcst-test/lists"}