trousse 2.0.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 CHANGED
@@ -1,4 +1,3 @@
1
1
  //#region src/arrays.d.ts
2
- declare const omitEmpty: <T>(array: Array<T | null | undefined>) => Array<T> | undefined;
3
- //#endregion
4
- export { omitEmpty };
2
+ export declare const omitEmpty: <T>(array: Array<T | null | undefined>) => Array<T> | undefined;
3
+ //#endregion
@@ -1,10 +1,9 @@
1
1
  import { Nullish } from "./types.js";
2
2
  //#region src/coercions.d.ts
3
- declare const coerceString: (value: unknown) => string | undefined;
4
- declare const coerceNumber: (value: unknown) => number | undefined;
5
- declare const coerceBoolean: (value: unknown) => boolean | undefined;
6
- declare const coerceDate: (value: unknown) => Date | undefined;
7
- declare const coerceSingular: <T>(value: T | Array<T>) => T;
8
- declare const coerceArray: <T>(value: Nullish<T | Array<T>>) => Array<T>;
9
- //#endregion
10
- 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
@@ -1,10 +1,9 @@
1
1
  import { Pattern } from "./types.js";
2
2
  //#region src/matching.d.ts
3
- declare const escapeRegex: (value: string) => string;
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
- //#endregion
10
- 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,7 +1,7 @@
1
1
  import { AnyOf } from "./types.js";
2
2
  //#region src/objects.d.ts
3
- declare const pick: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Pick<T, K>;
4
- declare const omit: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Omit<T, K>;
5
- declare const trimObject: <T extends Record<string, unknown>>(object: T, keep?: (value: unknown) => boolean) => AnyOf<T> | undefined;
6
- //#endregion
7
- export { omit, pick, trimObject };
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
@@ -27,5 +27,8 @@ const trimObject = (object, keep = isPresent) => {
27
27
  }
28
28
  return result;
29
29
  };
30
+ const toMap = (record) => {
31
+ return new Map(Object.entries(record));
32
+ };
30
33
  //#endregion
31
- export { omit, pick, trimObject };
34
+ export { omit, pick, toMap, trimObject };
package/dist/timers.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  //#region src/timers.d.ts
2
- declare const sleep: (milliseconds: number) => Promise<void>;
3
- //#endregion
4
- export { sleep };
2
+ export declare const sleep: (milliseconds: number) => Promise<void>;
3
+ //#endregion
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]>; }> & { [Key in keyof T]-?: Pick<{ [InnerKey in keyof T]-?: NonNullable<T[InnerKey]>; }, Key>; }[keyof T];
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>; }, Exclude<keyof T, Keys>> : T;
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.3.14",
39
+ "@types/bun": "^1.4.1",
40
40
  "kvalita": "^1.21.0",
41
- "tsdown": "^0.22.2"
41
+ "tsdown": "^0.23.0"
42
42
  },
43
- "version": "2.0.0"
43
+ "version": "2.1.0"
44
44
  }