@bemoje/object 0.0.10 → 0.2.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 +6 -34
- package/package.json +10 -10
- package/{dist/types → src}/index.d.ts +0 -1
- package/src/index.js +47 -0
- package/src/index.js.map +1 -0
- package/{dist/types → src}/lib/createObjectFactory.d.ts +0 -1
- package/src/lib/createObjectFactory.js +48 -0
- package/src/lib/createObjectFactory.js.map +1 -0
- package/{dist/types → src}/lib/getConstructor.d.ts +0 -1
- package/src/lib/getConstructor.js +19 -0
- package/src/lib/getConstructor.js.map +1 -0
- package/{dist/types → src}/lib/inheritStaticMembers.d.ts +0 -1
- package/src/lib/inheritStaticMembers.js +40 -0
- package/src/lib/inheritStaticMembers.js.map +1 -0
- package/{dist/types → src}/lib/iterableFirstElement.d.ts +0 -1
- package/src/lib/iterableFirstElement.js +19 -0
- package/src/lib/iterableFirstElement.js.map +1 -0
- package/{dist/types → src}/lib/iteratePrototypeChain.d.ts +0 -1
- package/src/lib/iteratePrototypeChain.js +44 -0
- package/src/lib/iteratePrototypeChain.js.map +1 -0
- package/{dist/types → src}/lib/objDeepFreeze.d.ts +0 -1
- package/src/lib/objDeepFreeze.js +42 -0
- package/src/lib/objDeepFreeze.js.map +1 -0
- package/{dist/types → src}/lib/objDelete.d.ts +0 -1
- package/src/lib/objDelete.js +21 -0
- package/src/lib/objDelete.js.map +1 -0
- package/{dist/types → src}/lib/objEntries.d.ts +0 -1
- package/src/lib/objEntries.js +21 -0
- package/src/lib/objEntries.js.map +1 -0
- package/{dist/types → src}/lib/objEntriesArray.d.ts +0 -1
- package/src/lib/objEntriesArray.js +21 -0
- package/src/lib/objEntriesArray.js.map +1 -0
- package/{dist/types → src}/lib/objFilter.d.ts +0 -1
- package/src/lib/objFilter.js +28 -0
- package/src/lib/objFilter.js.map +1 -0
- package/{dist/types → src}/lib/objForEach.d.ts +0 -1
- package/src/lib/objForEach.js +26 -0
- package/src/lib/objForEach.js.map +1 -0
- package/{dist/types → src}/lib/objGet.d.ts +0 -1
- package/src/lib/objGet.js +24 -0
- package/src/lib/objGet.js.map +1 -0
- package/{dist/types → src}/lib/objGetOrElse.d.ts +0 -1
- package/src/lib/objGetOrElse.js +24 -0
- package/src/lib/objGetOrElse.js.map +1 -0
- package/{dist/types → src}/lib/objHas.d.ts +0 -1
- package/src/lib/objHas.js +22 -0
- package/src/lib/objHas.js.map +1 -0
- package/{dist/types → src}/lib/objIsEmpty.d.ts +0 -1
- package/src/lib/objIsEmpty.js +28 -0
- package/src/lib/objIsEmpty.js.map +1 -0
- package/{dist/types → src}/lib/objKeys.d.ts +0 -1
- package/src/lib/objKeys.js +22 -0
- package/src/lib/objKeys.js.map +1 -0
- package/{dist/types → src}/lib/objKeysArray.d.ts +0 -1
- package/src/lib/objKeysArray.js +20 -0
- package/src/lib/objKeysArray.js.map +1 -0
- package/{dist/types → src}/lib/objMap.d.ts +0 -1
- package/src/lib/objMap.js +26 -0
- package/src/lib/objMap.js.map +1 -0
- package/{dist/types → src}/lib/objMapKeys.d.ts +0 -1
- package/src/lib/objMapKeys.js +27 -0
- package/src/lib/objMapKeys.js.map +1 -0
- package/{dist/types → src}/lib/objMapMutable.d.ts +0 -1
- package/src/lib/objMapMutable.js +26 -0
- package/src/lib/objMapMutable.js.map +1 -0
- package/{dist/types → src}/lib/objOmitKeys.d.ts +0 -1
- package/src/lib/objOmitKeys.js +21 -0
- package/src/lib/objOmitKeys.js.map +1 -0
- package/{dist/types → src}/lib/objOmitKeysMutable.d.ts +0 -1
- package/src/lib/objOmitKeysMutable.js +23 -0
- package/src/lib/objOmitKeysMutable.js.map +1 -0
- package/{dist/types → src}/lib/objPropertyValueToGetter.d.ts +0 -1
- package/src/lib/objPropertyValueToGetter.js +35 -0
- package/src/lib/objPropertyValueToGetter.js.map +1 -0
- package/{dist/types → src}/lib/objReduce.d.ts +0 -1
- package/src/lib/objReduce.js +28 -0
- package/src/lib/objReduce.js.map +1 -0
- package/{dist/types → src}/lib/objReverse.d.ts +0 -1
- package/src/lib/objReverse.js +20 -0
- package/src/lib/objReverse.js.map +1 -0
- package/{dist/types → src}/lib/objSet.d.ts +0 -1
- package/src/lib/objSet.js +21 -0
- package/src/lib/objSet.js.map +1 -0
- package/{dist/types → src}/lib/objSize.d.ts +0 -1
- package/src/lib/objSize.js +19 -0
- package/src/lib/objSize.js.map +1 -0
- package/{dist/types → src}/lib/objSortKeys.d.ts +0 -1
- package/src/lib/objSortKeys.js +20 -0
- package/src/lib/objSortKeys.js.map +1 -0
- package/{dist/types → src}/lib/objToMap.d.ts +0 -1
- package/src/lib/objToMap.js +23 -0
- package/src/lib/objToMap.js.map +1 -0
- package/{dist/types → src}/lib/objUpdate.d.ts +0 -1
- package/src/lib/objUpdate.js +20 -0
- package/src/lib/objUpdate.js.map +1 -0
- package/{dist/types → src}/lib/objUpdatePropertyDescriptors.d.ts +0 -1
- package/src/lib/objUpdatePropertyDescriptors.js +28 -0
- package/src/lib/objUpdatePropertyDescriptors.js.map +1 -0
- package/{dist/types → src}/lib/objValues.d.ts +0 -1
- package/src/lib/objValues.js +26 -0
- package/src/lib/objValues.js.map +1 -0
- package/{dist/types → src}/lib/objValuesArray.d.ts +0 -1
- package/src/lib/objValuesArray.js +20 -0
- package/src/lib/objValuesArray.js.map +1 -0
- package/{dist/types → src}/lib/objWalk.d.ts +0 -1
- package/src/lib/objWalk.js +42 -0
- package/src/lib/objWalk.js.map +1 -0
- package/{dist/types → src}/lib/setEnumerable.d.ts +0 -1
- package/src/lib/setEnumerable.js +28 -0
- package/src/lib/setEnumerable.js.map +1 -0
- package/{dist/types → src}/lib/setNonConfigurable.d.ts +0 -1
- package/src/lib/setNonConfigurable.js +30 -0
- package/src/lib/setNonConfigurable.js.map +1 -0
- package/{dist/types → src}/lib/setNonEnumerable.d.ts +0 -1
- package/src/lib/setNonEnumerable.js +25 -0
- package/src/lib/setNonEnumerable.js.map +1 -0
- package/{dist/types → src}/lib/setNonWritable.d.ts +0 -1
- package/src/lib/setNonWritable.js +31 -0
- package/src/lib/setNonWritable.js.map +1 -0
- package/{dist/types → src}/lib/setWritable.d.ts +0 -1
- package/src/lib/setWritable.js +26 -0
- package/src/lib/setWritable.js.map +1 -0
- package/{dist/types → src}/lib/toJson.d.ts +0 -1
- package/src/lib/toJson.js +19 -0
- package/src/lib/toJson.js.map +1 -0
- package/{dist/types → src}/types/Constructor.d.ts +0 -1
- package/src/types/Constructor.js +3 -0
- package/src/types/Constructor.js.map +1 -0
- package/{dist/types → src}/types/ConstructorOf.d.ts +0 -1
- package/src/types/ConstructorOf.js +3 -0
- package/src/types/ConstructorOf.js.map +1 -0
- package/{dist/types → src}/types/ObjectKey.d.ts +0 -1
- package/src/types/ObjectKey.js +3 -0
- package/src/types/ObjectKey.js.map +1 -0
- package/LICENSE +0 -21
- package/dist/index.cjs.js +0 -6
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -6
- package/dist/index.esm.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/lib/createObjectFactory.d.ts.map +0 -1
- package/dist/types/lib/getConstructor.d.ts.map +0 -1
- package/dist/types/lib/inheritStaticMembers.d.ts.map +0 -1
- package/dist/types/lib/iterableFirstElement.d.ts.map +0 -1
- package/dist/types/lib/iteratePrototypeChain.d.ts.map +0 -1
- package/dist/types/lib/objDeepFreeze.d.ts.map +0 -1
- package/dist/types/lib/objDelete.d.ts.map +0 -1
- package/dist/types/lib/objEntries.d.ts.map +0 -1
- package/dist/types/lib/objEntriesArray.d.ts.map +0 -1
- package/dist/types/lib/objFilter.d.ts.map +0 -1
- package/dist/types/lib/objForEach.d.ts.map +0 -1
- package/dist/types/lib/objGet.d.ts.map +0 -1
- package/dist/types/lib/objGetOrElse.d.ts.map +0 -1
- package/dist/types/lib/objHas.d.ts.map +0 -1
- package/dist/types/lib/objIsEmpty.d.ts.map +0 -1
- package/dist/types/lib/objKeys.d.ts.map +0 -1
- package/dist/types/lib/objKeysArray.d.ts.map +0 -1
- package/dist/types/lib/objMap.d.ts.map +0 -1
- package/dist/types/lib/objMapKeys.d.ts.map +0 -1
- package/dist/types/lib/objMapMutable.d.ts.map +0 -1
- package/dist/types/lib/objOmitKeys.d.ts.map +0 -1
- package/dist/types/lib/objOmitKeysMutable.d.ts.map +0 -1
- package/dist/types/lib/objPropertyValueToGetter.d.ts.map +0 -1
- package/dist/types/lib/objReduce.d.ts.map +0 -1
- package/dist/types/lib/objReverse.d.ts.map +0 -1
- package/dist/types/lib/objSet.d.ts.map +0 -1
- package/dist/types/lib/objSize.d.ts.map +0 -1
- package/dist/types/lib/objSortKeys.d.ts.map +0 -1
- package/dist/types/lib/objToMap.d.ts.map +0 -1
- package/dist/types/lib/objUpdate.d.ts.map +0 -1
- package/dist/types/lib/objUpdatePropertyDescriptors.d.ts.map +0 -1
- package/dist/types/lib/objValues.d.ts.map +0 -1
- package/dist/types/lib/objValuesArray.d.ts.map +0 -1
- package/dist/types/lib/objWalk.d.ts.map +0 -1
- package/dist/types/lib/setEnumerable.d.ts.map +0 -1
- package/dist/types/lib/setNonConfigurable.d.ts.map +0 -1
- package/dist/types/lib/setNonEnumerable.d.ts.map +0 -1
- package/dist/types/lib/setNonWritable.d.ts.map +0 -1
- package/dist/types/lib/setWritable.d.ts.map +0 -1
- package/dist/types/lib/toJson.d.ts.map +0 -1
- package/dist/types/types/Constructor.d.ts.map +0 -1
- package/dist/types/types/ConstructorOf.d.ts.map +0 -1
- package/dist/types/types/ObjectKey.d.ts.map +0 -1
- package/jest.config.ts +0 -13
- package/project.json +0 -30
- package/tsconfig.spec.json +0 -9
|
@@ -13,4 +13,3 @@ import { ObjectKey } from '../types/ObjectKey';
|
|
|
13
13
|
* @typeparam V - The type of the values in the object.
|
|
14
14
|
*/
|
|
15
15
|
export declare function objGetOrElse<V>(obj: Record<ObjectKey, V>, key: ObjectKey, callback: (key: ObjectKey) => V): V;
|
|
16
|
-
//# sourceMappingURL=objGetOrElse.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objGetOrElse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This function attempts to retrieve a value from an object using a provided key.
|
|
6
|
+
* If the key does not exist in the object, it uses a callback function to generate a default value.
|
|
7
|
+
* @param obj The object from which to retrieve the value.
|
|
8
|
+
* @param key The key to use when retrieving the value.
|
|
9
|
+
* @param callback The function to call when the key does not exist in the object. This function should return the default value.
|
|
10
|
+
* @returns The value associated with the key in the object, or the result of the callback function if the key does not exist in the object.
|
|
11
|
+
* @example ```ts
|
|
12
|
+
* objGetOrElse({ a: 1, b: 2 }, 'c', (key) => 3);;
|
|
13
|
+
* //=> 3
|
|
14
|
+
* ```
|
|
15
|
+
* @typeparam V - The type of the values in the object.
|
|
16
|
+
*/
|
|
17
|
+
function objGetOrElse(obj, key, callback) {
|
|
18
|
+
const value = obj[key];
|
|
19
|
+
if (value !== undefined)
|
|
20
|
+
return value;
|
|
21
|
+
return (obj[key] = callback(key));
|
|
22
|
+
}
|
|
23
|
+
exports.objGetOrElse = objGetOrElse;
|
|
24
|
+
//# sourceMappingURL=objGetOrElse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objGetOrElse.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objGetOrElse.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;GAYG;AACH,SAAgB,YAAY,CAAI,GAAyB,EAAE,GAAc,EAAE,QAA+B;IACxG,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;IACtB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IACrC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;AACnC,CAAC;AAJD,oCAIC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objHas = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if an object has a specific key.
|
|
6
|
+
* @param obj The object to check.
|
|
7
|
+
* @template K - The type of the keys in the object.
|
|
8
|
+
* @returns Returns true if the object has the key, false otherwise.
|
|
9
|
+
* @param key The key to check for.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* const myObj = { name: 'John', age: 30 };
|
|
12
|
+
* objHas(myObj, 'name');
|
|
13
|
+
* //=> true
|
|
14
|
+
* objHas(myObj, 'email');
|
|
15
|
+
* //=> false
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function objHas(obj, key) {
|
|
19
|
+
return Object.hasOwn(obj, key);
|
|
20
|
+
}
|
|
21
|
+
exports.objHas = objHas;
|
|
22
|
+
//# sourceMappingURL=objHas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objHas.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objHas.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;GAaG;AACH,SAAgB,MAAM,CAAI,GAAyB,EAAE,GAAc;IACjE,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAChC,CAAC;AAFD,wBAEC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objIsEmpty = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if an object is empty. This function iterates over the keys of the provided object and checks if any key is defined.
|
|
6
|
+
* @remarks This function uses the `Object.keys()` method to check if the object has any keys.
|
|
7
|
+
* If the object has at least one key, the function returns `false`, otherwise it returns `true`.
|
|
8
|
+
* @typeparam T - The type of the values in the object.
|
|
9
|
+
* @returns A boolean indicating whether the object is empty or not.
|
|
10
|
+
* @param obj The object to check.
|
|
11
|
+
* @example ```ts
|
|
12
|
+
* const emptyObject = {};
|
|
13
|
+
* const nonEmptyObject = { key: 'value' };
|
|
14
|
+
* objIsEmpty(emptyObject);
|
|
15
|
+
* //=> true
|
|
16
|
+
* objIsEmpty(nonEmptyObject);
|
|
17
|
+
* //=> false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function objIsEmpty(obj) {
|
|
21
|
+
for (const key of Object.keys(obj)) {
|
|
22
|
+
if (key !== undefined)
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
exports.objIsEmpty = objIsEmpty;
|
|
28
|
+
//# sourceMappingURL=objIsEmpty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objIsEmpty.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objIsEmpty.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,UAAU,CAAI,GAAsB;IAClD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,KAAK,CAAA;KACpC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AALD,gCAKC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objKeys = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns an iterable of all the keys in the given object.
|
|
6
|
+
* @remarks This function is a part of the `utils` module.
|
|
7
|
+
* @typeparam V - The type of the values in the object.
|
|
8
|
+
* @returns An iterable of the object's keys.
|
|
9
|
+
* @param obj The object whose keys to iterate over.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
12
|
+
* const keys = objKeys(obj);
|
|
13
|
+
* for (const key of keys) {
|
|
14
|
+
* //=> //=> //=> c
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function* objKeys(obj) {
|
|
19
|
+
yield* Object.keys(obj);
|
|
20
|
+
}
|
|
21
|
+
exports.objKeys = objKeys;
|
|
22
|
+
//# sourceMappingURL=objKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objKeys.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objKeys.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;GAaG;AACH,QAAe,CAAC,CAAC,OAAO,CAAI,GAAyB;IACnD,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACzB,CAAC;AAFD,0BAEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objKeysArray = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns an array of keys from the provided object.
|
|
6
|
+
* @remarks This function is a part of Object Utilities.
|
|
7
|
+
* @typeparam V - The type of values in the object.
|
|
8
|
+
* @returns The array of keys of the input object.
|
|
9
|
+
* @param obj The object from which to extract the keys.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
12
|
+
* objKeysArray(obj);
|
|
13
|
+
* //=> ['a', 'b', 'c']
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function objKeysArray(obj) {
|
|
17
|
+
return Array.from(Object.keys(obj));
|
|
18
|
+
}
|
|
19
|
+
exports.objKeysArray = objKeysArray;
|
|
20
|
+
//# sourceMappingURL=objKeysArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objKeysArray.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objKeysArray.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACH,SAAgB,YAAY,CAAI,GAAyB;IACvD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AACrC,CAAC;AAFD,oCAEC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Maps over the values of an object and returns a new object with the mapped values.
|
|
6
|
+
* @param object The object to map over.
|
|
7
|
+
* @param callback The mapping function to apply to each value.
|
|
8
|
+
* @template T The type of the values in the input object.
|
|
9
|
+
* @param An optional function to determine the keys to iterate over. Defaults to `Object.keys`.
|
|
10
|
+
* @returns A new object with the same keys as the input object, but with each value transformed by the callback function.
|
|
11
|
+
* @param getKeys The function used to get the keys of the object.
|
|
12
|
+
* @example ```ts
|
|
13
|
+
* const object = { a: 1, b: 2, c: 3 }
|
|
14
|
+
* const callback = (value: number, key: string) => value * 2
|
|
15
|
+
* objMap(object, callback) //=> { a: 2, b: 4, c: 6 }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function objMap(object, callback, getKeys = Object.keys) {
|
|
19
|
+
const result = {};
|
|
20
|
+
for (const key of getKeys(object)) {
|
|
21
|
+
result[key] = callback(object[key], key);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
exports.objMap = objMap;
|
|
26
|
+
//# sourceMappingURL=objMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objMap.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objMap.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,SAAgB,MAAM,CACpB,MAAyB,EACzB,QAAsC,EACtC,UAAoD,MAAM,CAAC,IAAI;IAE/D,MAAM,MAAM,GAAsB,EAAE,CAAA;IACpC,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;KACzC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAVD,wBAUC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objMapKeys = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Maps the keys of an object using a callback function.
|
|
6
|
+
* @param object The object whose keys will be mapped.
|
|
7
|
+
* @param callback The callback function that maps the keys.
|
|
8
|
+
* @template T - The type of the values in the object.
|
|
9
|
+
* @param - The function to get the keys of the object.
|
|
10
|
+
* @returns A new object with the keys mapped.
|
|
11
|
+
* @param getKeys The function that retrieves the keys of the object.
|
|
12
|
+
* @example ```ts
|
|
13
|
+
* const object = { a: 1, b: 2, c: 3 };
|
|
14
|
+
* const callback = (key: string, value: number) => key.toUpperCase();
|
|
15
|
+
* objMapKeys(object, callback);
|
|
16
|
+
* //=> { A: 1, B: 2, C: 3 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function objMapKeys(object, callback, getKeys = Object.keys) {
|
|
20
|
+
const result = {};
|
|
21
|
+
for (const key of getKeys(object)) {
|
|
22
|
+
result[callback(key, object[key])] = object[key];
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
exports.objMapKeys = objMapKeys;
|
|
27
|
+
//# sourceMappingURL=objMapKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objMapKeys.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objMapKeys.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CACxB,MAAyB,EACzB,QAA2C,EAC3C,UAAoD,MAAM,CAAC,IAAI;IAE/D,MAAM,MAAM,GAAsB,EAAE,CAAA;IACpC,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;KACjD;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAVD,gCAUC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objMapMutable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Applies a callback function to each key-value pair in an object and mutates the object.
|
|
6
|
+
* @param object The object to be mapped.
|
|
7
|
+
* @param callback The callback function to apply to each valuekey pair.
|
|
8
|
+
* @template T - The type of the properties in the object.
|
|
9
|
+
* @param - An optional function to determine the keys to be iterated over.
|
|
10
|
+
* @returns The mutated object.
|
|
11
|
+
* @param getKeys The function used to get the keys of the object.
|
|
12
|
+
* @example ```ts
|
|
13
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
14
|
+
* const callback = (value: number, key: string) => value * 2;
|
|
15
|
+
* objMapMutable(obj, callback);
|
|
16
|
+
* //=> { a: 2, b: 4, c: 6 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function objMapMutable(object, callback, getKeys = Object.keys) {
|
|
20
|
+
for (const key of getKeys(object)) {
|
|
21
|
+
object[key] = callback(object[key], key);
|
|
22
|
+
}
|
|
23
|
+
return object;
|
|
24
|
+
}
|
|
25
|
+
exports.objMapMutable = objMapMutable;
|
|
26
|
+
//# sourceMappingURL=objMapMutable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objMapMutable.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objMapMutable.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,aAAa,CAC3B,MAAyB,EACzB,QAAsC,EACtC,UAAoD,MAAM,CAAC,IAAI;IAE/D,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;KACzC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AATD,sCASC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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) => !keys.includes(key));
|
|
19
|
+
}
|
|
20
|
+
exports.objOmitKeys = objOmitKeys;
|
|
21
|
+
//# sourceMappingURL=objOmitKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objOmitKeys.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objOmitKeys.ts"],"names":[],"mappings":";;;AACA,2CAAuC;AAEvC;;;;;;;;;;;GAWG;AACH,SAAgB,WAAW,CAAyB,GAAiB,EAAE,GAAG,IAAc;IACtF,OAAO,IAAA,qBAAS,EAAM,GAAG,EAAE,CAAC,CAAC,EAAE,GAAW,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAiB,CAAA;AACrF,CAAC;AAFD,kCAEC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objOmitKeysMutable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Deletes the specified keys from an object in a mutable way.
|
|
6
|
+
* @param obj The object from which to delete the keys.
|
|
7
|
+
* @returns The modified object with the specified keys deleted.
|
|
8
|
+
* @typeparam V - The type of the values in the object.
|
|
9
|
+
* @param keys The keys to delete from the object.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
12
|
+
* objOmitKeysMutable(obj, 'a', 'c');
|
|
13
|
+
* //=> { b: 2 }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function objOmitKeysMutable(obj, ...keys) {
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
Reflect.deleteProperty(obj, key);
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
exports.objOmitKeysMutable = objOmitKeysMutable;
|
|
23
|
+
//# sourceMappingURL=objOmitKeysMutable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objOmitKeysMutable.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objOmitKeysMutable.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,SAAgB,kBAAkB,CAAI,GAAsB,EAAE,GAAG,IAAc;IAC7E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;KACjC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AALD,gDAKC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objPropertyValueToGetter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Converts the specified properties of an object into getter functions.
|
|
6
|
+
* @template K - The type of the keys of the object.
|
|
7
|
+
* @template V - The type of the values of the object.
|
|
8
|
+
* @template T - The type of the object.
|
|
9
|
+
* @param object The object whose properties are to be converted into getter functions.
|
|
10
|
+
* @param propertyNames The names of the properties to be converted into getter functions.
|
|
11
|
+
* @returns The object with the specified properties converted into getter functions.
|
|
12
|
+
* @throws Throws an error if the property descriptor for a specified property name is not found.
|
|
13
|
+
* @example ```ts
|
|
14
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
15
|
+
* objPropertyValueToGetter(obj, 'a', 'b');
|
|
16
|
+
* obj.a;;
|
|
17
|
+
* //=> 1
|
|
18
|
+
* obj.b;;
|
|
19
|
+
* //=> 2
|
|
20
|
+
* obj.c;;
|
|
21
|
+
* //=> 3
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function objPropertyValueToGetter(object, ...propertyNames) {
|
|
25
|
+
for (const propertyName of propertyNames) {
|
|
26
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, propertyName);
|
|
27
|
+
if (!descriptor)
|
|
28
|
+
throw new Error(`Property descriptor for '${String(propertyName)}' not found.`);
|
|
29
|
+
const { enumerable, configurable, value } = descriptor;
|
|
30
|
+
Object.defineProperty(object, propertyName, { enumerable, configurable, get: () => value });
|
|
31
|
+
}
|
|
32
|
+
return object;
|
|
33
|
+
}
|
|
34
|
+
exports.objPropertyValueToGetter = objPropertyValueToGetter;
|
|
35
|
+
//# sourceMappingURL=objPropertyValueToGetter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objPropertyValueToGetter.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objPropertyValueToGetter.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,wBAAwB,CACtC,MAAS,EACT,GAAG,aAA0B;IAE7B,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;QACxE,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;QAChG,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,UAAU,CAAA;QACtD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAA;KAC5F;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAXD,4DAWC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objReduce = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Reduces the values of an object into a single value.
|
|
6
|
+
* @param object The object to reduce.
|
|
7
|
+
* @param callback The function that handles the reduction logic.
|
|
8
|
+
* @param accum The initial value of the accumulator.
|
|
9
|
+
* @template T - The type of the values in the input object.
|
|
10
|
+
* @param - An optional function to get the keys of the object. Defaults to `Object.keys`.
|
|
11
|
+
* @returns The final accumulated value.
|
|
12
|
+
* @param getKeys The function that retrieves the keys of the object.
|
|
13
|
+
* @example ```ts
|
|
14
|
+
* const object = { a: 1, b: 2, c: 3 };
|
|
15
|
+
* const callback = (accum, value, key) => accum + value;
|
|
16
|
+
* const initialAccum = 0;
|
|
17
|
+
* objReduce(object, callback, initialAccum);
|
|
18
|
+
* //=> 6
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function objReduce(object, callback, accum, getKeys = Object.keys) {
|
|
22
|
+
for (const key of getKeys(object)) {
|
|
23
|
+
accum = callback(accum, object[key], key);
|
|
24
|
+
}
|
|
25
|
+
return accum;
|
|
26
|
+
}
|
|
27
|
+
exports.objReduce = objReduce;
|
|
28
|
+
//# sourceMappingURL=objReduce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objReduce.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objReduce.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,SAAS,CACvB,MAAyB,EACzB,QAAgD,EAChD,KAAQ,EACR,UAAoD,MAAM,CAAC,IAAI;IAE/D,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACjC,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;KAC1C;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAVD,8BAUC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objReverse = void 0;
|
|
4
|
+
const objEntriesArray_1 = require("./objEntriesArray");
|
|
5
|
+
/**
|
|
6
|
+
* Reverses the order of the properties in the given object.
|
|
7
|
+
* @remarks This function does not mutate the original object. It returns a new object with the properties in reverse order.
|
|
8
|
+
* @param obj The object to reverse. The object's keys are of type `ObjectKey` and its values are of type `V`.
|
|
9
|
+
* @returns A new object with the properties of the input object in reverse order. The returned object's keys are of type `ObjectKey` and its values are of type `V`.
|
|
10
|
+
* @typeparam V - The type of the values in the input object and the returned object.
|
|
11
|
+
* @example ```ts
|
|
12
|
+
* objReverse({ a: 1, b: 2, c: 3 });;
|
|
13
|
+
* //=> { c: 3, b: 2, a: 1 }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function objReverse(obj) {
|
|
17
|
+
return Object.fromEntries((0, objEntriesArray_1.objEntriesArray)(obj).reverse());
|
|
18
|
+
}
|
|
19
|
+
exports.objReverse = objReverse;
|
|
20
|
+
//# sourceMappingURL=objReverse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objReverse.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objReverse.ts"],"names":[],"mappings":";;;AACA,uDAAmD;AAEnD;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CAAI,GAAyB;IACrD,OAAO,MAAM,CAAC,WAAW,CAAC,IAAA,iCAAe,EAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AAC3D,CAAC;AAFD,gCAEC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objSet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sets a value for a key in an object and returns the value.
|
|
6
|
+
* @template ObjectKey - The type of the keys in the object.
|
|
7
|
+
* @template V - The type of the values in the object.
|
|
8
|
+
* @param obj The object in which to set the value.
|
|
9
|
+
* @param key The key for which to set the value.
|
|
10
|
+
* @param value The value to set.
|
|
11
|
+
* @returns The value that was set.
|
|
12
|
+
* @example ```ts
|
|
13
|
+
* objSet({ a: 1, b: 2 }, 'a', 3);;
|
|
14
|
+
* //=> { a: 3, b: 2 }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function objSet(obj, key, value) {
|
|
18
|
+
return (obj[key] = value);
|
|
19
|
+
}
|
|
20
|
+
exports.objSet = objSet;
|
|
21
|
+
//# sourceMappingURL=objSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objSet.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objSet.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;GAYG;AACH,SAAgB,MAAM,CAAI,GAAyB,EAAE,GAAc,EAAE,KAAQ;IAC3E,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;AAC3B,CAAC;AAFD,wBAEC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objSize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Calculates and returns the size of the given object.
|
|
6
|
+
* @remarks This function uses `Object.keys(obj).length` to determine the size of the object.
|
|
7
|
+
* @param obj The object whose size is to be calculated.
|
|
8
|
+
* @typeparam V - The type of the values in the object.
|
|
9
|
+
* @returns The size of the object.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* objSize({ a: 1, b: 2, c: 3 });;
|
|
12
|
+
* //=> 3
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
function objSize(obj) {
|
|
16
|
+
return Object.keys(obj).length;
|
|
17
|
+
}
|
|
18
|
+
exports.objSize = objSize;
|
|
19
|
+
//# sourceMappingURL=objSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objSize.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objSize.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,SAAgB,OAAO,CAAI,GAAyB;IAClD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;AAChC,CAAC;AAFD,0BAEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objSortKeys = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sorts the keys of an object in alphabetical order.
|
|
6
|
+
* @remarks This function does not mutate the original object. It returns a new object with sorted keys.
|
|
7
|
+
* @typeparam V - The type of the values in the object.
|
|
8
|
+
* @returns A new object with the same values as the original, but with keys sorted in ascending order.
|
|
9
|
+
* @param o The object whose keys should be sorted.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* const obj = { c: 1, a: 2, b: 3 };
|
|
12
|
+
* objSortKeys(obj);
|
|
13
|
+
* //=> { a: 2, b: 3, c: 1 }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function objSortKeys(o) {
|
|
17
|
+
return Object.fromEntries(Object.entries(o).sort((a, b) => a[0].localeCompare(b[0])));
|
|
18
|
+
}
|
|
19
|
+
exports.objSortKeys = objSortKeys;
|
|
20
|
+
//# sourceMappingURL=objSortKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objSortKeys.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objSortKeys.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACH,SAAgB,WAAW,CAAI,CAAuB;IACpD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACvF,CAAC;AAFD,kCAEC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objToMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Converts an object to a Map.
|
|
6
|
+
* @remarks This function is useful when you need to convert an object to a Map data structure.
|
|
7
|
+
* @typeparam V - The type of the values in the object.
|
|
8
|
+
* @returns A new Map object populated with the [key, value] pairs from the original object.
|
|
9
|
+
* @param obj The object to convert to a Map.
|
|
10
|
+
* @example ```ts
|
|
11
|
+
* const obj = { key1: 'value1', key2: 'value2' };
|
|
12
|
+
* const map = objToMap(obj);
|
|
13
|
+
* map.get('key1');
|
|
14
|
+
* //=> 'value1'
|
|
15
|
+
* map.get('key2');
|
|
16
|
+
* //=> 'value2'
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function objToMap(obj) {
|
|
20
|
+
return new Map(Object.entries(obj));
|
|
21
|
+
}
|
|
22
|
+
exports.objToMap = objToMap;
|
|
23
|
+
//# sourceMappingURL=objToMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objToMap.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objToMap.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,QAAQ,CAAI,GAAyB;IACnD,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AACrC,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objUpdate = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Updates the value of a specific key in an object using a callback function.
|
|
6
|
+
* @template V - The type of the values in the object.
|
|
7
|
+
* @param obj The object to update.
|
|
8
|
+
* @param key The key of the value to update.
|
|
9
|
+
* @param callback The function to generate the new value. It receives the current value and the key as arguments.
|
|
10
|
+
* @returns The new value.
|
|
11
|
+
* @example ```ts
|
|
12
|
+
* objUpdate({ a: 1, b: 2 }, 'a', (value, key) => value + 1);;
|
|
13
|
+
* //=> { a: 2, b: 2 }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function objUpdate(obj, key, callback) {
|
|
17
|
+
return (obj[key] = callback(obj[key], key));
|
|
18
|
+
}
|
|
19
|
+
exports.objUpdate = objUpdate;
|
|
20
|
+
//# sourceMappingURL=objUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objUpdate.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objUpdate.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CACvB,GAAyB,EACzB,GAAc,EACd,QAAqD;IAErD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;AAC7C,CAAC;AAND,8BAMC"}
|