Skip to content

Latest commit

 

History

History
391 lines (295 loc) · 10.9 KB

chimp.md

File metadata and controls

391 lines (295 loc) · 10.9 KB

Constants

LEAF : Number

Type LEAF = 1

BRANCH : Number

Type BRANCH = 2

CLOSE : Number

Type CLOSE = 3

isLeafBoolean

Test if node is LEAF

isBranchBoolean

Test if node is BRANCH

isCloseBoolean

Test if node is CLOSE

isLastChildBoolean

Test if node is last child

isFirstChildBoolean

Test if node is first child

isEmptyBranchBoolean

Test if node is empty branch

linkObject | void

Retrieve the branch's closer, or the closer's branch

Functions

create([props], [type])Object

Create a leaf node (branches and closes are created by the implementation).

The following keys are reserved for formatting an object as a node:

Key Purpose
$0 Type
$1 Depth-first travsersal
$2 Reversed depth-first Traversal
$3 BRANCH-to-CLOSE link
next(node)Object | void

Get the node's next node in depth-first traversal

previous(node)Object | void

Get the node's previous node in depth-first traversal

nextSibling(node)Object | void

Get the node's nextSibling

previousSibling(node)Object | void

Get the node's previousSibling

traverse(node)

Traverse node

firstChild(node)Object | void

Get the node's firstChild

lastChild(node)Object | void

Get the node's lastChild

appendChild(node, ref)Object

append child to node (promotes LEAF to BRANCH if needed)

insertBefore(node, ref)Object

insert node before ref (sibling)

insertAfter(node, ref)Object

insert node after ref (sibling)

removeChild(node, ref)Object

remove child from node

remove(node)Object

remove node from its parent

openBefore(props, ref, [lastSib])Object

Create a new branch before a node and add all its siblings up to lastSibling

LEAF : Number

Type LEAF = 1

Kind: global constant

BRANCH : Number

Type BRANCH = 2

Kind: global constant

CLOSE : Number

Type CLOSE = 3

Kind: global constant

isLeaf ⇒ Boolean

Test if node is LEAF

Kind: global constant

Param Type Description
node Object Node-formatted object

isBranch ⇒ Boolean

Test if node is BRANCH

Kind: global constant

Param Type Description
node Object Node-formatted object

isClose ⇒ Boolean

Test if node is CLOSE

Kind: global constant

Param Type Description
node Object Node-formatted object

isLastChild ⇒ Boolean

Test if node is last child

Kind: global constant
Returns: Boolean - The inserted node

Param Type Description
node Object Node-formatted object

isFirstChild ⇒ Boolean

Test if node is first child

Kind: global constant
Returns: Boolean - The inserted node

Param Type Description
node Object Node-formatted object

isEmptyBranch ⇒ Boolean

Test if node is empty branch

Kind: global constant
Returns: Boolean - The inserted node

Param Type Description
node Object Node-formatted object

link ⇒ Object | void

Retrieve the branch's closer, or the closer's branch

Kind: global constant
Returns: Object | void - Node-formatted object (if any)

Param Type Description
node Object Node-formatted object

create([props], [type]) ⇒ Object

Create a leaf node (branches and closes are created by the implementation).

The following keys are reserved for formatting an object as a node:

Key Purpose
$0 Type
$1 Depth-first travsersal
$2 Reversed depth-first Traversal
$3 BRANCH-to-CLOSE link

Kind: global function
Returns: Object - node-formatted object

Param Type Default Description
[props] Object {} initial object
[type] Number LEAF node type

next(node) ⇒ Object | void

Get the node's next node in depth-first traversal

Kind: global function
Returns: Object | void - Node (if have)

Param Type Description
node Object Node-formatted object

previous(node) ⇒ Object | void

Get the node's previous node in depth-first traversal

Kind: global function
Returns: Object | void - Node (if have)

Param Type Description
node Object Node-formatted object

nextSibling(node) ⇒ Object | void

Get the node's nextSibling

Kind: global function
Returns: Object | void - Node (if have)

Param Type Description
node Object Node-formatted object

previousSibling(node) ⇒ Object | void

Get the node's previousSibling

Kind: global function
Returns: Object | void - Node (if have)

Param Type Description
node Object Node-formatted object

traverse(node)

Traverse node

Kind: global function

Param Type Description
node Object Node-formatted object

firstChild(node) ⇒ Object | void

Get the node's firstChild

Kind: global function
Returns: Object | void - Node (if have)

Param Type Description
node Object Node-formatted object

lastChild(node) ⇒ Object | void

Get the node's lastChild

Kind: global function
Returns: Object | void - Node (if have)

Param Type Description
node Object Node-formatted object

appendChild(node, ref) ⇒ Object

append child to node (promotes LEAF to BRANCH if needed)

Kind: global function
Returns: Object - The appended child

Param Type Description
node Object Node-formatted object
ref Object Node-formatted object

insertBefore(node, ref) ⇒ Object

insert node before ref (sibling)

Kind: global function
Returns: Object - The inserted node

Param Type Description
node Object Node-formatted object
ref Object Node-formatted object

insertAfter(node, ref) ⇒ Object

insert node after ref (sibling)

Kind: global function
Returns: Object - The inserted node

Param Type Description
node Object Node-formatted object
ref Object Node-formatted object

removeChild(node, ref) ⇒ Object

remove child from node

Kind: global function
Returns: Object - The provided branch node

Param Type Description
node Object Node-formatted object
ref Object Node-formatted object

remove(node) ⇒ Object

remove node from its parent

Kind: global function
Returns: Object - The removed node-formatted object (for reuse)

Param Type Description
node Object Node-formatted object

openBefore(props, ref, [lastSib]) ⇒ Object

Create a new branch before a node and add all its siblings up to lastSibling

Kind: global function
Returns: Object - The new branch

Param Type Description
props Object Initial object
ref Object Reference node
[lastSib] Object The last sibling to add to the branch