UNPKG

@platform/state

Version:

A small, simple, strongly typed, [rx/observable] state-machine.

41 lines (40 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.helpers = void 0; var TreeIdentity_1 = require("../TreeIdentity"); var TreeQuery_1 = require("../TreeQuery"); var query = TreeQuery_1.TreeQuery.create; var id = TreeIdentity_1.TreeIdentity; exports.helpers = { id: id, isInstance: function (input) { return input === null || typeof input !== 'object' ? false : input._kind === 'TreeState'; }, props: function (of, fn) { of.props = of.props || {}; if (typeof fn === 'function') { fn(of.props); } return of.props; }, children: function (of, fn) { var children = (of.children = of.children || []); if (typeof fn === 'function') { fn(children); } return of.children; }, ensureNamespace: function (root, namespace) { query(root).walkDown(function (e) { if (!id.hasNamespace(e.node.id)) { e.node.id = id.format(namespace, e.node.id); } else { var res = id.parse(e.node.id); if (res.namespace !== namespace) { e.skip(); } } }); }, };