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 +1 -1
- package/regex.d.ts +12 -5
- package/scripts/publish-version.json +1 -1
- package/tool-lib/cjbm.js +1 -1
package/package.json
CHANGED
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
|
-
) ?
|
|
203
|
+
) ? R extends TypedRegExpBrand
|
|
204
|
+
? (...args: ReplaceCallbackParams<R, T>) => string
|
|
205
|
+
: (match: string, ...rest: any[]) => string
|
|
206
|
+
: string;
|
|
200
207
|
export as namespace XRegex;
|
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?:)(?=[.\\/]+)\
|