trousse 1.5.0 → 2.1.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/arrays.d.ts +2 -3
- package/dist/arrays.js +1 -1
- package/dist/coercions.d.ts +7 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/is.d.ts +11 -12
- package/dist/json.d.ts +3 -4
- package/dist/locales.d.ts +4 -5
- package/dist/matching.d.ts +7 -9
- package/dist/objects.d.ts +5 -6
- package/dist/objects.js +4 -1
- package/dist/timers.d.ts +2 -3
- package/dist/types.d.ts +8 -9
- package/dist/urls.d.ts +5 -6
- package/package.json +4 -4
package/dist/arrays.d.ts
CHANGED
package/dist/arrays.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isPresent } from "./is.js";
|
|
|
3
3
|
const omitEmpty = (array) => {
|
|
4
4
|
const result = [];
|
|
5
5
|
for (const item of array) if (isPresent(item) && item !== "") result.push(item);
|
|
6
|
-
return result;
|
|
6
|
+
return result.length ? result : void 0;
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
9
9
|
export { omitEmpty };
|
package/dist/coercions.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Nullish } from "./types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/coercions.d.ts
|
|
4
|
-
declare const coerceString: (value: unknown) => string | undefined;
|
|
5
|
-
declare const coerceNumber: (value: unknown) => number | undefined;
|
|
6
|
-
declare const coerceBoolean: (value: unknown) => boolean | undefined;
|
|
7
|
-
declare const coerceDate: (value: unknown) => Date | undefined;
|
|
8
|
-
declare const coerceSingular: <T>(value: T | Array<T>) => T;
|
|
9
|
-
declare const coerceArray: <T>(value: Nullish<T | Array<T>>) => Array<T>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, coerceString };
|
|
3
|
+
export declare const coerceString: (value: unknown) => string | undefined;
|
|
4
|
+
export declare const coerceNumber: (value: unknown) => number | undefined;
|
|
5
|
+
export declare const coerceBoolean: (value: unknown) => boolean | undefined;
|
|
6
|
+
export declare const coerceDate: (value: unknown) => Date | undefined;
|
|
7
|
+
export declare const coerceSingular: <T>(value: T | Array<T>) => T;
|
|
8
|
+
export declare const coerceArray: <T>(value: Nullish<T | Array<T>>) => Array<T>;
|
|
9
|
+
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { isBoolean, isFunction, isNonEmptyString, isNullish, isNumber, isObject,
|
|
|
5
5
|
import { isJsonLike, isParseableJson } from "./json.js";
|
|
6
6
|
import { escapeHtml, t, tx } from "./locales.js";
|
|
7
7
|
import { anyWordMatchesAnyOf, endsWithAnyOf, escapeRegex, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
8
|
-
import { omit, pick, trimObject } from "./objects.js";
|
|
8
|
+
import { omit, pick, toMap, trimObject } from "./objects.js";
|
|
9
9
|
import { sleep } from "./timers.js";
|
|
10
10
|
import { getPathSegments, isHostOf, isSubdomainOf, parseUrl } from "./urls.js";
|
|
11
|
-
export { type AnyOf, type DeepOmit, type IsPlainObject, 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, trimObject, tx };
|
|
11
|
+
export { type AnyOf, type DeepOmit, type IsPlainObject, 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, toMap, trimObject, tx };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { coerceArray, coerceBoolean, coerceDate, coerceNumber, coerceSingular, c
|
|
|
4
4
|
import { isJsonLike, isParseableJson } from "./json.js";
|
|
5
5
|
import { escapeHtml, t, tx } from "./locales.js";
|
|
6
6
|
import { anyWordMatchesAnyOf, endsWithAnyOf, escapeRegex, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
7
|
-
import { omit, pick, trimObject } from "./objects.js";
|
|
7
|
+
import { omit, pick, toMap, trimObject } 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, 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, trimObject, 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, toMap, trimObject, tx };
|
package/dist/is.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
//#region src/is.d.ts
|
|
2
|
-
declare const isString: (value: unknown) => value is string;
|
|
3
|
-
declare const isNumber: (value: unknown) => value is number;
|
|
4
|
-
declare const isBoolean: (value: unknown) => value is boolean;
|
|
5
|
-
declare const isFunction: (value: unknown) => value is (...args: Array<never>) => unknown;
|
|
6
|
-
declare const isPresent: <T>(value: T) => value is NonNullable<T>;
|
|
7
|
-
declare const isNullish: (value: unknown) => value is null | undefined;
|
|
8
|
-
declare const isObject: (value: unknown) => value is object;
|
|
9
|
-
declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
10
|
-
declare const isNonEmptyString: (value: unknown) => value is string;
|
|
11
|
-
declare const isValidDate: (value: unknown) => value is Date;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { isBoolean, isFunction, isNonEmptyString, isNullish, isNumber, isObject, isPlainObject, isPresent, isString, isValidDate };
|
|
2
|
+
export declare const isString: (value: unknown) => value is string;
|
|
3
|
+
export declare const isNumber: (value: unknown) => value is number;
|
|
4
|
+
export declare const isBoolean: (value: unknown) => value is boolean;
|
|
5
|
+
export declare const isFunction: (value: unknown) => value is (...args: Array<never>) => unknown;
|
|
6
|
+
export declare const isPresent: <T>(value: T) => value is NonNullable<T>;
|
|
7
|
+
export declare const isNullish: (value: unknown) => value is null | undefined;
|
|
8
|
+
export declare const isObject: (value: unknown) => value is object;
|
|
9
|
+
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
10
|
+
export declare const isNonEmptyString: (value: unknown) => value is string;
|
|
11
|
+
export declare const isValidDate: (value: unknown) => value is Date;
|
|
12
|
+
//#endregion
|
package/dist/json.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/json.d.ts
|
|
2
|
-
declare const isJsonLike: (value: string) => boolean;
|
|
3
|
-
declare const isParseableJson: (value: string) => boolean;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { isJsonLike, isParseableJson };
|
|
2
|
+
export declare const isJsonLike: (value: string) => boolean;
|
|
3
|
+
export declare const isParseableJson: (value: string) => boolean;
|
|
4
|
+
//#endregion
|
package/dist/locales.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
//#region src/locales.d.ts
|
|
2
|
-
declare const escapeHtml: (value: string) => string;
|
|
3
|
-
declare const t: (template: string, params: Record<string, string | number>) => string;
|
|
4
|
-
declare const tx: (template: string, params: Record<string, string | number>) => string;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { escapeHtml, t, tx };
|
|
2
|
+
export declare const escapeHtml: (value: string) => string;
|
|
3
|
+
export declare const t: (template: string, params: Record<string, string | number>) => string;
|
|
4
|
+
export declare const tx: (template: string, params: Record<string, string | number>) => string;
|
|
5
|
+
//#endregion
|
package/dist/matching.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Pattern } from "./types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/matching.d.ts
|
|
4
|
-
declare const escapeRegex: (value: string) => string;
|
|
5
|
-
declare const isAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
6
|
-
declare const includesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
7
|
-
declare const startsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
8
|
-
declare const endsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
9
|
-
declare const anyWordMatchesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { anyWordMatchesAnyOf, endsWithAnyOf, escapeRegex, includesAnyOf, isAnyOf, startsWithAnyOf };
|
|
3
|
+
export declare const escapeRegex: (value: string) => string;
|
|
4
|
+
export declare const isAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
5
|
+
export declare const includesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>, parser?: (value: string) => string) => boolean;
|
|
6
|
+
export declare const startsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
7
|
+
export declare const endsWithAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
8
|
+
export declare const anyWordMatchesAnyOf: (value: string, patterns: ReadonlyArray<Pattern>) => boolean;
|
|
9
|
+
//#endregion
|
package/dist/objects.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AnyOf } from "./types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/objects.d.ts
|
|
4
|
-
declare const pick: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Pick<T, K>;
|
|
5
|
-
declare const omit: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Omit<T, K>;
|
|
6
|
-
declare const trimObject: <T extends Record<string, unknown>>(object: T, keep?: (value: unknown) => boolean) => AnyOf<T> | undefined;
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export declare const pick: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Pick<T, K>;
|
|
4
|
+
export declare const omit: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Omit<T, K>;
|
|
5
|
+
export declare const trimObject: <T extends Record<string, unknown>>(object: T, keep?: (value: unknown) => boolean) => AnyOf<T> | undefined;
|
|
6
|
+
export declare const toMap: <V>(record: Record<string, V>) => Map<string, V>;
|
|
7
|
+
//#endregion
|
package/dist/objects.js
CHANGED
package/dist/timers.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
|
-
type AnyOf<T> = Partial<{ [Key in keyof T]-?: NonNullable<T[Key]
|
|
3
|
-
type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
|
|
4
|
-
type DeepOmit<T, Keys extends string> = T extends Array<infer Item> ? Array<DeepOmit<Item, Keys>> : IsPlainObject<T> extends true ? Pick<{ [Key in keyof T]: DeepOmit<T[Key], Keys
|
|
5
|
-
type Nullish<T> = T | null | undefined;
|
|
6
|
-
type PartialNullish<T> = { [Key in keyof T]?: Nullish<T[Key]
|
|
7
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
8
|
-
type Pattern = string | RegExp;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { AnyOf, DeepOmit, IsPlainObject, MaybePromise, Nullish, PartialNullish, Pattern };
|
|
2
|
+
export type AnyOf<T> = Partial<{ [Key in keyof T]-?: NonNullable<T[Key]>; }> & { [Key in keyof T]-?: Pick<{ [InnerKey in keyof T]-?: NonNullable<T[InnerKey]>; }, Key>; }[keyof T];
|
|
3
|
+
export type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
|
|
4
|
+
export type DeepOmit<T, Keys extends string> = T extends Array<infer Item> ? Array<DeepOmit<Item, Keys>> : IsPlainObject<T> extends true ? Pick<{ [Key in keyof T]: DeepOmit<T[Key], Keys>; }, Exclude<keyof T, Keys>> : T;
|
|
5
|
+
export type Nullish<T> = T | null | undefined;
|
|
6
|
+
export type PartialNullish<T> = { [Key in keyof T]?: Nullish<T[Key]>; };
|
|
7
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
8
|
+
export type Pattern = string | RegExp;
|
|
9
|
+
//#endregion
|
package/dist/urls.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
//#region src/urls.d.ts
|
|
2
|
-
declare const parseUrl: (value: string | URL, base?: string | URL) => URL | undefined;
|
|
3
|
-
declare const getPathSegments: (value: string | URL) => Array<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
|
-
//#endregion
|
|
7
|
-
export { getPathSegments, isHostOf, isSubdomainOf, parseUrl };
|
|
2
|
+
export declare const parseUrl: (value: string | URL, base?: string | URL) => URL | undefined;
|
|
3
|
+
export declare const getPathSegments: (value: string | URL) => Array<string>;
|
|
4
|
+
export declare const isHostOf: (url: string | URL, hosts: string | ReadonlyArray<string>) => boolean;
|
|
5
|
+
export declare const isSubdomainOf: (url: string | URL, domains: string | ReadonlyArray<string>) => boolean;
|
|
6
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"test": "bun test"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/bun": "^1.
|
|
40
|
-
"kvalita": "^1.
|
|
41
|
-
"tsdown": "^0.
|
|
39
|
+
"@types/bun": "^1.4.1",
|
|
40
|
+
"kvalita": "^1.21.0",
|
|
41
|
+
"tsdown": "^0.23.0"
|
|
42
42
|
},
|
|
43
|
-
"version": "1.
|
|
43
|
+
"version": "2.1.0"
|
|
44
44
|
}
|