trousse 1.1.0 → 1.2.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/matching.d.ts +5 -5
- package/dist/types.d.ts +2 -1
- package/dist/urls.d.ts +2 -2
- package/dist/urls.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { omitEmpty } from "./arrays.js";
|
|
2
|
-
import { MaybePromise, Nullish, Pattern } from "./types.js";
|
|
2
|
+
import { MaybePromise, Nullish, PartialNullish, Pattern } from "./types.js";
|
|
3
3
|
import { coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, coerceString } from "./coercions.js";
|
|
4
4
|
import { isBoolean, isFunction, isNonEmptyString, isNullish, isNumber, isObject, isPlainObject, isPresent, isString, isValidDate } from "./is.js";
|
|
5
5
|
import { isJsonLike, isParseableJson } from "./json.js";
|
|
@@ -7,4 +7,4 @@ import { escapeHtml, t, tx } from "./locales.js";
|
|
|
7
7
|
import { anyWordMatchesAnyOf, endsWithAnyOf, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
8
8
|
import { sleep } from "./timers.js";
|
|
9
9
|
import { getPathSegments, isHostOf, isSubdomainOf, parseUrl } from "./urls.js";
|
|
10
|
-
export { type MaybePromise, type Nullish, 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, omitEmpty, parseUrl, sleep, startsWithAnyOf, t, tx };
|
|
10
|
+
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, omitEmpty, parseUrl, sleep, startsWithAnyOf, t, tx };
|
package/dist/matching.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Pattern } from "./types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/matching.d.ts
|
|
4
|
-
declare const isAnyOf: (value: string, patterns:
|
|
5
|
-
declare const includesAnyOf: (value: string, patterns:
|
|
6
|
-
declare const startsWithAnyOf: (value: string, patterns:
|
|
7
|
-
declare const endsWithAnyOf: (value: string, patterns:
|
|
8
|
-
declare const anyWordMatchesAnyOf: (value: string, patterns:
|
|
4
|
+
declare const isAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
5
|
+
declare const includesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
6
|
+
declare const startsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
7
|
+
declare const endsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
8
|
+
declare const anyWordMatchesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { anyWordMatchesAnyOf, endsWithAnyOf, includesAnyOf, isAnyOf, startsWithAnyOf };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
type Nullish<T> = T | null | undefined;
|
|
3
|
+
type PartialNullish<T> = { [Key in keyof T]?: Nullish<T[Key]> };
|
|
3
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
4
5
|
type Pattern = string | RegExp;
|
|
5
6
|
//#endregion
|
|
6
|
-
export { MaybePromise, Nullish, Pattern };
|
|
7
|
+
export { MaybePromise, Nullish, PartialNullish, Pattern };
|
package/dist/urls.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/urls.d.ts
|
|
2
2
|
declare const parseUrl: (value: string | URL, base?: string | URL) => URL | undefined;
|
|
3
3
|
declare const getPathSegments: (value: string | URL) => Array<string>;
|
|
4
|
-
declare const isHostOf: (url: string | URL, hosts: string |
|
|
5
|
-
declare const isSubdomainOf: (url: string | URL, domains: string |
|
|
4
|
+
declare const isHostOf: (url: string | URL, hosts: string | ReadonlyArray<string>) => boolean;
|
|
5
|
+
declare const isSubdomainOf: (url: string | URL, domains: string | ReadonlyArray<string>) => boolean;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { getPathSegments, isHostOf, isSubdomainOf, parseUrl };
|
package/dist/urls.js
CHANGED
|
@@ -12,12 +12,12 @@ const getPathSegments = (value) => {
|
|
|
12
12
|
const isHostOf = (url, hosts) => {
|
|
13
13
|
const hostname = parseUrl(url)?.hostname;
|
|
14
14
|
if (!hostname) return false;
|
|
15
|
-
return isAnyOf(hostname,
|
|
15
|
+
return isAnyOf(hostname, typeof hosts === "string" ? [hosts] : hosts);
|
|
16
16
|
};
|
|
17
17
|
const isSubdomainOf = (url, domains) => {
|
|
18
18
|
const hostname = parseUrl(url)?.hostname;
|
|
19
19
|
if (!hostname) return false;
|
|
20
|
-
return endsWithAnyOf(hostname, (
|
|
20
|
+
return endsWithAnyOf(hostname, (typeof domains === "string" ? [domains] : domains).map((domain) => `.${domain}`));
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
23
23
|
export { getPathSegments, isHostOf, isSubdomainOf, parseUrl };
|
package/package.json
CHANGED