Zeptomatch Is Static
zeptomatch-is-static is a lightweight utility designed to ascertain if a given glob pattern is entirely static, meaning it contains no dynamic wildcards or special glob syntax. It is part of the 'zeptomatch' ecosystem of packages, known for being absurdly small, opinionated, and highly performant for glob matching. The current stable version is 1.0.1, last published approximately a year ago, indicating a stable release cycle for focused utilities. Unlike broader glob libraries that offer extensive configuration, `zeptomatch-is-static` provides a singular, optimized function to quickly check for static patterns. A key differentiator is its specific interpretation where escaped characters are considered static, necessitating separate unescaping if a truly dynamic check is required. The library ships with TypeScript types, ensuring good developer experience in TypeScript projects.
Common errors
-
TypeError: isStatic is not a function
cause Attempting to call `isStatic` after an incorrect CommonJS `require` import in an ESM context, or a typo in the import.fixEnsure you are using the correct ESM import syntax: `import isStatic from 'zeptomatch-is-static';`. If in a CommonJS-only file, verify the package's `package.json` for `main` or `exports` fields, or consider dynamic `import()`. -
Unexpected 'true' for a glob with escaped wildcard characters.
cause Misunderstanding how `zeptomatch-is-static` defines 'static' patterns. It considers `foo\*bar` as static because the wildcard character `*` is escaped, making it a literal character.fixIf the intent is to check if a glob contains *any* dynamic elements, including escaped wildcards, first unescape the glob using `zeptomatch-unescape` before passing it to `isStatic`. For example: `import unescape from 'zeptomatch-unescape'; isStatic(unescape('foo\\*bar')); // => false`.
Warnings
- gotcha The `isStatic` function considers escaped glob characters (e.g., `foo\*bar`) as part of a static pattern. If you need to treat these as dynamic or remove the escapes for further processing, you should use `zeptomatch-unescape` in conjunction with this package.
- gotcha This package, like other `zeptomatch` utilities, is designed for ESM (ECMAScript Module) imports. Attempting to use `require()` in an environment configured for ESM (e.g., a Node.js project with `"type": "module"` in `package.json`) can lead to import errors.
Install
-
npm install zeptomatch-is-static -
yarn add zeptomatch-is-static -
pnpm add zeptomatch-is-static
Imports
- isStatic
const isStatic = require('zeptomatch-is-static');import isStatic from 'zeptomatch-is-static';
Quickstart
import isStatic from 'zeptomatch-is-static';
// Install the package
// npm install zeptomatch-is-static
console.log(isStatic('foo')); // true
console.log(isStatic('foo/bar')); // true
console.log(isStatic('foo\\*bar')); // true (escaped characters are considered static)
console.log(isStatic('*')); // false
console.log(isStatic('**')); // false
console.log(isStatic('foo*')); // false
console.log(isStatic('foo/**/*')); // false
console.log(isStatic('foo*bar')); // false