{"id":13716560,"url":"https://github.com/syntax-tree/unist-builder","last_synced_at":"2025-06-29T22:03:53.621Z","repository":{"id":34894910,"uuid":"43240526","full_name":"syntax-tree/unist-builder","owner":"syntax-tree","description":"utility to create a new trees with a nice syntax","archived":false,"fork":false,"pushed_at":"2023-07-07T10:30:13.000Z","size":97,"stargazers_count":80,"open_issues_count":0,"forks_count":3,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-06-24T02:18:44.069Z","etag":null,"topics":["hyperscript","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},"funding":{"github":"unifiedjs","open_collective":"unified"}},"created_at":"2015-09-27T09:07:59.000Z","updated_at":"2025-05-23T16:49:04.000Z","dependencies_parsed_at":"2024-06-18T13:52:58.031Z","dependency_job_id":"e3068a2e-bcc4-4056-afee-9f7ab1f92607","html_url":"https://github.com/syntax-tree/unist-builder","commit_stats":{"total_commits":82,"total_committers":3,"mean_commits":"27.333333333333332","dds":"0.13414634146341464","last_synced_commit":"117b8e5078b9ebb8197a21181fb72aa27614920c"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/unist-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/unist-builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Funist-builder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262674946,"owners_count":23346741,"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":["hyperscript","syntax-tree","unist","unist-util","util"],"created_at":"2024-08-03T00:01:11.813Z","updated_at":"2025-06-29T22:03:53.583Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# unist-builder\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 create trees with ease.\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    *   [`u(type[, props][, children|value])`](#utype-props-childrenvalue)\n    *   [`ChildrenOrValue`](#childrenorvalue)\n    *   [`Props`](#props)\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 hyperscript interface (like `createElement` from React and\n`h` from Vue and such) to help with creating unist trees.\n\n## When should I use this?\n\nYou can use this utility in your project when you generate syntax trees with\ncode.\nIt helps because it replaces most of the repetition otherwise needed in a syntax\ntree with function calls.\n\nYou can instead use [`hastscript`][hastscript] or [`xastscript`][xastscript]\nwhen creating hast (HTML) or xast (XML) nodes.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install unist-builder\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {u} from 'https://esm.sh/unist-builder@4'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {u} from 'https://esm.sh/unist-builder@4?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {u} from 'unist-builder'\n\nconst tree = u('root', [\n  u('subtree', {id: 1}),\n  u('subtree', {id: 2}, [\n    u('node', [u('leaf', 'leaf 1'), u('leaf', 'leaf 2')]),\n    u('leaf', {id: 3}, 'leaf 3'),\n    u('void', {id: 4})\n  ])\n])\n\nconsole.dir(tree, {depth: undefined})\n```\n\n…yields:\n\n```js\n{\n  type: 'root',\n  children: [\n    {type: 'subtree', id: 1},\n    {\n      type: 'subtree',\n      id: 2,\n      children: [\n        {\n          type: 'node',\n          children: [\n            {type: 'leaf', value: 'leaf 1'},\n            {type: 'leaf', value: 'leaf 2'}\n          ]\n        },\n        {type: 'leaf', id: 3, value: 'leaf 3'},\n        {type: 'void', id: 4}\n      ]\n    }\n  ]\n}\n```\n\n## API\n\nThis package exports the identifier [`u`][u].\nThere is no default export.\n\n### `u(type[, props][, children|value])`\n\nBuild a node.\n\n###### Signatures\n\n*   `u(type[, props], children)` — create a parent ([`Parent`][parent])\n*   `u(type[, props], value)` — create a literal ([`Literal`][literal])\n*   `u(type[, props])` — create a void node (neither parent not literal)\n\n###### Parameters\n\n*   `type` (`string`)\n    — node type\n*   `props` (`Record\u003cstring, unknown\u003e`)\n    — fields assigned to node\n*   `children` ([`Array\u003cNode\u003e`][node])\n    — children of node\n*   `value` (`*`)\n    — value of `node` (cast to string)\n\n###### Returns\n\nBuilt node ([`Node`][node]).\n\n### `ChildrenOrValue`\n\nList to use as `children` or value to use as `value` (TypeScript type).\n\n###### Type\n\n```ts\ntype ChildrenOrValue = Array\u003cNode\u003e | string\n```\n\n### `Props`\n\nOther fields to add to the node (TypeScript type).\n\n###### Type\n\n```ts\nexport type Props = Record\u003cstring, unknown\u003e\n```\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types [`ChildrenOrValue`][childrenorvalue] and\n[`Props`][props].\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-builder@^4`,\ncompatible with Node.js 16.\n\n## Related\n\n*   [`hastscript`](https://github.com/syntax-tree/hastscript)\n    — create [hast][] trees\n*   [`xastscript`](https://github.com/syntax-tree/xastscript)\n    — create [xast][] 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] © Eugene Sharygin\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/syntax-tree/unist-builder/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/unist-builder/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-builder.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/unist-builder\n\n[downloads-badge]: https://img.shields.io/npm/dm/unist-builder.svg\n\n[downloads]: https://www.npmjs.com/package/unist-builder\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=unist-builder\n\n[size]: https://bundlejs.com/?q=unist-builder\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[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]: https://github.com/syntax-tree/unist\n\n[node]: https://github.com/syntax-tree/unist#node\n\n[parent]: https://github.com/syntax-tree/unist#parent\n\n[literal]: https://github.com/syntax-tree/unist#literal\n\n[hast]: https://github.com/syntax-tree/hast\n\n[xast]: https://github.com/syntax-tree/xast\n\n[hastscript]: https://github.com/syntax-tree/hastscript\n\n[xastscript]: https://github.com/syntax-tree/xastscript\n\n[u]: #utype-props-childrenvalue\n\n[props]: #props\n\n[childrenorvalue]: #childrenorvalue\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["unist utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Funist-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Funist-builder/lists"}