shelving 1.124.5 → 1.125.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/package.json +1 -1
- package/util/equal.d.ts +1 -1
- package/util/index.d.ts +1 -1
- package/util/index.js +1 -1
- package/util/regexp.d.ts +22 -8
- package/util/regexp.js +22 -4
- /package/util/{match.d.ts → filter.d.ts} +0 -0
- /package/util/{match.js → filter.js} +0 -0
package/package.json
CHANGED
package/util/equal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ImmutableArray } from "./array.js";
|
|
2
|
+
import type { Match } from "./filter.js";
|
|
2
3
|
import type { ImmutableMap } from "./map.js";
|
|
3
|
-
import type { Match } from "./match.js";
|
|
4
4
|
import type { ImmutableObject } from "./object.js";
|
|
5
5
|
/** Is unknown value `left` exactly equal to `right`? */
|
|
6
6
|
export declare function isEqual<T>(left: unknown, right: T): left is T;
|
package/util/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./entry.js";
|
|
|
18
18
|
export * from "./equal.js";
|
|
19
19
|
export * from "./error.js";
|
|
20
20
|
export * from "./file.js";
|
|
21
|
+
export * from "./filter.js";
|
|
21
22
|
export * from "./focus.js";
|
|
22
23
|
export * from "./function.js";
|
|
23
24
|
export * from "./hash.js";
|
|
@@ -28,7 +29,6 @@ export * from "./jsx.js";
|
|
|
28
29
|
export * from "./lazy.js";
|
|
29
30
|
export * from "./link.js";
|
|
30
31
|
export * from "./map.js";
|
|
31
|
-
export * from "./match.js";
|
|
32
32
|
export * from "./merge.js";
|
|
33
33
|
export * from "./null.js";
|
|
34
34
|
export * from "./number.js";
|
package/util/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./entry.js";
|
|
|
18
18
|
export * from "./equal.js";
|
|
19
19
|
export * from "./error.js";
|
|
20
20
|
export * from "./file.js";
|
|
21
|
+
export * from "./filter.js";
|
|
21
22
|
export * from "./focus.js";
|
|
22
23
|
export * from "./function.js";
|
|
23
24
|
export * from "./hash.js";
|
|
@@ -28,7 +29,6 @@ export * from "./jsx.js";
|
|
|
28
29
|
export * from "./lazy.js";
|
|
29
30
|
export * from "./link.js";
|
|
30
31
|
export * from "./map.js";
|
|
31
|
-
export * from "./match.js";
|
|
32
32
|
export * from "./merge.js";
|
|
33
33
|
export * from "./null.js";
|
|
34
34
|
export * from "./number.js";
|
package/util/regexp.d.ts
CHANGED
|
@@ -22,15 +22,11 @@ export declare function escapeRegExp(pattern: string): string;
|
|
|
22
22
|
export declare function getAnyRegExp(patterns: Iterable<PossibleRegExp> & NotString, flags?: string): RegExp;
|
|
23
23
|
/** Create regular expression that matches all of a list of other expressions. */
|
|
24
24
|
export declare function getAllRegExp(patterns: Iterable<PossibleRegExp> & NotString, flags?: string): RegExp;
|
|
25
|
-
/**
|
|
26
|
-
export declare function isRegExpMatch(item: string, target: RegExp): boolean;
|
|
27
|
-
/** Match function for finding strings that match against regular expressions (use with `filter()` to negatively filter iterable sets of items). */
|
|
28
|
-
export declare function notRegExpMatch(item: string, target: RegExp): boolean;
|
|
29
|
-
/** Regular expression match array that you've asserted contains the specified named groups. */
|
|
25
|
+
/** Regular expression match array that matches a specific string format. */
|
|
30
26
|
export interface TypedRegExpExecArray<T extends string = string> extends RegExpExecArray {
|
|
31
27
|
0: T;
|
|
32
28
|
}
|
|
33
|
-
/** Regular expression that
|
|
29
|
+
/** Regular expression that matches a specific string format. */
|
|
34
30
|
export interface TypedRegExp<T extends string = string> extends RegExp {
|
|
35
31
|
exec(input: string): TypedRegExpExecArray<T> | null;
|
|
36
32
|
}
|
|
@@ -38,11 +34,29 @@ export interface TypedRegExp<T extends string = string> extends RegExp {
|
|
|
38
34
|
export type NamedRegExpData = {
|
|
39
35
|
[named: string]: string;
|
|
40
36
|
};
|
|
41
|
-
/** Regular expression match array that
|
|
37
|
+
/** Regular expression match array that contains the specified named groups. */
|
|
42
38
|
export interface NamedRegExpExecArray<T extends NamedRegExpData = NamedRegExpData> extends RegExpExecArray {
|
|
43
39
|
groups: T;
|
|
44
40
|
}
|
|
45
|
-
/** Regular expression that
|
|
41
|
+
/** Regular expression that contains the specified named capture groups. */
|
|
46
42
|
export interface NamedRegExp<T extends NamedRegExpData = NamedRegExpData> extends RegExp {
|
|
47
43
|
exec(input: string): NamedRegExpExecArray<T> | null;
|
|
48
44
|
}
|
|
45
|
+
/** Match function for finding strings that match against regular expressions (use with `filter()` to positively filter iterable sets of items). */
|
|
46
|
+
export declare function isMatch(str: string, regexp: RegExp): boolean;
|
|
47
|
+
/** Match function for finding strings that match against regular expressions (use with `filter()` to negatively filter iterable sets of items). */
|
|
48
|
+
export declare function notMatch(str: string, regexp: RegExp): boolean;
|
|
49
|
+
/** Get an optional regular expression match, or `undefined` if no match could be made. */
|
|
50
|
+
export declare function getOptionalMatch<T extends NamedRegExpData>(str: string, regexp: NamedRegExp<T>): NamedRegExpExecArray<T> | undefined;
|
|
51
|
+
export declare function getOptionalMatch<T extends string>(str: string, regexp: TypedRegExp<T>): TypedRegExpExecArray<T> | undefined;
|
|
52
|
+
export declare function getOptionalMatch(str: string, regexp: RegExp): RegExpExecArray | undefined;
|
|
53
|
+
/** Get a required regular expression match, or throw `ValueError` if no match could be made. */
|
|
54
|
+
export declare function getMatch<T extends NamedRegExpData>(str: string, regexp: NamedRegExp<T>): NamedRegExpExecArray<T>;
|
|
55
|
+
export declare function getMatch<T extends string>(str: string, regexp: TypedRegExp<T>): TypedRegExpExecArray<T>;
|
|
56
|
+
export declare function getMatch(str: string, regexp: RegExp): RegExpExecArray;
|
|
57
|
+
/** Get an optional regular expression match, or `undefined` if no match could be made. */
|
|
58
|
+
export declare function getOptionalMatchGroups<T extends NamedRegExpData>(str: string, regexp: NamedRegExp<T>): T | undefined;
|
|
59
|
+
export declare function getOptionalMatchGroups(str: string, regexp: RegExp): NamedRegExpData | undefined;
|
|
60
|
+
/** Get a required regular expression match, or throw `ValueError` if no match could be made. */
|
|
61
|
+
export declare function getMatchGroups<T extends NamedRegExpData>(str: string, regexp: NamedRegExp<T>): T;
|
|
62
|
+
export declare function getMatchGroups(str: string, regexp: RegExp): NamedRegExpData;
|
package/util/regexp.js
CHANGED
|
@@ -44,10 +44,28 @@ export function getAllRegExp(patterns, flags) {
|
|
|
44
44
|
return new RegExp(`^(?=.*?(?:${getArray(patterns).map(getRegExpSource).join("))(?=.*?(?:")}))`, flags);
|
|
45
45
|
}
|
|
46
46
|
/** Match function for finding strings that match against regular expressions (use with `filter()` to positively filter iterable sets of items). */
|
|
47
|
-
export function
|
|
48
|
-
return
|
|
47
|
+
export function isMatch(str, regexp) {
|
|
48
|
+
return regexp.test(str);
|
|
49
49
|
}
|
|
50
50
|
/** Match function for finding strings that match against regular expressions (use with `filter()` to negatively filter iterable sets of items). */
|
|
51
|
-
export function
|
|
52
|
-
return !
|
|
51
|
+
export function notMatch(str, regexp) {
|
|
52
|
+
return !regexp.test(str);
|
|
53
|
+
}
|
|
54
|
+
export function getOptionalMatch(str, regexp) {
|
|
55
|
+
return regexp.exec(str) || undefined;
|
|
56
|
+
}
|
|
57
|
+
export function getMatch(str, regexp) {
|
|
58
|
+
const match = getOptionalMatch(str, regexp);
|
|
59
|
+
if (!match)
|
|
60
|
+
throw new ValueError("Must match regular expression", str);
|
|
61
|
+
return match;
|
|
62
|
+
}
|
|
63
|
+
export function getOptionalMatchGroups(str, regexp) {
|
|
64
|
+
return regexp.exec(str)?.groups || undefined;
|
|
65
|
+
}
|
|
66
|
+
export function getMatchGroups(str, regexp) {
|
|
67
|
+
const groups = getOptionalMatchGroups(str, regexp);
|
|
68
|
+
if (!groups)
|
|
69
|
+
throw new ValueError("Must match regular expression", str);
|
|
70
|
+
return groups;
|
|
53
71
|
}
|
|
File without changes
|
|
File without changes
|