mtype-node
v0.1.8
Published
Object factory with schema validation for default tree nodes used by mojule
Downloads
4
Readme
mtype-node
Object factory with schema validation for this default tree nodes (entityNodes) used in mojule
Refer to :
Dependencies
Project json schema for mojule entityNode structure.
- emptyNode.schema.json
- entityNode.schema.json
- entityNodeValue.schema.json
- parentNode.schema.json
Usage
const EntityNode = require( 'mtype-node' )
// Factory returns instance of EntityNode
const sampleNode = EntityNode('someNodeType')
console.log( JSON.stringify( sampleNode ) ) // {"value":{"nodeType":"someNodeType","_id":"somenodetype-293c865aaf08ee5ab23eb335e9236908"},"children":[]}
// Value factory returns instance of EntityNodeValue
const sampleNodeValue = EntityNode.Value('someNodeType')
console.log( JSON.stringify( sampleNodeValue ) ) // {"nodeType":"someNodeType","_id":"somenodetype-5a336a3c20029b79898900cae8700d75"}
// Reference underlying instance of mtype
const mtype = EntityNode.mtype
console.log( types ) //[ 'entityNode', 'entityNodeValue', 'emptyNode', 'parentNode' ]