unist-builder

WebJar for unist-builder

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

unist-builder
Last Version

Last Version

2.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

unist-builder
WebJar for unist-builder
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/syntax-tree/unist-builder

Download unist-builder

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/unist-builder/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>unist-builder</artifactId>
    <version>2.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/unist-builder/
implementation 'org.webjars.npm:unist-builder:2.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/unist-builder/
implementation ("org.webjars.npm:unist-builder:2.0.3")
'org.webjars.npm:unist-builder:jar:2.0.3'
<dependency org="org.webjars.npm" name="unist-builder" rev="2.0.3">
  <artifact name="unist-builder" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='unist-builder', version='2.0.3')
)
libraryDependencies += "org.webjars.npm" % "unist-builder" % "2.0.3"
[org.webjars.npm/unist-builder "2.0.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

unist-builder

Build Coverage Downloads Size Sponsors Backers Chat

unist utility to create a new trees with hyperscript-like syntax.

Install

npm:

npm install unist-builder

Use

var u = require('unist-builder')

var tree = u('root', [
  u('subtree', {id: 1}),
  u('subtree', {id: 2}, [
    u('node', [u('leaf', 'leaf 1'), u('leaf', 'leaf 2')]),
    u('leaf', {id: 3}, 'leaf 3'),
    u('void', {id: 4})
  ])
])

console.dir(tree, {depth: null})

results in the following tree:

{
  type: 'root',
  children: [
    {type: 'subtree', id: 1},
    {
      type: 'subtree',
      id: 2,
      children: [
        {
          type: 'node',
          children: [
            {type: 'leaf', value: 'leaf 1'},
            {type: 'leaf', value: 'leaf 2'}
          ]
        },
        {type: 'leaf', id: 3, value: 'leaf 3'},
        {type: 'void', id: 4}
      ]
    }
  ]
}

API

u(type[, props][, children|value])

Creates a node from props, children, and optionally value.

Signatures
  • u(type[, props], children) — create a parent
  • u(type[, props], value) — create a literal
  • u(type[, props]) — create a void node
Parameters
  • type (string) — node type
  • props (Object) — other values assigned to node
  • children (Array.<Node>) — children of node
  • value (*) — value of node (cast to string)
Returns

Node.

Related

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Eugene Sharygin

org.webjars.npm
🌲🌲🌲🌳🌲🌳🌲🌲🌲🌳🌳🌲🌲🌳🌲🌲🎄🌲🌳🌲🌲🌳🐻🌳🌳🌳🌲🌲🌳🌲🎄🌲🌳🌲🌲🌳🌳🌳

Versions

Version
2.0.3
1.0.4