Skip to content

Commit

Permalink
feat: Add export of createNode() & createPair() to yaml/util (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Apr 4, 2023
1 parent 26fa994 commit 6cfd2fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/06_custom_tags.md
Expand Up @@ -99,7 +99,7 @@ stringify(

In YAML-speak, a custom data type is represented by a _tag_. To define your own tag, you need to account for the ways that your data is both parsed and stringified. Furthermore, both of those processes are split into two stages by the intermediate AST node structure.

If you wish to implement your own custom tags, the [`!!binary`](https://github.com/eemeli/yaml/blob/main/src/tags/yaml-1.1/binary.js) and [`!!set`](https://github.com/eemeli/yaml/blob/main/src/tags/yaml-1.1/set.js) tags provide relatively cohesive examples to study in addition to the simple examples in the sidebar here.
If you wish to implement your own custom tags, the [`!!binary`](https://github.com/eemeli/yaml/blob/main/src/schema/yaml-1.1/binary.ts) and [`!!set`](https://github.com/eemeli/yaml/blob/main/src/schema/yaml-1.1/set.ts) tags provide relatively cohesive examples to study in addition to the simple examples in the sidebar here.

### Parsing Custom Data

Expand Down Expand Up @@ -135,6 +135,8 @@ For collections in particular, the default stringifier should be perfectly suffi

```js
import {
createNode, // (value, tagName, ctx) => Node -- Create a new node
createPair, // (key, value, ctx) => Pair -- Create a new pair
debug, // (logLevel, ...messages) => void -- Log debug messages to console
findPair, // (items, key) => Pair? -- Given a key, find a matching Pair
foldFlowLines, // (text, indent, mode, options) => string -- Fold long lines
Expand Down
2 changes: 2 additions & 0 deletions src/util.ts
@@ -1,4 +1,6 @@
export { createNode, CreateNodeContext } from './doc/createNode.js'
export { debug, LogLevelId, warn } from './log.js'
export { createPair } from './nodes/Pair.js'
export { findPair } from './nodes/YAMLMap.js'
export { toJS, ToJSContext } from './nodes/toJS.js'
export { map as mapTag } from './schema/common/map.js'
Expand Down

0 comments on commit 6cfd2fa

Please sign in to comment.