Skip to content

Commit

Permalink
Make defaultListPrefix() a generator
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Nov 4, 2024
1 parent d98bdca commit 5070c85
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ for await (const dependency of traverse(new URL('file:///directory/file.js'), re

#### `const dependencies = traverse(url[, options], readModule[, listPrefix])`

Traverse the module graph rooted at `url`, which must be a WHATWG `URL` instance. `readModule` is called with a `URL` instance for every module to be read and must either return the module source, if it exists, or `null`. `listPrefix` is called with a `URL` instance of every prefix to be listed and must return a list of `URL` instances that have the specified `URL` as a prefix. If not provided, prefixes won't be traversed. If `readModule` returns a promise or `listPrefix` returns a promise generator, synchronous iteration is not supported.
Traverse the module graph rooted at `url`, which must be a WHATWG `URL` instance. `readModule` is called with a `URL` instance for every module to be read and must either return the module source, if it exists, or `null`. `listPrefix` is called with a `URL` instance of every prefix to be listed and must yield `URL` instances that have the specified `URL` as a prefix. If not provided, prefixes won't be traversed. If `readModule` returns a promise or `listPrefix` returns a promise generator, synchronous iteration is not supported.

Options include:

Expand Down
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ module.exports = exports = function traverse (entry, opts, readModule, listPrefi
}
}

function defaultListPrefix () {
return []
}
function * defaultListPrefix () {}

function addURL (array, url) {
let lo = 0
Expand Down

0 comments on commit 5070c85

Please sign in to comment.