Skip to main content

Module patch

Module patch 

Source
Expand description

Editing Yog Data text in place: patch changes a document to hold a new value and keeps everything that didn’t change as it was — comments, key order, number spelling, layout. What changed is written by [format], the way Yog’s editors write a value.

Functions§

format
value as Yog’s editors write it at indent level (two spaces each): short lists of numbers and short objects of scalars on one line ("uv": [0, 0, 16, 16]), the rest one entry a line.
patch
text changed to hold next, the rest as it was. Maps and lists are edited entry by entry (a kept entry keeps the comments before it; a removed one takes them along). Text that doesn’t parse is written anew.
same
Whether two values are the same, a number however it’s spelled (1 = 1.0).
to_json
value as compact JSON for a tool: maps in their order, strings as the source has them (a typed value’s text unread).