forEachNode typing not quite correct
lordnox opened this issue · comments
Tobias K commented
As the forEachNode loop will stop when returning true
Lines 520 to 524 in b5e768a
The typing of forEachNode should be amended:
/** To stop the iteration return true in the callback */
forEachNode: (callbackPerNode: (node: Node<NodeData>) => void | undefined | null | boolean) => void
This would allow the use of the function as described in the readme:
g.forEachNode(function(node){
console.log(node.id, node.data);
});
Typescript will fail here as the return value is undefined
and not boolean
Andrei Kashcha commented
Tobias, thank you for noticing it and fixing it!
Your fix should be available starting from v19.0.1