NodeChildren
@types IPublicModelNodeChildren
> @since v1.0.0
Overview
Node children model
Properties
owner
Returns the node instance that owns this children instance
@type {IPublicModelNode | null}
Related types: IPublicModelNode
size
Number of node instances in children
@type {number}
isEmptyNode
Whether children is empty
@type {boolean}
@since v1.1.0
Before v1.1.0, use
isEmpty
notEmptyNode
Whether children is not empty
@type {boolean}
@since v1.1.0
Methods
delete
Delete the specified node
/**
* Delete the specified node
* delete the node
* @param node
*/
delete(node: IPublicModelNode): boolean;
Related types: IPublicModelNode
insert
Insert a node
/**
* Insert a node
* insert the node
* @param node
*/
insert(node: IPublicModelNode): boolean;
Related types: IPublicModelNode
indexOf
Return the index of the specified node
/**
* Return the index of the specified node
* get index of node in current children
* @param node
* @returns
*/
indexOf(node: IPublicModelNode): number;
Related types: IPublicModelNode
splice
Similar to Array.prototype.splice
/**
* Similar to Array.splice
* provide the same function with {Array.prototype.splice}
* @param start
* @param deleteCount
* @param node
*/
splice(start: number, deleteCount: number, node?: IPublicModelNode): any;
Related types: IPublicModelNode
get
Return the node at the specified index
/**
* Return the node at the specified index
* get node with index
* @param index
* @returns
*/
get(index: number): IPublicModelNode | null;
Related types: IPublicModelNode
has
Whether children contains the specified node
/**
* Whether it contains the specified node
* check if node exists in current children
* @param node
* @returns
*/
has(node: IPublicModelNode): boolean;
Related types: IPublicModelNode
forEach
Similar to Array.prototype.forEach
/**
* Similar to Array.forEach
* provide the same function with {Array.prototype.forEach}
* @param fn
*/
forEach(fn: (node: IPublicModelNode, index: number) => void): void;
Related types: IPublicModelNode
reverse
Similar to Array.prototype.reverse
/**
* Similar to Array.reverse
* provide the same function with {Array.prototype.reverse}
*/
reverse(): IPublicModelNode[];
Related types: IPublicModelNode
map
Similar to Array.prototype.map
/**
* Similar to Array.map
* provide the same function with {Array.prototype.map}
* @param fn
*/
map<T>(fn: (node: IPublicModelNode, index: number) => T[]): any[] | null;
Related types: IPublicModelNode
every
Similar to Array.prototype.every
/**
* Similar to Array.every
* provide the same function with {Array.prototype.every}
* @param fn
*/
every(fn: (node: IPublicModelNode, index: number) => boolean): boolean;
Related types: IPublicModelNode
some
Similar to Array.prototype.some
/**
* Similar to Array.some
* provide the same function with {Array.prototype.some}
* @param fn
*/
some(fn: (node: IPublicModelNode, index: number) => boolean): boolean;
Related types: IPublicModelNode
filter
Similar to Array.prototype.filter
/**
* Similar to Array.filter
* provide the same function with {Array.prototype.filter}
* @param fn
*/
filter(fn: (node: IPublicModelNode, index: number) => boolean): any;
Related types: IPublicModelNode
find
Similar to Array.prototype.find
/**
* Similar to Array.find
* provide the same function with {Array.prototype.find}
* @param fn
*/
find(fn: (node: IPublicModelNode, index: number) => boolean): IPublicModelNode | null;
Related types: IPublicModelNode
reduce
Similar to Array.prototype.reduce
/**
* Similar to Array.reduce
* provide the same function with {Array.prototype.reduce}
* @param fn
*/
reduce(fn: (acc: any, cur: IPublicModelNode) => any, initialValue: any): void;
Related types: IPublicModelNode
importSchema
Import schema
/**
* Import schema
* import schema
* @param data
*/
importSchema(data?: IPublicTypeNodeData | IPublicTypeNodeData[]): void;
Related types: IPublicTypeNodeData
exportSchema
Export schema
/**
* Export schema
* export schema
* @param stage
*/
exportSchema(stage: IPublicEnumTransformStage): IPublicTypeNodeSchema;
Related types:
mergeChildren
Perform add, remove, sort, and other operations
/**
* Perform add, remove, sort, and related operations
* excute remove/add/sort operations
* @param remover
* @param adder
* @param sorter
*/
mergeChildren(
remover: (node: IPublicModelNode, idx: number) => boolean,
adder: (children: IPublicModelNode[]) => IPublicTypeNodeData[] | null,
sorter: (firstNode: IPublicModelNode, secondNode: IPublicModelNode) => number
): any;
Related types: