tiny-escape 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,8 @@ re.test(userInput); // true
42
42
 
43
43
  ## Differences from `escape-string-regexp`
44
44
 
45
+ `escape-string-regexp` v5 is ESM-only. If you `require("escape-string-regexp")` you get `ERR_REQUIRE_ESM`. `tiny-escape` works with both `import` and `require()`.
46
+
45
47
  | | `escape-string-regexp` | `tiny-escape` |
46
48
  | ----------- | ---------------------- | ------------- |
47
49
  | CJS support | v4 only (v5 ESM-only) | ESM + CJS |
package/dist/index.cjs CHANGED
@@ -1,2 +1,3 @@
1
- 'use strict';function r(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}exports.escapeRegExp=r;//# sourceMappingURL=index.cjs.map
2
- //# sourceMappingURL=index.cjs.map
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});function r(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var t=r;exports.default=t;exports.escapeRegExp=r;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
3
+ module.exports=Object.assign(exports.default,exports);delete module.exports.default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["escapeRegExp","string"],"mappings":"aAAO,SAASA,CAAAA,CAAaC,EAAwB,CACnD,GAAI,OAAOA,CAAAA,EAAW,QAAA,CACpB,MAAM,IAAI,SAAA,CAAU,mBAAmB,CAAA,CAGzC,OAAOA,EAAO,OAAA,CAAQ,qBAAA,CAAuB,MAAM,CAAA,CAAE,OAAA,CAAQ,IAAA,CAAM,OAAO,CAC5E","file":"index.cjs","sourcesContent":["export function escapeRegExp(string: string): string {\n if (typeof string !== \"string\") {\n throw new TypeError(\"Expected a string\");\n }\n\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, \"\\\\$&\").replace(/-/g, \"\\\\x2d\");\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["escapeRegExp","string","index_default"],"mappings":"sEAAO,SAASA,CAAAA,CAAaC,CAAAA,CAAwB,CACnD,GAAI,OAAOA,GAAW,QAAA,CACpB,MAAM,IAAI,SAAA,CAAU,mBAAmB,CAAA,CAGzC,OAAOA,CAAAA,CAAO,OAAA,CAAQ,qBAAA,CAAuB,MAAM,CAAA,CAAE,OAAA,CAAQ,KAAM,OAAO,CAC5E,CAEA,IAAOC,CAAAA,CAAQF","file":"index.cjs","sourcesContent":["export function escapeRegExp(string: string): string {\n if (typeof string !== \"string\") {\n throw new TypeError(\"Expected a string\");\n }\n\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, \"\\\\$&\").replace(/-/g, \"\\\\x2d\");\n}\n\nexport default escapeRegExp;\n"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  declare function escapeRegExp(string: string): string;
2
2
 
3
- export { escapeRegExp };
3
+ export { escapeRegExp as default, escapeRegExp };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  declare function escapeRegExp(string: string): string;
2
2
 
3
- export { escapeRegExp };
3
+ export { escapeRegExp as default, escapeRegExp };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function r(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}export{r as escapeRegExp};//# sourceMappingURL=index.js.map
1
+ function r(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var t=r;export{t as default,r as escapeRegExp};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["escapeRegExp","string"],"mappings":"AAAO,SAASA,CAAAA,CAAaC,EAAwB,CACnD,GAAI,OAAOA,CAAAA,EAAW,QAAA,CACpB,MAAM,IAAI,SAAA,CAAU,mBAAmB,CAAA,CAGzC,OAAOA,EAAO,OAAA,CAAQ,qBAAA,CAAuB,MAAM,CAAA,CAAE,OAAA,CAAQ,IAAA,CAAM,OAAO,CAC5E","file":"index.js","sourcesContent":["export function escapeRegExp(string: string): string {\n if (typeof string !== \"string\") {\n throw new TypeError(\"Expected a string\");\n }\n\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, \"\\\\$&\").replace(/-/g, \"\\\\x2d\");\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["escapeRegExp","string","index_default"],"mappings":"AAAO,SAASA,CAAAA,CAAaC,CAAAA,CAAwB,CACnD,GAAI,OAAOA,GAAW,QAAA,CACpB,MAAM,IAAI,SAAA,CAAU,mBAAmB,CAAA,CAGzC,OAAOA,CAAAA,CAAO,OAAA,CAAQ,qBAAA,CAAuB,MAAM,CAAA,CAAE,OAAA,CAAQ,KAAM,OAAO,CAC5E,CAEA,IAAOC,CAAAA,CAAQF","file":"index.js","sourcesContent":["export function escapeRegExp(string: string): string {\n if (typeof string !== \"string\") {\n throw new TypeError(\"Expected a string\");\n }\n\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, \"\\\\$&\").replace(/-/g, \"\\\\x2d\");\n}\n\nexport default escapeRegExp;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-escape",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Escape special characters for use in regular expressions. Like escape-string-regexp, ships ESM + CJS.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "scripts": {
25
- "build": "tsup",
25
+ "build": "tsup && node -e \"let f=require('fs'),p='dist/index.cjs',c=f.readFileSync(p,'utf8');c+='\\nmodule.exports=Object.assign(exports.default,exports);delete module.exports.default;';f.writeFileSync(p,c)\"",
26
26
  "typecheck": "tsc --noEmit",
27
27
  "test": "vitest run",
28
28
  "test:watch": "vitest",
@@ -70,9 +70,12 @@
70
70
  "escape-string-regexp",
71
71
  "string",
72
72
  "sanitize",
73
- "drop-in-replacement",
73
+ "commonjs",
74
+ "dual-package",
75
+ "err-require-esm",
74
76
  "typescript",
75
77
  "esm",
78
+ "cjs",
76
79
  "zero-dependency"
77
80
  ],
78
81
  "author": "Ofer Shapira <ofer@ofershap.dev>",