[lexical-utils] Documentation Update: describe $reverseDfs instead of $reverseDfsIterator - #8962
Merged
Merged
Conversation
… $reverseDfsIterator ## Description `$reverseDfs` carried the JSDoc of `$reverseDfsIterator` verbatim, so it called itself an iterator, claimed traversal happens on the fly with O(1) memory, and documented `@returns` as an iterator. It returns `DFSNode[]` built by `Array.from`, exactly like `$dfs`, whose doc already says so. Also added the two notes `$dfs` and `$dfsIterator` carry and that apply here: the children-only spine with the pointer to `$reverseDfsWithSlots`, and that an ElementNode endNode stops before its children. No behavior change. ## Test plan ### Before "@returns An iterator, each yielded value is a DFSNode" on a function returning DFSNode[]. ### After Wording follows $dfs. prettier and tsc clean, lexical-utils unit suite 225 passing.
luantaraschi
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 7, 2026 18:38
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Aug 7, 2026
Merged
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
$reverseDfscarries the JSDoc block of$reverseDfsIterator, copied word for word, so three of its statements describe a different function.It is not an iterator, it returns
DFSNode[]. Traversal is not done on the fly,Array.fromruns it to completion before returning. Memory is not O(1) for the same reason. The@returnsline then tells the reader to expect an iterator.$dfsis the same shape,Array.fromover its iterator, and its doc gets this right: "It will then return all the nodes found in the search in an array of objects".$reverseDfsnow says the same thing.Two things were also missing that both
$dfsand$dfsIteratordocument and that apply here equally:$reverseDfsWithSlots, which exists and is the slot-aware counterpartElementNodepassed asendNodestops the traversal before its childrenNo behavior change, and the wording follows
$dfsso the pair reads consistently.Test plan
Before
After
pnpm run prettierandpnpm run tscare clean. Thelexical-utilsunit suite passes, 225 tests across 15 files.