mobx-keystone
Version:
A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more
26 lines (23 loc) • 788 B
text/typescript
import { assertTweakedObject } from "../tweaker/core"
import { getDeepObjectChildren, getObjectChildren } from "./coreObjectChildren"
/**
* Returns all the children objects (this is, excluding primitives) of an object.
*
* @param node Object to get the list of children from.
* @param [options] An optional object with the `deep` option (defaults to false) to true to get
* the children deeply or false to get them shallowly.
* @returns A readonly observable set with the children.
*/
export function getChildrenObjects(
node: object,
options?: {
deep?: boolean
}
): ReadonlySet<object> {
assertTweakedObject(node, "node")
if (options?.deep) {
return getDeepObjectChildren(node).deep
} else {
return getObjectChildren(node)
}
}