UNPKG

@mojule/tree-factory

Version:

Takes an adapter/plugins and generates a consistent API over arbitrary tree-like data

16 lines (13 loc) 428 B
'use strict'; var createRootPlugin = function createRootPlugin(api) { return { $createRootState: function $createRootState(rawNode) { if (!api.isNode(rawNode)) throw new Error('Expected a raw node'); return { node: rawNode, root: rawNode, parent: null }; }, $createRoot: function $createRoot(rawNode) { return api(api.createRootState(rawNode)); } }; }; module.exports = createRootPlugin;