@bemoje/object 0.2.12 → 0.2.13
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/cjs/index.d.ts +4 -3
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +4 -3
- package/cjs/index.js.map +1 -1
- package/cjs/lib/OView.d.ts +136 -0
- package/cjs/lib/OView.d.ts.map +1 -0
- package/cjs/lib/OView.js +308 -0
- package/cjs/lib/OView.js.map +1 -0
- package/cjs/lib/define.d.ts +10 -8
- package/cjs/lib/define.d.ts.map +1 -1
- package/cjs/lib/define.js +144 -8
- package/cjs/lib/define.js.map +1 -1
- package/cjs/lib/getConstructor.d.ts +1 -1
- package/cjs/lib/getConstructor.d.ts.map +1 -1
- package/cjs/lib/getConstructor.js.map +1 -1
- package/cjs/lib/hasOwnProp.d.ts +3 -0
- package/cjs/lib/hasOwnProp.d.ts.map +1 -0
- package/cjs/lib/hasOwnProp.js +8 -0
- package/cjs/lib/hasOwnProp.js.map +1 -0
- package/cjs/lib/inheritStaticMembers.d.ts +2 -2
- package/cjs/lib/inheritStaticMembers.d.ts.map +1 -1
- package/cjs/lib/inheritStaticMembers.js.map +1 -1
- package/cjs/lib/isPropEnum.d.ts +3 -0
- package/cjs/lib/isPropEnum.d.ts.map +1 -0
- package/cjs/lib/isPropEnum.js +8 -0
- package/cjs/lib/isPropEnum.js.map +1 -0
- package/cjs/lib/iterableFirstElement.d.ts.map +1 -1
- package/cjs/lib/iterableFirstElement.js +1 -3
- package/cjs/lib/iterableFirstElement.js.map +1 -1
- package/cjs/lib/iteratePrototypeChain.d.ts +4 -16
- package/cjs/lib/iteratePrototypeChain.d.ts.map +1 -1
- package/cjs/lib/iteratePrototypeChain.js +9 -41
- package/cjs/lib/iteratePrototypeChain.js.map +1 -1
- package/cjs/lib/objDeepFreeze.d.ts +2 -1
- package/cjs/lib/objDeepFreeze.d.ts.map +1 -1
- package/cjs/lib/objDeepFreeze.js.map +1 -1
- package/cjs/lib/objFilter.d.ts +1 -1
- package/cjs/lib/objFilter.d.ts.map +1 -1
- package/cjs/lib/objFilter.js +2 -2
- package/cjs/lib/objFilter.js.map +1 -1
- package/cjs/lib/objFilterMutable.d.ts +1 -1
- package/cjs/lib/objFilterMutable.d.ts.map +1 -1
- package/cjs/lib/objFilterMutable.js +2 -2
- package/cjs/lib/objFilterMutable.js.map +1 -1
- package/cjs/lib/objMap.d.ts +2 -1
- package/cjs/lib/objMap.d.ts.map +1 -1
- package/cjs/lib/objMap.js.map +1 -1
- package/cjs/lib/objSet.d.ts +2 -2
- package/cjs/lib/objSet.d.ts.map +1 -1
- package/cjs/lib/objSet.js +2 -1
- package/cjs/lib/objSet.js.map +1 -1
- package/cjs/lib/objUpdatePropertyDescriptors.d.ts +1 -1
- package/cjs/lib/objUpdatePropertyDescriptors.d.ts.map +1 -1
- package/cjs/lib/objUpdatePropertyDescriptors.js +1 -1
- package/cjs/lib/objUpdatePropertyDescriptors.js.map +1 -1
- package/cjs/lib/objWalk.d.ts +6 -12
- package/cjs/lib/objWalk.d.ts.map +1 -1
- package/cjs/lib/objWalk.js +9 -14
- package/cjs/lib/objWalk.js.map +1 -1
- package/cjs/lib/superChain.d.ts +5 -0
- package/cjs/lib/superChain.d.ts.map +1 -0
- package/cjs/lib/superChain.js +16 -0
- package/cjs/lib/superChain.js.map +1 -0
- package/package.json +1 -1
- package/cjs/lib/createObjectFactory.d.ts +0 -14
- package/cjs/lib/createObjectFactory.d.ts.map +0 -1
- package/cjs/lib/createObjectFactory.js +0 -48
- package/cjs/lib/createObjectFactory.js.map +0 -1
- package/cjs/lib/objClonePrimitiveProperties.d.ts +0 -8
- package/cjs/lib/objClonePrimitiveProperties.d.ts.map +0 -1
- package/cjs/lib/objClonePrimitiveProperties.js +0 -19
- package/cjs/lib/objClonePrimitiveProperties.js.map +0 -1
- package/cjs/lib/objOmitKeys.d.ts +0 -16
- package/cjs/lib/objOmitKeys.d.ts.map +0 -1
- package/cjs/lib/objOmitKeys.js +0 -23
- package/cjs/lib/objOmitKeys.js.map +0 -1
package/cjs/lib/objWalk.d.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
+
import { Any } from '@bemoje/types';
|
|
1
2
|
/**
|
|
2
3
|
* Recursively traverses an object and invokes a callback function for every encountered non-object value.
|
|
3
4
|
* The callback function is passed the non-object value and an array representing the path to the value.
|
|
4
5
|
* @param node - The object to be traversed.
|
|
5
|
-
* @param callback - The callback function to be invoked for every non-object value.
|
|
6
|
-
* @example ```ts
|
|
7
|
-
* const obj = { a: 1, b: { c: 2, d: [3, 4] } };
|
|
8
|
-
* objWalk(obj, (value, path) => {
|
|
9
|
-
* console.log(`Path: ${path.join('.')}, Value: ${value}`);
|
|
10
|
-
* });
|
|
11
|
-
* // Output:
|
|
12
|
-
* // Path: a, Value: 1
|
|
13
|
-
* // Path: b.c, Value: 2
|
|
14
|
-
* // Path: b.d[0], Value: 3
|
|
15
|
-
* // Path: b.d[1], Value: 4
|
|
16
6
|
* ```
|
|
17
7
|
*/
|
|
18
|
-
export declare function objWalk(node: Record<string,
|
|
8
|
+
export declare function objWalk(node: Record<string, Any>, callback: (type: 'primitive' | 'object' | 'array', value: Any, node: Any, path: string[]) => false | void, options?: {
|
|
9
|
+
noPrimitives?: boolean;
|
|
10
|
+
noArrays?: boolean;
|
|
11
|
+
noObjects?: boolean;
|
|
12
|
+
}): void;
|
|
19
13
|
//# sourceMappingURL=objWalk.d.ts.map
|
package/cjs/lib/objWalk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objWalk.d.ts","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objWalk.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"objWalk.d.ts","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objWalk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAEnC;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ,GAAG,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,KAAK,GAAG,IAAI,EACzG,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GAChF,IAAI,CAoBN"}
|
package/cjs/lib/objWalk.js
CHANGED
|
@@ -5,34 +5,29 @@ exports.objWalk = void 0;
|
|
|
5
5
|
* Recursively traverses an object and invokes a callback function for every encountered non-object value.
|
|
6
6
|
* The callback function is passed the non-object value and an array representing the path to the value.
|
|
7
7
|
* @param node - The object to be traversed.
|
|
8
|
-
* @param callback - The callback function to be invoked for every non-object value.
|
|
9
|
-
* @example ```ts
|
|
10
|
-
* const obj = { a: 1, b: { c: 2, d: [3, 4] } };
|
|
11
|
-
* objWalk(obj, (value, path) => {
|
|
12
|
-
* console.log(`Path: ${path.join('.')}, Value: ${value}`);
|
|
13
|
-
* });
|
|
14
|
-
* // Output:
|
|
15
|
-
* // Path: a, Value: 1
|
|
16
|
-
* // Path: b.c, Value: 2
|
|
17
|
-
* // Path: b.d[0], Value: 3
|
|
18
|
-
* // Path: b.d[1], Value: 4
|
|
19
8
|
* ```
|
|
20
9
|
*/
|
|
21
|
-
function objWalk(node, callback) {
|
|
10
|
+
function objWalk(node, callback, options = {}) {
|
|
11
|
+
const { noPrimitives, noArrays, noObjects } = options;
|
|
22
12
|
function recurse(node, path = []) {
|
|
23
13
|
for (const [key, child] of Object.entries(node)) {
|
|
24
|
-
if (typeof child === 'object' && child
|
|
14
|
+
if (typeof child === 'object' && child != null) {
|
|
25
15
|
if (Array.isArray(child)) {
|
|
16
|
+
if (!noArrays && callback('array', child, node, path.concat(key)) === false)
|
|
17
|
+
continue;
|
|
26
18
|
child.forEach((node, index) => {
|
|
27
19
|
recurse(node, path.concat([`${key}[${index}]`]));
|
|
28
20
|
});
|
|
29
21
|
}
|
|
30
22
|
else {
|
|
23
|
+
if (!noObjects && callback('object', child, node, path.concat(key)) === false)
|
|
24
|
+
continue;
|
|
31
25
|
recurse(child, path.concat(key));
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
28
|
else {
|
|
35
|
-
callback(child, path.concat(key))
|
|
29
|
+
if (!noPrimitives && callback('array', child, node, path.concat(key)) === false)
|
|
30
|
+
continue;
|
|
36
31
|
}
|
|
37
32
|
}
|
|
38
33
|
}
|
package/cjs/lib/objWalk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objWalk.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objWalk.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"objWalk.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objWalk.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,OAAO,CACrB,IAAyB,EACzB,QAAyG,EACzG,UAA+E,EAAE;IAEjF,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IACrD,SAAS,OAAO,CAAC,IAAyB,EAAE,OAAiB,EAAE;QAC7D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE;gBAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACxB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;wBAAE,SAAQ;oBACrF,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;wBAC5B,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;oBAClD,CAAC,CAAC,CAAA;iBACH;qBAAM;oBACL,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;wBAAE,SAAQ;oBACvF,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;iBACjC;aACF;iBAAM;gBACL,IAAI,CAAC,YAAY,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;oBAAE,SAAQ;aAC1F;SACF;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAA;AACf,CAAC;AAxBD,0BAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"superChain.d.ts","sourceRoot":"","sources":["../../../../../packages/object/src/lib/superChain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE1D,wBAAgB,UAAU,CAAC,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,CAAC,YAAY,CAAC,CAMhH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.superChain = void 0;
|
|
4
|
+
const is_1 = require("@bemoje/is");
|
|
5
|
+
function superChain(o, opts) {
|
|
6
|
+
console.log(o);
|
|
7
|
+
if ((0, is_1.isObject)(o))
|
|
8
|
+
o = Object.getPrototypeOf(o).constructor;
|
|
9
|
+
if (typeof o !== 'function')
|
|
10
|
+
throw new Error('Expected object or constructor.');
|
|
11
|
+
if (!o.name || o === Object)
|
|
12
|
+
return [Object];
|
|
13
|
+
return (opts?.excludeSelf ? [] : [o]).concat(superChain(Object.getPrototypeOf(o)));
|
|
14
|
+
}
|
|
15
|
+
exports.superChain = superChain;
|
|
16
|
+
//# sourceMappingURL=superChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"superChain.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/superChain.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAGrC,SAAgB,UAAU,CAAC,CAA8B,EAAE,IAAgC;IACzF,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACd,IAAI,IAAA,aAAQ,EAAC,CAAC,CAAC;QAAE,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;IACzD,IAAI,OAAO,CAAC,KAAK,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IAC/E,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,MAAM;QAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAC5C,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAwB,CAAA;AAC3G,CAAC;AAND,gCAMC"}
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a factory function for creating objects with specified keys and default values.
|
|
3
|
-
* @template T The type of the values.
|
|
4
|
-
* @param keys An array of strings representing the keys of the objects to be created.
|
|
5
|
-
* @param defaultValues An optional array of default values for the keys. If provided, its length should not be larger than the length of the keys array.
|
|
6
|
-
* @returns An `ObjectFactory` function. When called, this function takes an optional array of values and returns an object with the specified keys and values. If the values array is not provided or if a value is `undefined`, the corresponding default value is used.
|
|
7
|
-
* @throws If the length of the `defaultValues` array is larger than the length of the `keys` array, or if the length of the `values` array passed to the factory function is larger than the length of the `keys` array.
|
|
8
|
-
* @example ```ts
|
|
9
|
-
* createObjectFactory(['key1', 'key2'], ['default1', 'default2'])(['value1']);
|
|
10
|
-
* //=> { key1: 'value1', key2: 'default2' }
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare function createObjectFactory<T>(keys: string[], defaultValues?: T[]): (values?: T[]) => Record<string, T>;
|
|
14
|
-
//# sourceMappingURL=createObjectFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createObjectFactory.d.ts","sourceRoot":"","sources":["../../../../../packages/object/src/lib/createObjectFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,aAAa,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CA6B/G"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createObjectFactory = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Creates a factory function for creating objects with specified keys and default values.
|
|
6
|
-
* @template T The type of the values.
|
|
7
|
-
* @param keys An array of strings representing the keys of the objects to be created.
|
|
8
|
-
* @param defaultValues An optional array of default values for the keys. If provided, its length should not be larger than the length of the keys array.
|
|
9
|
-
* @returns An `ObjectFactory` function. When called, this function takes an optional array of values and returns an object with the specified keys and values. If the values array is not provided or if a value is `undefined`, the corresponding default value is used.
|
|
10
|
-
* @throws If the length of the `defaultValues` array is larger than the length of the `keys` array, or if the length of the `values` array passed to the factory function is larger than the length of the `keys` array.
|
|
11
|
-
* @example ```ts
|
|
12
|
-
* createObjectFactory(['key1', 'key2'], ['default1', 'default2'])(['value1']);
|
|
13
|
-
* //=> { key1: 'value1', key2: 'default2' }
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
function createObjectFactory(keys, defaultValues) {
|
|
17
|
-
const numKeys = keys.length;
|
|
18
|
-
if (defaultValues && defaultValues.length > numKeys) {
|
|
19
|
-
throw new Error('defaultValues length larger than keys length.');
|
|
20
|
-
}
|
|
21
|
-
return function factory(values) {
|
|
22
|
-
if (values && values.length > numKeys) {
|
|
23
|
-
throw new Error('values length larger than keys length.');
|
|
24
|
-
}
|
|
25
|
-
const o = {};
|
|
26
|
-
for (let i = 0; i < numKeys; i++) {
|
|
27
|
-
let value;
|
|
28
|
-
if (values) {
|
|
29
|
-
value = values[i];
|
|
30
|
-
if (value === undefined && defaultValues) {
|
|
31
|
-
value = defaultValues[i];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else if (defaultValues) {
|
|
35
|
-
value = defaultValues[i];
|
|
36
|
-
}
|
|
37
|
-
Object.defineProperty(o, keys[i], {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
value,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return o;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
exports.createObjectFactory = createObjectFactory;
|
|
48
|
-
//# sourceMappingURL=createObjectFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createObjectFactory.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/createObjectFactory.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,SAAgB,mBAAmB,CAAI,IAAc,EAAE,aAAmB;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAA;IAC3B,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,OAAO,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;KACjE;IACD,OAAO,SAAS,OAAO,CAAC,MAAY;QAClC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,OAAO,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;SAC1D;QACD,MAAM,CAAC,GAAG,EAAE,CAAA;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE;YAChC,IAAI,KAAK,CAAA;YACT,IAAI,MAAM,EAAE;gBACV,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;gBACjB,IAAI,KAAK,KAAK,SAAS,IAAI,aAAa,EAAE;oBACxC,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;iBACzB;aACF;iBAAM,IAAI,aAAa,EAAE;gBACxB,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;aACzB;YACD,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE;gBAChC,UAAU,EAAE,IAAI;gBAChB,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;gBAClB,KAAK;aACN,CAAC,CAAA;SACH;QACD,OAAO,CAAC,CAAA;IACV,CAAC,CAAA;AACH,CAAC;AA7BD,kDA6BC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ObjectKey } from '@bemoje/types';
|
|
2
|
-
import { TPrimitive } from '@bemoje/types';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a shallow clone of an object, but replaces all non-primitive values with a string representation of the value's type.
|
|
5
|
-
* @param o - The object to clone.
|
|
6
|
-
*/
|
|
7
|
-
export declare function objClonePrimitiveProperties(o: Record<ObjectKey, unknown>): Record<ObjectKey, TPrimitive>;
|
|
8
|
-
//# sourceMappingURL=objClonePrimitiveProperties.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objClonePrimitiveProperties.d.ts","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objClonePrimitiveProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAMxG"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objClonePrimitiveProperties = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Creates a shallow clone of an object, but replaces all non-primitive values with a string representation of the value's type.
|
|
6
|
-
* @param o - The object to clone.
|
|
7
|
-
*/
|
|
8
|
-
function objClonePrimitiveProperties(o) {
|
|
9
|
-
const clone = {};
|
|
10
|
-
for (const [key, value] of Object.entries(o)) {
|
|
11
|
-
clone[key] = isPrimitive(value) ? value : `[${Object.getPrototypeOf(value).constructor.name}]`;
|
|
12
|
-
}
|
|
13
|
-
return clone;
|
|
14
|
-
}
|
|
15
|
-
exports.objClonePrimitiveProperties = objClonePrimitiveProperties;
|
|
16
|
-
function isPrimitive(value) {
|
|
17
|
-
return (typeof value !== 'object' && typeof value !== 'function') || value === null;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=objClonePrimitiveProperties.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objClonePrimitiveProperties.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objClonePrimitiveProperties.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,CAA6B;IACvE,MAAM,KAAK,GAAkC,EAAE,CAAA;IAC/C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC5C,KAAK,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,IAAI,GAAG,CAAA;KAC/F;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAND,kEAMC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,CAAA;AACrF,CAAC"}
|
package/cjs/lib/objOmitKeys.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Any } from '@bemoje/types';
|
|
2
|
-
import { ObjectKey } from '@bemoje/types';
|
|
3
|
-
/**
|
|
4
|
-
* Deletes specified keys from an object. This function takes an object and an array of keys to be deleted from the object. It returns a new object with the specified keys removed.
|
|
5
|
-
* @param obj The object from which keys are to be deleted.
|
|
6
|
-
* @template V - The type of the values in the object.
|
|
7
|
-
* @returns A new object with the specified keys deleted.
|
|
8
|
-
* @param keys The keys to be deleted from the object.
|
|
9
|
-
* @example ```ts
|
|
10
|
-
* const obj = { a: 1, b: 2, c: 3 };
|
|
11
|
-
* objOmitKeys(obj, 'a', 'c');
|
|
12
|
-
* //=> { b: 2 }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function objOmitKeys<O extends Record<ObjectKey, Any>>(obj: O, ...keys: ObjectKey[]): Partial<O>;
|
|
16
|
-
//# sourceMappingURL=objOmitKeys.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objOmitKeys.d.ts","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objOmitKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,cAIzF"}
|
package/cjs/lib/objOmitKeys.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objOmitKeys = void 0;
|
|
4
|
-
const objFilter_1 = require("./objFilter");
|
|
5
|
-
/**
|
|
6
|
-
* Deletes specified keys from an object. This function takes an object and an array of keys to be deleted from the object. It returns a new object with the specified keys removed.
|
|
7
|
-
* @param obj The object from which keys are to be deleted.
|
|
8
|
-
* @template V - The type of the values in the object.
|
|
9
|
-
* @returns A new object with the specified keys deleted.
|
|
10
|
-
* @param keys The keys to be deleted from the object.
|
|
11
|
-
* @example ```ts
|
|
12
|
-
* const obj = { a: 1, b: 2, c: 3 };
|
|
13
|
-
* objOmitKeys(obj, 'a', 'c');
|
|
14
|
-
* //=> { b: 2 }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
function objOmitKeys(obj, ...keys) {
|
|
18
|
-
return (0, objFilter_1.objFilter)(obj, (_, key) => {
|
|
19
|
-
return !keys.includes(key);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
exports.objOmitKeys = objOmitKeys;
|
|
23
|
-
//# sourceMappingURL=objOmitKeys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objOmitKeys.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objOmitKeys.ts"],"names":[],"mappings":";;;AAEA,2CAAuC;AAEvC;;;;;;;;;;;GAWG;AACH,SAAgB,WAAW,CAAmC,GAAM,EAAE,GAAG,IAAiB;IACxF,OAAO,IAAA,qBAAS,EAAI,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;QAClC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAJD,kCAIC"}
|