Skip to content

Commit

Permalink
Add mention in docs for previous (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Aug 23, 2020
1 parent 1568214 commit d33cc44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/05_content_nodes.md
Expand Up @@ -167,7 +167,7 @@ String(doc)

#### `YAML.Document#createNode(value, options?): Node`

To create a new node, use the `createNode(value, options?)` document method. This will recursively wrap any input with appropriate `Node` containers. Generic objects as well as `Map` and its descendants become mappings, while arrays and other iterable objects result in sequences.
To create a new node, use the `createNode(value, options?)` document method. This will recursively wrap any input with appropriate `Node` containers. Generic JS `Object` values as well as `Map` and its descendants become mappings, while arrays and other iterable objects result in sequences. With `Object`, entries that have an `undefined` value are dropped.

To specify the collection type, set `options.tag` to its identifying string, e.g. `"!!omap"`. Note that this requires the corresponding tag to be available in the document's schema. If `options.wrapScalars` is undefined or `true`, plain values are wrapped in `Scalar` objects.

Expand Down
8 changes: 7 additions & 1 deletion tests/doc/stringify.js
Expand Up @@ -727,7 +727,13 @@ describe('undefined values', () => {

test("{ a: 'A', b: undefined, c: 'C' }", () => {
expect(YAML.stringify({ a: 'A', b: undefined, c: 'C' })).toBe(
'a: A\nc: C\n'
'a: A\nc: C\n' // note: No `b` key
)
})

test("{ a: 'A', b: null, c: 'C' }", () => {
expect(YAML.stringify({ a: 'A', b: null, c: 'C' })).toBe(
'a: A\nb: null\nc: C\n'
)
})

Expand Down

0 comments on commit d33cc44

Please sign in to comment.