Skip to content

Obj

Base object.

  1. have unique id
  2. have parent and children
  3. can be serialized (store and copy-paste)
  4. can be traversed

Extended by

Constructors

new Obj()

new Obj(): Obj

Returns

Obj

Source

core/obj.ts:16

Properties

children

children: Obj[]

Source

core/obj.ts:14


id

id: string

Source

core/obj.ts:11


parent

parent: null | Obj

Source

core/obj.ts:13


type

type: string

Source

core/obj.ts:12

Methods

find()

find(pred): null | Obj

Find an shape in breath-first order

Parameters

pred

Returns

null | Obj

Source

core/obj.ts:106


findDepthFirst()

findDepthFirst(pred): null | Obj

Find an shape in depth-first order

Parameters

pred

Returns

null | Obj

Source

core/obj.ts:119


findParent()

findParent(pred): null | Obj

Find a shape along with the parent-chain

Parameters

pred

Returns

null | Obj

Source

core/obj.ts:132


fromJSON()

fromJSON(json): void

Parameters

json: any

Returns

void

Source

core/obj.ts:37


isDescendant()

isDescendant(obj): boolean

Test whether the given shape is a descendant

Parameters

obj: Obj

Returns

boolean

Source

core/obj.ts:142


resolveRefs()

resolveRefs(idMap, nullIfNotFound): void

Resolve references

Parameters

idMap: Record<string, Obj>

id to object map

nullIfNotFound: boolean= false

assign null if not found

Returns

void

Source

core/obj.ts:47


toJSON()

toJSON(recursive, keepRefs): any

Parameters

recursive: boolean= false

keepRefs: boolean= false

Returns

any

Source

core/obj.ts:23


traverse()

traverse(fun, parent): void

Traverse all objects in breath-first order

Parameters

fun

parent: null | Obj= null

Returns

void

Source

core/obj.ts:60


traverseDepthFirst()

traverseDepthFirst(fun, parent): void

Traverse all shapes in depth-first order

Parameters

fun

parent: null | Obj= null

Returns

void

Source

core/obj.ts:74


traverseDepthFirstSequence()

traverseDepthFirstSequence(): Obj[]

Returns an array of shapes in order of traverse sequence.

Returns

Obj[]

Source

core/obj.ts:97


traverseSequence()

traverseSequence(): Obj[]

Returns an array of shapes in order of traverse sequence.

Returns

Obj[]

Source

core/obj.ts:88