@augment-vir/common 8.1.0 → 9.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/cjs/augments/object/filter-object.d.ts +5 -0
- package/dist/cjs/augments/object/filter-object.js +27 -0
- package/dist/cjs/augments/object/jsonify.d.ts +3 -0
- package/dist/cjs/augments/object/jsonify.js +7 -0
- package/dist/cjs/augments/object/nested-keys.d.ts +4 -4
- package/dist/cjs/augments/object/object.d.ts +1 -2
- package/dist/cjs/augments/object/object.js +1 -12
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +2 -0
- package/dist/esm/augments/object/filter-object.d.ts +5 -0
- package/dist/esm/augments/object/filter-object.js +21 -0
- package/dist/esm/augments/object/jsonify.d.ts +3 -0
- package/dist/esm/augments/object/jsonify.js +3 -0
- package/dist/esm/augments/object/nested-keys.d.ts +4 -4
- package/dist/esm/augments/object/object.d.ts +1 -2
- package/dist/esm/augments/object/object.js +1 -11
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/types/augments/object/filter-object.d.ts +5 -0
- package/dist/types/augments/object/jsonify.d.ts +3 -0
- package/dist/types/augments/object/nested-keys.d.ts +4 -4
- package/dist/types/augments/object/object.d.ts +1 -2
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PropertyValueType } from './object';
|
|
2
|
+
export declare function filterObject<ObjectGeneric>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: PropertyValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
3
|
+
export declare function omitObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, omitTheseKeys: ReadonlyArray<KeyGeneric>): Omit<ObjectGeneric, KeyGeneric>;
|
|
4
|
+
export declare function pickObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, pickTheseKeys: ReadonlyArray<KeyGeneric>): Pick<ObjectGeneric, KeyGeneric>;
|
|
5
|
+
//# sourceMappingURL=filter-object.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pickObjectKeys = exports.omitObjectKeys = exports.filterObject = void 0;
|
|
4
|
+
const object_entries_1 = require("./object-entries");
|
|
5
|
+
function filterObject(inputObject, callback) {
|
|
6
|
+
const filteredKeys = (0, object_entries_1.getObjectTypedKeys)(inputObject).filter((key) => {
|
|
7
|
+
const value = inputObject[key];
|
|
8
|
+
return callback(key, value, inputObject);
|
|
9
|
+
});
|
|
10
|
+
return filteredKeys.reduce((accum, key) => {
|
|
11
|
+
accum[key] = inputObject[key];
|
|
12
|
+
return accum;
|
|
13
|
+
}, {});
|
|
14
|
+
}
|
|
15
|
+
exports.filterObject = filterObject;
|
|
16
|
+
function omitObjectKeys(inputObject, omitTheseKeys) {
|
|
17
|
+
return filterObject(inputObject, (currentKey) => {
|
|
18
|
+
return !omitTheseKeys.includes(currentKey);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.omitObjectKeys = omitObjectKeys;
|
|
22
|
+
function pickObjectKeys(inputObject, pickTheseKeys) {
|
|
23
|
+
return filterObject(inputObject, (currentKey) => {
|
|
24
|
+
return pickTheseKeys.includes(currentKey);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.pickObjectKeys = pickObjectKeys;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { UnionToIntersection } from 'type-fest';
|
|
2
|
-
import {
|
|
3
|
-
export type NestedSequentialKeys<ObjectGeneric extends object> =
|
|
2
|
+
import { PropertyValueType } from './object';
|
|
3
|
+
export type NestedSequentialKeys<ObjectGeneric extends object> = PropertyValueType<{
|
|
4
4
|
[Prop in keyof ObjectGeneric]: NonNullable<ObjectGeneric[Prop]> extends object ? [Prop, ...(NestedSequentialKeys<NonNullable<ObjectGeneric[Prop]>> | [])] : [Prop];
|
|
5
5
|
}>;
|
|
6
|
-
export type NestedKeys<ObjectGeneric extends object> = UnionToIntersection<Extract<
|
|
6
|
+
export type NestedKeys<ObjectGeneric extends object> = UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>> extends object ? [
|
|
7
7
|
keyof ObjectGeneric,
|
|
8
|
-
...(NestedKeys<UnionToIntersection<Extract<
|
|
8
|
+
...(NestedKeys<UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>>> | [])
|
|
9
9
|
] : [keyof ObjectGeneric];
|
|
10
10
|
export type NestedValue<ObjectGeneric extends object, NestedKeysGeneric extends NestedSequentialKeys<ObjectGeneric>> = NestedKeysGeneric extends readonly [infer FirstEntry, ...infer FollowingEntries] ? FirstEntry extends keyof ObjectGeneric ? FollowingEntries extends never[] ? ObjectGeneric[FirstEntry] : ObjectGeneric[FirstEntry] extends object ? FollowingEntries extends NestedSequentialKeys<ObjectGeneric[FirstEntry]> ? NestedValue<ObjectGeneric[FirstEntry], FollowingEntries> : never : never : never : never;
|
|
11
11
|
export declare function getValueFromNestedKeys<ObjectGeneric extends object, KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(inputObject: ObjectGeneric, nestedKeys: KeysGeneric): NestedValue<ObjectGeneric, KeysGeneric> | undefined;
|
|
@@ -3,8 +3,7 @@ export type PartialWithNullable<T extends object> = {
|
|
|
3
3
|
};
|
|
4
4
|
export declare function isObject(input: any): input is NonNullable<object>;
|
|
5
5
|
export declare function areJsonEqual(a: object, b: object): boolean;
|
|
6
|
-
export declare function filterObject<ObjectGeneric extends object>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: ObjectValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
7
6
|
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
8
7
|
export declare function copyThroughJson<T>(input: T): T;
|
|
9
|
-
export type
|
|
8
|
+
export type PropertyValueType<T> = T[keyof T];
|
|
10
9
|
//# sourceMappingURL=object.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyThroughJson = exports.
|
|
3
|
+
exports.copyThroughJson = exports.areJsonEqual = exports.isObject = void 0;
|
|
4
4
|
const object_entries_1 = require("./object-entries");
|
|
5
5
|
function isObject(input) {
|
|
6
6
|
return !!input && typeof input === 'object';
|
|
@@ -18,17 +18,6 @@ function areJsonEqual(a, b) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.areJsonEqual = areJsonEqual;
|
|
21
|
-
function filterObject(inputObject, callback) {
|
|
22
|
-
const filteredKeys = (0, object_entries_1.getObjectTypedKeys)(inputObject).filter((key) => {
|
|
23
|
-
const value = inputObject[key];
|
|
24
|
-
return callback(key, value, inputObject);
|
|
25
|
-
});
|
|
26
|
-
return filteredKeys.reduce((accum, key) => {
|
|
27
|
-
accum[key] = inputObject[key];
|
|
28
|
-
return accum;
|
|
29
|
-
}, {});
|
|
30
|
-
}
|
|
31
|
-
exports.filterObject = filterObject;
|
|
32
21
|
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
33
22
|
function copyThroughJson(input) {
|
|
34
23
|
try {
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './augments/environment';
|
|
|
8
8
|
export * from './augments/error';
|
|
9
9
|
export * from './augments/function';
|
|
10
10
|
export * from './augments/object/enum';
|
|
11
|
+
export * from './augments/object/filter-object';
|
|
12
|
+
export * from './augments/object/jsonify';
|
|
11
13
|
export * from './augments/object/map-object';
|
|
12
14
|
export * from './augments/object/matches-object-shape';
|
|
13
15
|
export * from './augments/object/nested-keys';
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,6 +24,8 @@ __exportStar(require("./augments/environment"), exports);
|
|
|
24
24
|
__exportStar(require("./augments/error"), exports);
|
|
25
25
|
__exportStar(require("./augments/function"), exports);
|
|
26
26
|
__exportStar(require("./augments/object/enum"), exports);
|
|
27
|
+
__exportStar(require("./augments/object/filter-object"), exports);
|
|
28
|
+
__exportStar(require("./augments/object/jsonify"), exports);
|
|
27
29
|
__exportStar(require("./augments/object/map-object"), exports);
|
|
28
30
|
__exportStar(require("./augments/object/matches-object-shape"), exports);
|
|
29
31
|
__exportStar(require("./augments/object/nested-keys"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PropertyValueType } from './object';
|
|
2
|
+
export declare function filterObject<ObjectGeneric>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: PropertyValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
3
|
+
export declare function omitObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, omitTheseKeys: ReadonlyArray<KeyGeneric>): Omit<ObjectGeneric, KeyGeneric>;
|
|
4
|
+
export declare function pickObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, pickTheseKeys: ReadonlyArray<KeyGeneric>): Pick<ObjectGeneric, KeyGeneric>;
|
|
5
|
+
//# sourceMappingURL=filter-object.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getObjectTypedKeys } from './object-entries';
|
|
2
|
+
export function filterObject(inputObject, callback) {
|
|
3
|
+
const filteredKeys = getObjectTypedKeys(inputObject).filter((key) => {
|
|
4
|
+
const value = inputObject[key];
|
|
5
|
+
return callback(key, value, inputObject);
|
|
6
|
+
});
|
|
7
|
+
return filteredKeys.reduce((accum, key) => {
|
|
8
|
+
accum[key] = inputObject[key];
|
|
9
|
+
return accum;
|
|
10
|
+
}, {});
|
|
11
|
+
}
|
|
12
|
+
export function omitObjectKeys(inputObject, omitTheseKeys) {
|
|
13
|
+
return filterObject(inputObject, (currentKey) => {
|
|
14
|
+
return !omitTheseKeys.includes(currentKey);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function pickObjectKeys(inputObject, pickTheseKeys) {
|
|
18
|
+
return filterObject(inputObject, (currentKey) => {
|
|
19
|
+
return pickTheseKeys.includes(currentKey);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { UnionToIntersection } from 'type-fest';
|
|
2
|
-
import {
|
|
3
|
-
export type NestedSequentialKeys<ObjectGeneric extends object> =
|
|
2
|
+
import { PropertyValueType } from './object';
|
|
3
|
+
export type NestedSequentialKeys<ObjectGeneric extends object> = PropertyValueType<{
|
|
4
4
|
[Prop in keyof ObjectGeneric]: NonNullable<ObjectGeneric[Prop]> extends object ? [Prop, ...(NestedSequentialKeys<NonNullable<ObjectGeneric[Prop]>> | [])] : [Prop];
|
|
5
5
|
}>;
|
|
6
|
-
export type NestedKeys<ObjectGeneric extends object> = UnionToIntersection<Extract<
|
|
6
|
+
export type NestedKeys<ObjectGeneric extends object> = UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>> extends object ? [
|
|
7
7
|
keyof ObjectGeneric,
|
|
8
|
-
...(NestedKeys<UnionToIntersection<Extract<
|
|
8
|
+
...(NestedKeys<UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>>> | [])
|
|
9
9
|
] : [keyof ObjectGeneric];
|
|
10
10
|
export type NestedValue<ObjectGeneric extends object, NestedKeysGeneric extends NestedSequentialKeys<ObjectGeneric>> = NestedKeysGeneric extends readonly [infer FirstEntry, ...infer FollowingEntries] ? FirstEntry extends keyof ObjectGeneric ? FollowingEntries extends never[] ? ObjectGeneric[FirstEntry] : ObjectGeneric[FirstEntry] extends object ? FollowingEntries extends NestedSequentialKeys<ObjectGeneric[FirstEntry]> ? NestedValue<ObjectGeneric[FirstEntry], FollowingEntries> : never : never : never : never;
|
|
11
11
|
export declare function getValueFromNestedKeys<ObjectGeneric extends object, KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(inputObject: ObjectGeneric, nestedKeys: KeysGeneric): NestedValue<ObjectGeneric, KeysGeneric> | undefined;
|
|
@@ -3,8 +3,7 @@ export type PartialWithNullable<T extends object> = {
|
|
|
3
3
|
};
|
|
4
4
|
export declare function isObject(input: any): input is NonNullable<object>;
|
|
5
5
|
export declare function areJsonEqual(a: object, b: object): boolean;
|
|
6
|
-
export declare function filterObject<ObjectGeneric extends object>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: ObjectValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
7
6
|
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
8
7
|
export declare function copyThroughJson<T>(input: T): T;
|
|
9
|
-
export type
|
|
8
|
+
export type PropertyValueType<T> = T[keyof T];
|
|
10
9
|
//# sourceMappingURL=object.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEntriesSortedByKey
|
|
1
|
+
import { getEntriesSortedByKey } from './object-entries';
|
|
2
2
|
export function isObject(input) {
|
|
3
3
|
return !!input && typeof input === 'object';
|
|
4
4
|
}
|
|
@@ -13,16 +13,6 @@ export function areJsonEqual(a, b) {
|
|
|
13
13
|
throw error;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
export function filterObject(inputObject, callback) {
|
|
17
|
-
const filteredKeys = getObjectTypedKeys(inputObject).filter((key) => {
|
|
18
|
-
const value = inputObject[key];
|
|
19
|
-
return callback(key, value, inputObject);
|
|
20
|
-
});
|
|
21
|
-
return filteredKeys.reduce((accum, key) => {
|
|
22
|
-
accum[key] = inputObject[key];
|
|
23
|
-
return accum;
|
|
24
|
-
}, {});
|
|
25
|
-
}
|
|
26
16
|
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
27
17
|
export function copyThroughJson(input) {
|
|
28
18
|
try {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './augments/environment';
|
|
|
8
8
|
export * from './augments/error';
|
|
9
9
|
export * from './augments/function';
|
|
10
10
|
export * from './augments/object/enum';
|
|
11
|
+
export * from './augments/object/filter-object';
|
|
12
|
+
export * from './augments/object/jsonify';
|
|
11
13
|
export * from './augments/object/map-object';
|
|
12
14
|
export * from './augments/object/matches-object-shape';
|
|
13
15
|
export * from './augments/object/nested-keys';
|
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export * from './augments/environment';
|
|
|
8
8
|
export * from './augments/error';
|
|
9
9
|
export * from './augments/function';
|
|
10
10
|
export * from './augments/object/enum';
|
|
11
|
+
export * from './augments/object/filter-object';
|
|
12
|
+
export * from './augments/object/jsonify';
|
|
11
13
|
export * from './augments/object/map-object';
|
|
12
14
|
export * from './augments/object/matches-object-shape';
|
|
13
15
|
export * from './augments/object/nested-keys';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PropertyValueType } from './object';
|
|
2
|
+
export declare function filterObject<ObjectGeneric>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: PropertyValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
3
|
+
export declare function omitObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, omitTheseKeys: ReadonlyArray<KeyGeneric>): Omit<ObjectGeneric, KeyGeneric>;
|
|
4
|
+
export declare function pickObjectKeys<ObjectGeneric, KeyGeneric extends keyof ObjectGeneric>(inputObject: Readonly<ObjectGeneric>, pickTheseKeys: ReadonlyArray<KeyGeneric>): Pick<ObjectGeneric, KeyGeneric>;
|
|
5
|
+
//# sourceMappingURL=filter-object.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { UnionToIntersection } from 'type-fest';
|
|
2
|
-
import {
|
|
3
|
-
export type NestedSequentialKeys<ObjectGeneric extends object> =
|
|
2
|
+
import { PropertyValueType } from './object';
|
|
3
|
+
export type NestedSequentialKeys<ObjectGeneric extends object> = PropertyValueType<{
|
|
4
4
|
[Prop in keyof ObjectGeneric]: NonNullable<ObjectGeneric[Prop]> extends object ? [Prop, ...(NestedSequentialKeys<NonNullable<ObjectGeneric[Prop]>> | [])] : [Prop];
|
|
5
5
|
}>;
|
|
6
|
-
export type NestedKeys<ObjectGeneric extends object> = UnionToIntersection<Extract<
|
|
6
|
+
export type NestedKeys<ObjectGeneric extends object> = UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>> extends object ? [
|
|
7
7
|
keyof ObjectGeneric,
|
|
8
|
-
...(NestedKeys<UnionToIntersection<Extract<
|
|
8
|
+
...(NestedKeys<UnionToIntersection<Extract<PropertyValueType<ObjectGeneric>, object>>> | [])
|
|
9
9
|
] : [keyof ObjectGeneric];
|
|
10
10
|
export type NestedValue<ObjectGeneric extends object, NestedKeysGeneric extends NestedSequentialKeys<ObjectGeneric>> = NestedKeysGeneric extends readonly [infer FirstEntry, ...infer FollowingEntries] ? FirstEntry extends keyof ObjectGeneric ? FollowingEntries extends never[] ? ObjectGeneric[FirstEntry] : ObjectGeneric[FirstEntry] extends object ? FollowingEntries extends NestedSequentialKeys<ObjectGeneric[FirstEntry]> ? NestedValue<ObjectGeneric[FirstEntry], FollowingEntries> : never : never : never : never;
|
|
11
11
|
export declare function getValueFromNestedKeys<ObjectGeneric extends object, KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(inputObject: ObjectGeneric, nestedKeys: KeysGeneric): NestedValue<ObjectGeneric, KeysGeneric> | undefined;
|
|
@@ -3,8 +3,7 @@ export type PartialWithNullable<T extends object> = {
|
|
|
3
3
|
};
|
|
4
4
|
export declare function isObject(input: any): input is NonNullable<object>;
|
|
5
5
|
export declare function areJsonEqual(a: object, b: object): boolean;
|
|
6
|
-
export declare function filterObject<ObjectGeneric extends object>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: ObjectValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
7
6
|
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
8
7
|
export declare function copyThroughJson<T>(input: T): T;
|
|
9
|
-
export type
|
|
8
|
+
export type PropertyValueType<T> = T[keyof T];
|
|
10
9
|
//# sourceMappingURL=object.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './augments/environment';
|
|
|
8
8
|
export * from './augments/error';
|
|
9
9
|
export * from './augments/function';
|
|
10
10
|
export * from './augments/object/enum';
|
|
11
|
+
export * from './augments/object/filter-object';
|
|
12
|
+
export * from './augments/object/jsonify';
|
|
11
13
|
export * from './augments/object/map-object';
|
|
12
14
|
export * from './augments/object/matches-object-shape';
|
|
13
15
|
export * from './augments/object/nested-keys';
|