-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60e7976
commit 2c02eeb
Showing
8 changed files
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Node } from "../_namespaces/ts"; | ||
|
||
const nodeChildren = new WeakMap<Node, Node[] | undefined>(); | ||
|
||
/** @internal */ | ||
export function getNodeChildren(node: Node): Node[] | undefined { | ||
return nodeChildren.get(node); | ||
} | ||
|
||
/** @internal */ | ||
export function setNodeChildren(node: Node, children: Node[]) { | ||
nodeChildren.set(node, children); | ||
} | ||
|
||
/** @internal */ | ||
export function unsetNodeChildren(node: Node) { | ||
nodeChildren.delete(node); | ||
} | ||
|
||
/** @internal */ | ||
export function getOrSetNodeChildren(node: Node, fn: () => Node[]): Node[] { | ||
let children = getNodeChildren(node); | ||
if (children === undefined) { | ||
setNodeChildren(node, children = fn()); | ||
} | ||
return children; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters