js-dev-tool 1.0.17 → 1.0.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-dev-tool",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "bin": {
5
5
  "jstool": "tools.js"
6
6
  },
package/regex.d.ts CHANGED
@@ -62,15 +62,19 @@ declare global {
62
62
  // Basics
63
63
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
64
64
  */
65
+ export type Brand<Tag extends string> = {
66
+ [k in Tag]: true;
67
+ };
68
+ export type TypedRegExpBrand = Brand<"__TypedRegExp">;
69
+ export type TypedRegExp<const P extends string, const F extends string = ""> = RegExp & {
70
+ readonly source: P;
71
+ readonly flags: F;
72
+ } & TypedRegExpBrand;
65
73
  /**
66
74
  * Extracts the literal type from the source property of a RegExp.
67
75
  * @template R - A RegExp type.
68
76
  */
69
77
  export type RegExpSource<R extends RegExp> = R extends RegExp & { readonly source: infer T } ? T : never;
70
- export type TypedRegExp<const P extends string, const F extends string = ""> = RegExp & {
71
- readonly source: P;
72
- readonly flags: F;
73
- };
74
78
  export declare function createRegExp<
75
79
  const P extends string,
76
80
  const F extends string = ""
@@ -196,5 +200,8 @@ export type ReplaceCallbackParams<
196
200
  export type ReplacerFunctionSignature<R extends unkown> =
197
201
  R extends (
198
202
  RegExp & { readonly source: infer T }
199
- ) ? (...args: ReplaceCallbackParams<R, T>) => string : string;
203
+ ) ? R extends TypedRegExpBrand
204
+ ? (...args: ReplaceCallbackParams<R, T>) => string
205
+ : (match: string, ...rest: any[]) => string
206
+ : string;
200
207
  export as namespace XRegex;
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.0.17"
2
+ "version": "1.0.18"
3
3
  }
package/tool-lib/cjbm.js CHANGED
@@ -21,7 +21,7 @@ const path = require("path");
21
21
  * @returns {XRegex.TypedRegExp<P, F>} A typed RegExp object.
22
22
  */
23
23
  function createRegExp(pattern, flags) {
24
- return new RegExp(pattern, flags);
24
+ return /** @type {XRegex.TypedRegExp<P, F>} */(new RegExp(pattern, flags));
25
25
  }
26
26
  const reImportExportDetection = createRegExp(
27
27
  `(?<!\\s*\\/\\/+.*?)(?:(?<!@)import|export)\\s*(?:(?<qcGlobal>["'])(?!https?:)(?=[.\\/]+)\