trousse 1.3.0 → 1.4.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/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/matching.d.ts +2 -1
- package/dist/matching.js +5 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, c
|
|
|
4
4
|
import { isBoolean, isFunction, isNonEmptyString, isNullish, isNumber, isObject, isPlainObject, isPresent, isString, isValidDate } from "./is.js";
|
|
5
5
|
import { isJsonLike, isParseableJson } from "./json.js";
|
|
6
6
|
import { escapeHtml, t, tx } from "./locales.js";
|
|
7
|
-
import { anyWordMatchesAnyOf, endsWithAnyOf, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
7
|
+
import { anyWordMatchesAnyOf, endsWithAnyOf, escapeRegex, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
8
8
|
import { omit, pick } from "./objects.js";
|
|
9
9
|
import { sleep } from "./timers.js";
|
|
10
10
|
import { getPathSegments, isHostOf, isSubdomainOf, parseUrl } from "./urls.js";
|
|
11
|
-
export { type MaybePromise, type Nullish, type PartialNullish, type Pattern, anyWordMatchesAnyOf, coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, coerceString, endsWithAnyOf, escapeHtml, getPathSegments, includesAnyOf, isAnyOf, isBoolean, isFunction, isHostOf, isJsonLike, isNonEmptyString, isNullish, isNumber, isObject, isParseableJson, isPlainObject, isPresent, isString, isSubdomainOf, isValidDate, omit, omitEmpty, parseUrl, pick, sleep, startsWithAnyOf, t, tx };
|
|
11
|
+
export { type MaybePromise, type Nullish, type PartialNullish, type Pattern, anyWordMatchesAnyOf, coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, coerceString, endsWithAnyOf, escapeHtml, escapeRegex, getPathSegments, includesAnyOf, isAnyOf, isBoolean, isFunction, isHostOf, isJsonLike, isNonEmptyString, isNullish, isNumber, isObject, isParseableJson, isPlainObject, isPresent, isString, isSubdomainOf, isValidDate, omit, omitEmpty, parseUrl, pick, sleep, startsWithAnyOf, t, tx };
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { omitEmpty } from "./arrays.js";
|
|
|
3
3
|
import { coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, coerceString } from "./coercions.js";
|
|
4
4
|
import { isJsonLike, isParseableJson } from "./json.js";
|
|
5
5
|
import { escapeHtml, t, tx } from "./locales.js";
|
|
6
|
-
import { anyWordMatchesAnyOf, endsWithAnyOf, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
6
|
+
import { anyWordMatchesAnyOf, endsWithAnyOf, escapeRegex, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
7
7
|
import { omit, pick } from "./objects.js";
|
|
8
8
|
import { sleep } from "./timers.js";
|
|
9
9
|
import { getPathSegments, isHostOf, isSubdomainOf, parseUrl } from "./urls.js";
|
|
10
|
-
export { anyWordMatchesAnyOf, coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, coerceString, endsWithAnyOf, escapeHtml, getPathSegments, includesAnyOf, isAnyOf, isBoolean, isFunction, isHostOf, isJsonLike, isNonEmptyString, isNullish, isNumber, isObject, isParseableJson, isPlainObject, isPresent, isString, isSubdomainOf, isValidDate, omit, omitEmpty, parseUrl, pick, sleep, startsWithAnyOf, t, tx };
|
|
10
|
+
export { anyWordMatchesAnyOf, coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, coerceString, endsWithAnyOf, escapeHtml, escapeRegex, getPathSegments, includesAnyOf, isAnyOf, isBoolean, isFunction, isHostOf, isJsonLike, isNonEmptyString, isNullish, isNumber, isObject, isParseableJson, isPlainObject, isPresent, isString, isSubdomainOf, isValidDate, omit, omitEmpty, parseUrl, pick, sleep, startsWithAnyOf, t, tx };
|
package/dist/matching.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Pattern } from "./types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/matching.d.ts
|
|
4
|
+
declare const escapeRegex: (value: string) => string;
|
|
4
5
|
declare const isAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
5
6
|
declare const includesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
6
7
|
declare const startsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
7
8
|
declare const endsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
8
9
|
declare const anyWordMatchesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
9
10
|
//#endregion
|
|
10
|
-
export { anyWordMatchesAnyOf, endsWithAnyOf, includesAnyOf, isAnyOf, startsWithAnyOf };
|
|
11
|
+
export { anyWordMatchesAnyOf, endsWithAnyOf, escapeRegex, includesAnyOf, isAnyOf, startsWithAnyOf };
|
package/dist/matching.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
//#region src/matching.ts
|
|
2
2
|
const whitespaceRegex = /\s+/;
|
|
3
|
+
const regexMetaCharsRegex = /[.*+?^${}()|[\]\\-]/g;
|
|
4
|
+
const escapeRegex = (value) => {
|
|
5
|
+
return value.replace(regexMetaCharsRegex, "\\$&");
|
|
6
|
+
};
|
|
3
7
|
const isAnyOf = (value, patterns, parser) => {
|
|
4
8
|
const parsedValue = parser ? parser(value) : value?.toLowerCase()?.trim();
|
|
5
9
|
return patterns.some((pattern) => {
|
|
@@ -41,4 +45,4 @@ const anyWordMatchesAnyOf = (value, patterns) => {
|
|
|
41
45
|
return false;
|
|
42
46
|
};
|
|
43
47
|
//#endregion
|
|
44
|
-
export { anyWordMatchesAnyOf, endsWithAnyOf, includesAnyOf, isAnyOf, startsWithAnyOf };
|
|
48
|
+
export { anyWordMatchesAnyOf, endsWithAnyOf, escapeRegex, includesAnyOf, isAnyOf, startsWithAnyOf };
|
package/package.json
CHANGED