Registry / serialization / unist-util-find-all-after

unist-util-find-all-after

JSON →
library5.0.0jsnpmunverified

unist-util-find-all-after is a utility from the unified collective designed to locate all unist (Universal Syntax Tree) nodes that appear after a specified child node or index within a parent node. Its current stable version is 5.0.0, which requires Node.js 16 or higher and is ESM-only. The unified collective typically ties major releases to Node.js LTS cycles, providing stable maintenance. This package differentiates itself as a highly focused, lightweight utility for tree traversal, intended for integration within the broader unified ecosystem, offering a small, composable piece of functionality rather than a comprehensive tree manipulation library. It's fully typed with TypeScript and works alongside other `unist-util-*` packages like `unist-util-is` for node testing.

npm install unist-util-find-all-after
INSTALL
IMPORT
SIG · UNIST-UTIL-FIND-AL
U
unist-util-find-all-after
serializationjavascriptv5.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

findAllAfter
import { findAllAfter } from 'unist-util-find-all-after'
const findAllAfter = require('unist-util-find-all-after')
This package is ESM-only since v4.0.0 and requires Node.js 16+ since v5.0.0. There is no default export; always use named imports. For browser usage via esm.sh, you can import from `https://esm.sh/unist-util-find-all-after@5`.

Demonstrates how to import and use `findAllAfter` to find specific 'leaf' nodes occurring after a given index within a unist tree structure, using `unist-builder` to construct the tree.

import { u } from 'unist-builder'; import { findAllAfter } from 'unist-util-find-all-after'; const tree = u('tree', [ u('leaf', 'leaf 1'), u('parent', [u('leaf', 'leaf 2'), u('leaf', 'leaf 3')]), u('leaf', 'leaf 4'), u('parent', [u('leaf', 'leaf 5')]), u('leaf', 'leaf 6'), u('empty'), u('leaf', 'leaf 7') ]); // Find all 'leaf' nodes after the node at index 1 (which is a 'parent' node) const result = findAllAfter(tree, 1, 'leaf'); console.log(JSON.stringify(result, null, 2)); /* Expected output: [ { "type": "leaf", "value": "leaf 4" }, { "type": "leaf", "value": "leaf 6" }, { "type": "leaf", "value": "leaf 7" } ] */
Debug
Known issues
breakingVersion 5.0.0 changed to require Node.js 16 or higher. Older Node.js versions are no longer supported, impacting runtime compatibility.
fix
Upgrade your Node.js environment to version 16 or later to ensure compatibility and access to the latest features.
affects: >=5.0.0
breakingSince version 4.0.0, the package is ESM-only. CommonJS `require()` syntax is no longer supported for importing this package.
fix
Migrate your project to use ES modules (`import`/`export`) or stick to an older major version (e.g., `^3.0.0`). Ensure your `package.json` includes `"type": "module"` if using `.js` files for ESM.
affects: >=4.0.0
breakingVersion 5.0.0 introduced an `export` map, restricting direct imports from internal paths (e.g., `pkg/lib/index.js`).
fix
Always import directly from the package name: `import { findAllAfter } from 'unist-util-find-all-after'`. Avoid referencing internal directory structures.
affects: >=5.0.0
breakingType definitions were significantly improved and added since v3.0.0 and updated in v5.0.0. This might cause TypeScript compilation issues if your project relies on older `@types/unist` or incompatible type definitions.
fix
Update `@types/unist` to the latest compatible version and ensure your TypeScript project configuration is correctly set up to consume the package's types.
affects: >=3.0.0
breakingError messages were updated in version 3.0.0. If your code relies on exact string matching for error messages, this will break your tests or error handling.
fix
Review and update any code that performs string comparisons against error messages. It is generally recommended to rely on error types or properties rather than the exact message content.
affects: >=3.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to `require()` an ESM-only package in a CommonJS context.
fix
Change `require('unist-util-find-all-after')` to `import { findAllAfter } from 'unist-util-find-all-after'` and ensure your project is configured for ES modules (e.g., by adding `"type": "module"` to `package.json` or using the `.mjs` file extension).
TypeError: unist_util_find_all_after_1.findAllAfter is not a function
Incorrect import syntax for an ESM-only module that uses named exports, often encountered when TypeScript transpiles to CommonJS or due to incorrect CJS interop.
fix
Ensure you are using named import: `import { findAllAfter } from 'unist-util-find-all-after'`. This package does not have a default export. If transpiling to CJS, verify your transpiler correctly handles ESM named exports.
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '.../node_modules/unist-util-find-all-after/lib' is not supported
Attempting to import from internal paths or specific files within the package instead of its primary entry point, which is restricted by the `export` map introduced in v5.0.0.
fix
Always import from the package name directly: `import { findAllAfter } from 'unist-util-find-all-after'`. Avoid referencing internal directory structures.
SyntaxError: Cannot use import statement outside a module
Using an ES `import` statement in a JavaScript file that is being interpreted as a CommonJS module.
fix
To use `import` statements, your file must be part of an ES module. This can be achieved by adding `"type": "module"` to your nearest `package.json` file, or by renaming your module file to use the `.mjs` extension.
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
unist-util-isrequiredUsed internally for node testing functionality when a `test` parameter is provided.
@types/unistrequiredProvides core unist type definitions, crucial for TypeScript development and ensuring type compatibility with other unist utilities.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources