trousse 1.2.0 → 1.3.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/README.md +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/objects.d.ts +5 -0
- package/dist/objects.js +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/trousse)
|
|
5
5
|
[](https://github.com/macieklamberski/trousse/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
Personal toolbox of shared TypeScript utilities used across my projects: type guards, coercions, matching, array and locale interpolation helpers.
|
|
7
|
+
Personal toolbox of shared TypeScript utilities used across my projects: type guards, coercions, matching, array, object and locale interpolation helpers.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +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, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
8
|
+
import { omit, pick } from "./objects.js";
|
|
8
9
|
import { sleep } from "./timers.js";
|
|
9
10
|
import { getPathSegments, isHostOf, isSubdomainOf, parseUrl } from "./urls.js";
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +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, includesAnyOf, isAnyOf, startsWithAnyOf } from "./matching.js";
|
|
7
|
+
import { omit, pick } from "./objects.js";
|
|
7
8
|
import { sleep } from "./timers.js";
|
|
8
9
|
import { getPathSegments, isHostOf, isSubdomainOf, parseUrl } from "./urls.js";
|
|
9
|
-
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, omitEmpty, parseUrl, sleep, startsWithAnyOf, t, tx };
|
|
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 };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/objects.d.ts
|
|
2
|
+
declare const pick: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Pick<T, K>;
|
|
3
|
+
declare const omit: <T extends object, K extends keyof T>(object: T, keys: ReadonlyArray<K>) => Omit<T, K>;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { omit, pick };
|
package/dist/objects.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/objects.ts
|
|
2
|
+
const pick = (object, keys) => {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const key of keys) if (key in object) result[key] = object[key];
|
|
5
|
+
return result;
|
|
6
|
+
};
|
|
7
|
+
const omit = (object, keys) => {
|
|
8
|
+
const result = { ...object };
|
|
9
|
+
for (const key of keys) delete result[key];
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { omit, pick };
|
package/package.json
CHANGED