mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Add missing/undocumented functions (#27464)
Those functions and properties are not documented.
This commit is contained in:
Vendored
+20
@@ -121,6 +121,11 @@ declare namespace traverse {
|
||||
*/
|
||||
parent: TraverseContext | undefined;
|
||||
|
||||
/**
|
||||
* The contexts of the node's parents.
|
||||
*/
|
||||
parents: TraverseContext[];
|
||||
|
||||
/**
|
||||
* The name of the key of the present node in its parent.
|
||||
* This is `undefined` for the root node.
|
||||
@@ -172,6 +177,11 @@ declare namespace traverse {
|
||||
*/
|
||||
delete(stopHere?: boolean): void;
|
||||
|
||||
/**
|
||||
* Object keys of the node.
|
||||
*/
|
||||
keys: string[] | null;
|
||||
|
||||
/**
|
||||
* Call this function before all of the children are traversed.
|
||||
* You can assign into `this.keys` here to traverse in a custom order.
|
||||
@@ -192,6 +202,16 @@ declare namespace traverse {
|
||||
* Call this function after each of the children are traversed.
|
||||
*/
|
||||
post(callback: (this: TraverseContext, child: any) => void): void;
|
||||
|
||||
/**
|
||||
* Stops traversal entirely.
|
||||
*/
|
||||
stop(): void;
|
||||
|
||||
/**
|
||||
* Prevents traversing descendents of the current node.
|
||||
*/
|
||||
block(): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,3 +62,17 @@ function testPaths(){
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function testPropsAndFuncs(){
|
||||
var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ];
|
||||
|
||||
traverse(obj).forEach(function (x) {
|
||||
console.log(this.keys);
|
||||
console.log(this.parents);
|
||||
|
||||
if (this.level == 2) this.block();
|
||||
if (this.level > 10) this.stop();
|
||||
});
|
||||
|
||||
console.dir(obj);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user