deep
Source: quickjs-deep.c — module exports a function list, DeepIterator, and a default object.
Deep (recursive) traversal and manipulation of nested objects/arrays, addressing
nodes by a path (array of keys or a Pointer).
Module functions
| Function | Args | Description |
|---|---|---|
find(root, predicate) | 2 | Returns the first value (deeply) matching predicate. |
select(root, predicate) | 2 | Returns all values matching predicate. |
get(root, path) | 2 | Reads the value at path. |
set(root, path, value) | 3 | Writes value at path, creating intermediate nodes. |
unset(root, path) | 2 | Deletes the value at path. |
flatten(root) | 1 | Produces a flat map of path → value. |
pathOf(root, value) | 2 | Returns the path at which value occurs. |
equals(a, b) | 2 | Deep structural equality. |
iterate(root) | 1 | Returns a DeepIterator over all nodes. |
forEach(root, fn) | 2 | Invokes fn(value, path, root) for every node. |
clone(root) | 1 | Deep copy. |
DeepIterator
new DeepIterator(root[, ...]) // length 1| Member | Args | Kind | Description |
|---|---|---|---|
next() | 0 | method | Iterator step; yields [value, path]. |
return() | 0 | method | Ends iteration. |
leave() | 0 | method | Ascends out of the current subtree. |
skip() | 0 | method | Skips descending into the current node. |
path | — | getter | Path of the current node. |
[Symbol.iterator]() | 0 | method | Returns itself. |
Export list
Generated by utilities/doc-api.js from the deep dump of utilities/api-surface.sh: 102 members. Edit the text above this block, not the block.
Functions: clone(), equals(), find(), flatten(), forEach(), get(), iterate(), pathOf(), select(), set(), unset()
Values: FILTER_HAS_KEY = 1073741824, FILTER_KEY_OF = 0, FILTER_NEGATE = 2147483648, NO_RECURSE = 2, NO_THROW = 268435456, PATH_AS_ARRAY = 0, PATH_AS_POINTER = 134217728, PATH_AS_STRING = 67108864, RECURSE = 0, RETURN_PATH = 16777216, RETURN_PATH_VALUE = 50331648, RETURN_VALUE = 33554432, RETURN_VALUE_PATH = 0, TYPE_ALL = 4095, TYPE_ARRAY = 2048, TYPE_BIG_INT = 128, TYPE_BOOL = 4, TYPE_CATCH_OFFSET = 32768, TYPE_EXCEPTION = 65536, TYPE_FLOAT64 = 256, TYPE_FUNCTION = 1024, TYPE_FUNCTION_BYTECODE = 8192, TYPE_INT = 8, TYPE_MODULE = 4096, TYPE_NAN = 512, TYPE_NULL = 2, TYPE_NUMBER = 904, TYPE_OBJECT = 16, TYPE_PRIMITIVE = 1007, TYPE_STRING = 32, TYPE_SYMBOL = 64, TYPE_UNDEFINED = 1, TYPE_UNINITIALIZED = 16384, YIELD = 1, YIELD_NO_RECURSE = 3
DeepIterator
class, constructible
- methods:
leave(),next(),return(),skip(),[Symbol.iterator]() - properties:
path (get),[Symbol.toStringTag]
default
object
- static methods:
clone(),equals(),find(),flatten(),forEach(),get(),iterate(),pathOf(),select(),set(),unset() - static values:
FILTER_HAS_KEY = 1073741824,FILTER_KEY_OF = 0,FILTER_NEGATE = 2147483648,NO_RECURSE = 2,NO_THROW = 268435456,PATH_AS_ARRAY = 0,PATH_AS_POINTER = 134217728,PATH_AS_STRING = 67108864,RECURSE = 0,RETURN_PATH = 16777216,RETURN_PATH_VALUE = 50331648,RETURN_VALUE = 33554432,RETURN_VALUE_PATH = 0,TYPE_ALL = 4095,TYPE_ARRAY = 2048,TYPE_BIG_INT = 128,TYPE_BOOL = 4,TYPE_CATCH_OFFSET = 32768,TYPE_EXCEPTION = 65536,TYPE_FLOAT64 = 256,TYPE_FUNCTION = 1024,TYPE_FUNCTION_BYTECODE = 8192,TYPE_INT = 8,TYPE_MODULE = 4096,TYPE_NAN = 512,TYPE_NULL = 2,TYPE_NUMBER = 904,TYPE_OBJECT = 16,TYPE_PRIMITIVE = 1007,TYPE_STRING = 32,TYPE_SYMBOL = 64,TYPE_UNDEFINED = 1,TYPE_UNINITIALIZED = 16384,YIELD = 1,YIELD_NO_RECURSE = 3