vfile-is is a utility package within the unified/vfile ecosystem, designed to facilitate checking properties of `vfile` objects. It allows developers to assert whether a virtual file matches specific criteria, supporting a range of tests including glob patterns against `file.path`, direct string matches against `file.basename` or `file.extname`, custom predicate functions, or object-based comparisons against various `vfile` fields like `stem`, `extname`, or `basename`. The current stable version is 3.0.0, which mandates Node.js 16 or newer and is ESM-only. The package maintains a steady release cadence, often aligning with updates to the core `vfile` library. Its key differentiators include its integration with the `vfile` standard, offering a streamlined API (`is` and `convert`) for robust and composable file testing, which helps in building unified-based tools by providing a consistent way to filter or categorize files.
npm install vfile-isVerified import paths — ran on the pinned version, not inferred.
Demonstrates various ways to check VFile properties using `is()`, including path, extension, globs, object-based field assertions, and how to create reusable assertion functions with `convert()`.
Upgrade your Node.js environment to version 16 or newer. Consider using nvm or volta for easy version management.
Switch to ES module `import` syntax (e.g., `import { is } from 'vfile-is'`). Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` file extensions).Only use documented public APIs and import paths as specified in the package's official documentation or `exports` field.
Carefully consult the API documentation for the `Check` type to understand the expected behavior for each input format when defining file tests.
Update your import statements to use ES module syntax (e.g., `import { is } from 'vfile-is'`). Ensure your project's `package.json` includes `"type": "module"` if running in Node.js.Import `VFile` from `to-vfile` (e.g., `import { VFile } from 'to-vfile'`) or directly from `vfile` if `to-vfile` is not needed for file creation.Ensure `is` is imported as a named export: `import { is } from 'vfile-is'`.