UNPKG

mobx-keystone-mindreframer

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) 775 B
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 || !options.deep) { return getObjectChildren(node) } else { return getDeepObjectChildren(node).deep } }