Zeptomatch Unescape

1.0.1 · active · verified Sun Apr 19

zeptomatch-unescape is a small, specialized JavaScript utility designed to remove backslash escape sequences from glob patterns. It specifically targets characters commonly treated as special in glob syntax (e.g., `*`, `?`, `[`, `]`), converting `\*` to `*`, `\?` to `?`, and so on. This normalization is crucial when you need to interpret a glob pattern literally, especially if the pattern was generated dynamically or requires further processing without accidental escape interpretation. Currently at stable version 1.0.1, the package is maintained with a focus on reliability and correctness for its specific function, implying an infrequent release cadence. It integrates seamlessly into broader pattern matching pipelines, notably mentioned as a companion to `zeptomatch-is-static` for optimizing glob evaluation by first identifying and then handling truly static parts. This clear, single-purpose design differentiates it by offering a reliable component for complex pattern manipulation workflows.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `unescape` function to remove backslash escape sequences from various glob patterns, illustrating its specific behavior.

import unescape from 'zeptomatch-unescape';

// Example 1: Basic unescaping of glob special characters
const glob1 = 'foo\\*bar\\?';
const unescapedGlob1 = unescape(glob1);
console.log(`Original: "${glob1}" -> Unescaped: "${unescapedGlob1}"`);
// Expected: Original: "foo\*bar\?" -> Unescaped: "foo*bar?"

// Example 2: Glob with no special characters or escapes
const glob2 = 'path/to/file.txt';
const unescapedGlob2 = unescape(glob2);
console.log(`Original: "${glob2}" -> Unescaped: "${unescapedGlob2}"`);
// Expected: Original: "path/to/file.txt" -> Unescaped: "path/to/file.txt"

// Example 3: Mixed escapes and non-escaped characters
const glob3 = 'dir/\\*.js';
const unescapedGlob3 = unescape(glob3);
console.log(`Original: "${glob3}" -> Unescaped: "${unescapedGlob3}"`);
// Expected: Original: "dir/\*.js" -> Unescaped: "dir/*.js"

// Example 4: Escapes that are not glob special characters (should remain)
const glob4 = 'file\\-name.txt';
const unescapedGlob4 = unescape(glob4);
console.log(`Original: "${glob4}" -> Unescaped: "${unescapedGlob4}"`);
// Expected: Original: "file\-name.txt" -> Unescaped: "file\-name.txt"

view raw JSON →