{"id":12705,"library":"zeptomatch-unescape","title":"Zeptomatch Unescape","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/fabiospampinato/zeptomatch-unescape","tags":["javascript","zeptomatch","unescape","typescript"],"install":[{"cmd":"npm install zeptomatch-unescape","lang":"bash","label":"npm"},{"cmd":"yarn add zeptomatch-unescape","lang":"bash","label":"yarn"},{"cmd":"pnpm add zeptomatch-unescape","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary function is exported as the default export, hence no curly braces are needed for import.","wrong":"import { unescape } from 'zeptomatch-unescape';","symbol":"unescape","correct":"import unescape from 'zeptomatch-unescape';"},{"note":"For CommonJS environments, the default export is directly assigned when requiring the module.","wrong":"const { unescape } = require('zeptomatch-unescape');","symbol":"unescape (CJS)","correct":"const unescape = require('zeptomatch-unescape');"},{"note":"While 'unescape' is a simple function, its type can be imported for explicit type annotations if needed, though `typeof unescape` often suffices.","symbol":"Types","correct":"import type { Unescape } from 'zeptomatch-unescape';"}],"quickstart":{"code":"import unescape from 'zeptomatch-unescape';\n\n// Example 1: Basic unescaping of glob special characters\nconst glob1 = 'foo\\\\*bar\\\\?';\nconst unescapedGlob1 = unescape(glob1);\nconsole.log(`Original: \"${glob1}\" -> Unescaped: \"${unescapedGlob1}\"`);\n// Expected: Original: \"foo\\*bar\\?\" -> Unescaped: \"foo*bar?\"\n\n// Example 2: Glob with no special characters or escapes\nconst glob2 = 'path/to/file.txt';\nconst unescapedGlob2 = unescape(glob2);\nconsole.log(`Original: \"${glob2}\" -> Unescaped: \"${unescapedGlob2}\"`);\n// Expected: Original: \"path/to/file.txt\" -> Unescaped: \"path/to/file.txt\"\n\n// Example 3: Mixed escapes and non-escaped characters\nconst glob3 = 'dir/\\\\*.js';\nconst unescapedGlob3 = unescape(glob3);\nconsole.log(`Original: \"${glob3}\" -> Unescaped: \"${unescapedGlob3}\"`);\n// Expected: Original: \"dir/\\*.js\" -> Unescaped: \"dir/*.js\"\n\n// Example 4: Escapes that are not glob special characters (should remain)\nconst glob4 = 'file\\\\-name.txt';\nconst unescapedGlob4 = unescape(glob4);\nconsole.log(`Original: \"${glob4}\" -> Unescaped: \"${unescapedGlob4}\"`);\n// Expected: Original: \"file\\-name.txt\" -> Unescaped: \"file\\-name.txt\"","lang":"typescript","description":"This quickstart demonstrates how to import and use the `unescape` function to remove backslash escape sequences from various glob patterns, illustrating its specific behavior."},"warnings":[{"fix":"Understand that `zeptomatch-unescape` operates strictly on glob syntax escapes. For general string unescaping, use a different utility or standard JavaScript string methods.","message":"The utility specifically unescapes glob special characters (e.g., `*`, `?`, `[`, `]`). Other backslash escapes (e.g., `\\n`, `\\t`, or non-glob character escapes like `\\-`) are preserved, as it's not a general-purpose string unescaper.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Combine with a glob parsing or validation library if robust glob pattern validation or deeper analysis is required after unescaping.","message":"This package performs only unescaping and does not validate the glob pattern's syntax or ensure it forms a valid glob after unescaping.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change the import statement to `const unescape = require('zeptomatch-unescape');` in CommonJS files, or ensure your build configuration correctly handles ES module interop.","cause":"Incorrect CommonJS `require` syntax when trying to import a default export from an ES module.","error":"TypeError: zeptomatch_unescape_1.default is not a function"},{"fix":"Run `npm install zeptomatch-unescape` to install the package and double-check that the import path in your code exactly matches `zeptomatch-unescape`.","cause":"The package is not installed or the import path is incorrect.","error":"Cannot find module 'zeptomatch-unescape'"}],"ecosystem":"npm"}