@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.
Files changed (186) hide show
  1. package/README.md +6 -34
  2. package/package.json +10 -10
  3. package/{dist/types → src}/index.d.ts +0 -1
  4. package/src/index.js +47 -0
  5. package/src/index.js.map +1 -0
  6. package/{dist/types → src}/lib/createObjectFactory.d.ts +0 -1
  7. package/src/lib/createObjectFactory.js +48 -0
  8. package/src/lib/createObjectFactory.js.map +1 -0
  9. package/{dist/types → src}/lib/getConstructor.d.ts +0 -1
  10. package/src/lib/getConstructor.js +19 -0
  11. package/src/lib/getConstructor.js.map +1 -0
  12. package/{dist/types → src}/lib/inheritStaticMembers.d.ts +0 -1
  13. package/src/lib/inheritStaticMembers.js +40 -0
  14. package/src/lib/inheritStaticMembers.js.map +1 -0
  15. package/{dist/types → src}/lib/iterableFirstElement.d.ts +0 -1
  16. package/src/lib/iterableFirstElement.js +19 -0
  17. package/src/lib/iterableFirstElement.js.map +1 -0
  18. package/{dist/types → src}/lib/iteratePrototypeChain.d.ts +0 -1
  19. package/src/lib/iteratePrototypeChain.js +44 -0
  20. package/src/lib/iteratePrototypeChain.js.map +1 -0
  21. package/{dist/types → src}/lib/objDeepFreeze.d.ts +0 -1
  22. package/src/lib/objDeepFreeze.js +42 -0
  23. package/src/lib/objDeepFreeze.js.map +1 -0
  24. package/{dist/types → src}/lib/objDelete.d.ts +0 -1
  25. package/src/lib/objDelete.js +21 -0
  26. package/src/lib/objDelete.js.map +1 -0
  27. package/{dist/types → src}/lib/objEntries.d.ts +0 -1
  28. package/src/lib/objEntries.js +21 -0
  29. package/src/lib/objEntries.js.map +1 -0
  30. package/{dist/types → src}/lib/objEntriesArray.d.ts +0 -1
  31. package/src/lib/objEntriesArray.js +21 -0
  32. package/src/lib/objEntriesArray.js.map +1 -0
  33. package/{dist/types → src}/lib/objFilter.d.ts +0 -1
  34. package/src/lib/objFilter.js +28 -0
  35. package/src/lib/objFilter.js.map +1 -0
  36. package/{dist/types → src}/lib/objForEach.d.ts +0 -1
  37. package/src/lib/objForEach.js +26 -0
  38. package/src/lib/objForEach.js.map +1 -0
  39. package/{dist/types → src}/lib/objGet.d.ts +0 -1
  40. package/src/lib/objGet.js +24 -0
  41. package/src/lib/objGet.js.map +1 -0
  42. package/{dist/types → src}/lib/objGetOrElse.d.ts +0 -1
  43. package/src/lib/objGetOrElse.js +24 -0
  44. package/src/lib/objGetOrElse.js.map +1 -0
  45. package/{dist/types → src}/lib/objHas.d.ts +0 -1
  46. package/src/lib/objHas.js +22 -0
  47. package/src/lib/objHas.js.map +1 -0
  48. package/{dist/types → src}/lib/objIsEmpty.d.ts +0 -1
  49. package/src/lib/objIsEmpty.js +28 -0
  50. package/src/lib/objIsEmpty.js.map +1 -0
  51. package/{dist/types → src}/lib/objKeys.d.ts +0 -1
  52. package/src/lib/objKeys.js +22 -0
  53. package/src/lib/objKeys.js.map +1 -0
  54. package/{dist/types → src}/lib/objKeysArray.d.ts +0 -1
  55. package/src/lib/objKeysArray.js +20 -0
  56. package/src/lib/objKeysArray.js.map +1 -0
  57. package/{dist/types → src}/lib/objMap.d.ts +0 -1
  58. package/src/lib/objMap.js +26 -0
  59. package/src/lib/objMap.js.map +1 -0
  60. package/{dist/types → src}/lib/objMapKeys.d.ts +0 -1
  61. package/src/lib/objMapKeys.js +27 -0
  62. package/src/lib/objMapKeys.js.map +1 -0
  63. package/{dist/types → src}/lib/objMapMutable.d.ts +0 -1
  64. package/src/lib/objMapMutable.js +26 -0
  65. package/src/lib/objMapMutable.js.map +1 -0
  66. package/{dist/types → src}/lib/objOmitKeys.d.ts +0 -1
  67. package/src/lib/objOmitKeys.js +21 -0
  68. package/src/lib/objOmitKeys.js.map +1 -0
  69. package/{dist/types → src}/lib/objOmitKeysMutable.d.ts +0 -1
  70. package/src/lib/objOmitKeysMutable.js +23 -0
  71. package/src/lib/objOmitKeysMutable.js.map +1 -0
  72. package/{dist/types → src}/lib/objPropertyValueToGetter.d.ts +0 -1
  73. package/src/lib/objPropertyValueToGetter.js +35 -0
  74. package/src/lib/objPropertyValueToGetter.js.map +1 -0
  75. package/{dist/types → src}/lib/objReduce.d.ts +0 -1
  76. package/src/lib/objReduce.js +28 -0
  77. package/src/lib/objReduce.js.map +1 -0
  78. package/{dist/types → src}/lib/objReverse.d.ts +0 -1
  79. package/src/lib/objReverse.js +20 -0
  80. package/src/lib/objReverse.js.map +1 -0
  81. package/{dist/types → src}/lib/objSet.d.ts +0 -1
  82. package/src/lib/objSet.js +21 -0
  83. package/src/lib/objSet.js.map +1 -0
  84. package/{dist/types → src}/lib/objSize.d.ts +0 -1
  85. package/src/lib/objSize.js +19 -0
  86. package/src/lib/objSize.js.map +1 -0
  87. package/{dist/types → src}/lib/objSortKeys.d.ts +0 -1
  88. package/src/lib/objSortKeys.js +20 -0
  89. package/src/lib/objSortKeys.js.map +1 -0
  90. package/{dist/types → src}/lib/objToMap.d.ts +0 -1
  91. package/src/lib/objToMap.js +23 -0
  92. package/src/lib/objToMap.js.map +1 -0
  93. package/{dist/types → src}/lib/objUpdate.d.ts +0 -1
  94. package/src/lib/objUpdate.js +20 -0
  95. package/src/lib/objUpdate.js.map +1 -0
  96. package/{dist/types → src}/lib/objUpdatePropertyDescriptors.d.ts +0 -1
  97. package/src/lib/objUpdatePropertyDescriptors.js +28 -0
  98. package/src/lib/objUpdatePropertyDescriptors.js.map +1 -0
  99. package/{dist/types → src}/lib/objValues.d.ts +0 -1
  100. package/src/lib/objValues.js +26 -0
  101. package/src/lib/objValues.js.map +1 -0
  102. package/{dist/types → src}/lib/objValuesArray.d.ts +0 -1
  103. package/src/lib/objValuesArray.js +20 -0
  104. package/src/lib/objValuesArray.js.map +1 -0
  105. package/{dist/types → src}/lib/objWalk.d.ts +0 -1
  106. package/src/lib/objWalk.js +42 -0
  107. package/src/lib/objWalk.js.map +1 -0
  108. package/{dist/types → src}/lib/setEnumerable.d.ts +0 -1
  109. package/src/lib/setEnumerable.js +28 -0
  110. package/src/lib/setEnumerable.js.map +1 -0
  111. package/{dist/types → src}/lib/setNonConfigurable.d.ts +0 -1
  112. package/src/lib/setNonConfigurable.js +30 -0
  113. package/src/lib/setNonConfigurable.js.map +1 -0
  114. package/{dist/types → src}/lib/setNonEnumerable.d.ts +0 -1
  115. package/src/lib/setNonEnumerable.js +25 -0
  116. package/src/lib/setNonEnumerable.js.map +1 -0
  117. package/{dist/types → src}/lib/setNonWritable.d.ts +0 -1
  118. package/src/lib/setNonWritable.js +31 -0
  119. package/src/lib/setNonWritable.js.map +1 -0
  120. package/{dist/types → src}/lib/setWritable.d.ts +0 -1
  121. package/src/lib/setWritable.js +26 -0
  122. package/src/lib/setWritable.js.map +1 -0
  123. package/{dist/types → src}/lib/toJson.d.ts +0 -1
  124. package/src/lib/toJson.js +19 -0
  125. package/src/lib/toJson.js.map +1 -0
  126. package/{dist/types → src}/types/Constructor.d.ts +0 -1
  127. package/src/types/Constructor.js +3 -0
  128. package/src/types/Constructor.js.map +1 -0
  129. package/{dist/types → src}/types/ConstructorOf.d.ts +0 -1
  130. package/src/types/ConstructorOf.js +3 -0
  131. package/src/types/ConstructorOf.js.map +1 -0
  132. package/{dist/types → src}/types/ObjectKey.d.ts +0 -1
  133. package/src/types/ObjectKey.js +3 -0
  134. package/src/types/ObjectKey.js.map +1 -0
  135. package/LICENSE +0 -21
  136. package/dist/index.cjs.js +0 -6
  137. package/dist/index.cjs.js.map +0 -1
  138. package/dist/index.esm.js +0 -6
  139. package/dist/index.esm.js.map +0 -1
  140. package/dist/types/index.d.ts.map +0 -1
  141. package/dist/types/lib/createObjectFactory.d.ts.map +0 -1
  142. package/dist/types/lib/getConstructor.d.ts.map +0 -1
  143. package/dist/types/lib/inheritStaticMembers.d.ts.map +0 -1
  144. package/dist/types/lib/iterableFirstElement.d.ts.map +0 -1
  145. package/dist/types/lib/iteratePrototypeChain.d.ts.map +0 -1
  146. package/dist/types/lib/objDeepFreeze.d.ts.map +0 -1
  147. package/dist/types/lib/objDelete.d.ts.map +0 -1
  148. package/dist/types/lib/objEntries.d.ts.map +0 -1
  149. package/dist/types/lib/objEntriesArray.d.ts.map +0 -1
  150. package/dist/types/lib/objFilter.d.ts.map +0 -1
  151. package/dist/types/lib/objForEach.d.ts.map +0 -1
  152. package/dist/types/lib/objGet.d.ts.map +0 -1
  153. package/dist/types/lib/objGetOrElse.d.ts.map +0 -1
  154. package/dist/types/lib/objHas.d.ts.map +0 -1
  155. package/dist/types/lib/objIsEmpty.d.ts.map +0 -1
  156. package/dist/types/lib/objKeys.d.ts.map +0 -1
  157. package/dist/types/lib/objKeysArray.d.ts.map +0 -1
  158. package/dist/types/lib/objMap.d.ts.map +0 -1
  159. package/dist/types/lib/objMapKeys.d.ts.map +0 -1
  160. package/dist/types/lib/objMapMutable.d.ts.map +0 -1
  161. package/dist/types/lib/objOmitKeys.d.ts.map +0 -1
  162. package/dist/types/lib/objOmitKeysMutable.d.ts.map +0 -1
  163. package/dist/types/lib/objPropertyValueToGetter.d.ts.map +0 -1
  164. package/dist/types/lib/objReduce.d.ts.map +0 -1
  165. package/dist/types/lib/objReverse.d.ts.map +0 -1
  166. package/dist/types/lib/objSet.d.ts.map +0 -1
  167. package/dist/types/lib/objSize.d.ts.map +0 -1
  168. package/dist/types/lib/objSortKeys.d.ts.map +0 -1
  169. package/dist/types/lib/objToMap.d.ts.map +0 -1
  170. package/dist/types/lib/objUpdate.d.ts.map +0 -1
  171. package/dist/types/lib/objUpdatePropertyDescriptors.d.ts.map +0 -1
  172. package/dist/types/lib/objValues.d.ts.map +0 -1
  173. package/dist/types/lib/objValuesArray.d.ts.map +0 -1
  174. package/dist/types/lib/objWalk.d.ts.map +0 -1
  175. package/dist/types/lib/setEnumerable.d.ts.map +0 -1
  176. package/dist/types/lib/setNonConfigurable.d.ts.map +0 -1
  177. package/dist/types/lib/setNonEnumerable.d.ts.map +0 -1
  178. package/dist/types/lib/setNonWritable.d.ts.map +0 -1
  179. package/dist/types/lib/setWritable.d.ts.map +0 -1
  180. package/dist/types/lib/toJson.d.ts.map +0 -1
  181. package/dist/types/types/Constructor.d.ts.map +0 -1
  182. package/dist/types/types/ConstructorOf.d.ts.map +0 -1
  183. package/dist/types/types/ObjectKey.d.ts.map +0 -1
  184. package/jest.config.ts +0 -13
  185. package/project.json +0 -30
  186. package/tsconfig.spec.json +0 -9
package/README.md CHANGED
@@ -1,39 +1,11 @@
1
- # @bemoje/object
2
- Object related tools/util.
1
+ # object
3
2
 
4
- ![GitHub Top Language](https://img.shields.io/github/languages/top/bemoje/https://github.com/bemoje/tsmono)
3
+ This library was generated with [Nx](https://nx.dev).
5
4
 
6
- ##### Github
7
- ![GitHub Last Commit](https://img.shields.io/github/last-commit/bemoje/https://github.com/bemoje/tsmono?color=red)
8
- ![GitHub Stars](https://img.shields.io/github/stars/bemoje/https://github.com/bemoje/tsmono)
9
- ![GitHub Forks](https://img.shields.io/github/forks/bemoje/https://github.com/bemoje/tsmono)
10
- ![GitHub Watchers](https://img.shields.io/github/watchers/bemoje/https://github.com/bemoje/tsmono)
11
- ![GitHub Repo Size](https://img.shields.io/github/repo-size/bemoje/https://github.com/bemoje/tsmono)
5
+ ## Building
12
6
 
13
- ##### NPM
14
- <span><a href="https://npmjs.org/@bemoje/object" title="View this project on NPM"><img src="https://img.shields.io/npm/v/@bemoje/object" alt="NPM Version" /></a></span>
15
- <span><a href="https://npmjs.org/@bemoje/object" title="NPM Downloads"><img src="https://img.shields.io/npm/dt/@bemoje/object" alt="NPM Downloads" /></a></span>
7
+ Run `nx build object` to build the library.
16
8
 
17
- ## Documentation
18
- [object docs](https://bemoje.github.io/tsmono/modules/object.html)
9
+ ## Running unit tests
19
10
 
20
- ##### Donate
21
- <span><a href="https://www.patreon.com/user?u=40752770" title="Donate using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon Donation" /></a></span>
22
-
23
- ## Installation
24
- This library is published in the NPM registry and can be installed using any compatible package manager.
25
-
26
- #### NPM
27
- ```sh
28
- npm install @bemoje/object
29
- ```
30
-
31
-
32
- ## Issues
33
- Please let me know of any bugs or [issues](https://github.com/bemoje/https://github.com/bemoje/tsmono/issues).
34
-
35
- ## Contribute
36
- Contributors are welcome to open a [pull request](https://github.com/bemoje/https://github.com/bemoje/tsmono/pulls).
37
-
38
- ## License
39
- Released under the [MIT License](./LICENSE).
11
+ Run `nx test object` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json CHANGED
@@ -1,13 +1,9 @@
1
1
  {
2
2
  "name": "@bemoje/object",
3
- "version": "0.0.10",
3
+ "version": "0.2.0",
4
4
  "description": "Object related tools/util.",
5
- "main": "dist/index.cjs.js",
6
- "module": "dist/index.esm.js",
7
- "types": "dist/types/index.d.ts",
8
- "scripts": {
9
- "build": "rimraf dist && rollup --config ./rollup.config.js --bundleConfigAsCjs"
10
- },
5
+ "main": "./src/index.js",
6
+ "scripts": {},
11
7
  "author": {
12
8
  "name": "Benjamin Møller Jensen",
13
9
  "email": "bemoje@bemoje.net",
@@ -16,7 +12,8 @@
16
12
  "license": "MIT",
17
13
  "keywords": [],
18
14
  "dependencies": {
19
- "@bemoje/validation": "latest"
15
+ "@bemoje/validation": "latest",
16
+ "tslib": "^2.3.0"
20
17
  },
21
18
  "repository": {
22
19
  "type": "git",
@@ -29,5 +26,8 @@
29
26
  "bugs": {
30
27
  "url": "https://github.com/bemoje/tsmono/issues"
31
28
  },
32
- "homepage": "https://github.com/bemoje/tsmono"
33
- }
29
+ "homepage": "https://github.com/bemoje/tsmono",
30
+ "type": "commonjs",
31
+ "typings": "./src/index.d.ts",
32
+ "types": "./src/index.d.ts"
33
+ }
@@ -41,4 +41,3 @@ export * from './lib/toJson';
41
41
  export * from './types/Constructor';
42
42
  export * from './types/ConstructorOf';
43
43
  export * from './types/ObjectKey';
44
- //# sourceMappingURL=index.d.ts.map
package/src/index.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/createObjectFactory"), exports);
5
+ tslib_1.__exportStar(require("./lib/getConstructor"), exports);
6
+ tslib_1.__exportStar(require("./lib/inheritStaticMembers"), exports);
7
+ tslib_1.__exportStar(require("./lib/iterableFirstElement"), exports);
8
+ tslib_1.__exportStar(require("./lib/iteratePrototypeChain"), exports);
9
+ tslib_1.__exportStar(require("./lib/objDeepFreeze"), exports);
10
+ tslib_1.__exportStar(require("./lib/objDelete"), exports);
11
+ tslib_1.__exportStar(require("./lib/objEntries"), exports);
12
+ tslib_1.__exportStar(require("./lib/objEntriesArray"), exports);
13
+ tslib_1.__exportStar(require("./lib/objFilter"), exports);
14
+ tslib_1.__exportStar(require("./lib/objForEach"), exports);
15
+ tslib_1.__exportStar(require("./lib/objGet"), exports);
16
+ tslib_1.__exportStar(require("./lib/objGetOrElse"), exports);
17
+ tslib_1.__exportStar(require("./lib/objHas"), exports);
18
+ tslib_1.__exportStar(require("./lib/objIsEmpty"), exports);
19
+ tslib_1.__exportStar(require("./lib/objKeys"), exports);
20
+ tslib_1.__exportStar(require("./lib/objKeysArray"), exports);
21
+ tslib_1.__exportStar(require("./lib/objMap"), exports);
22
+ tslib_1.__exportStar(require("./lib/objMapKeys"), exports);
23
+ tslib_1.__exportStar(require("./lib/objMapMutable"), exports);
24
+ tslib_1.__exportStar(require("./lib/objOmitKeys"), exports);
25
+ tslib_1.__exportStar(require("./lib/objOmitKeysMutable"), exports);
26
+ tslib_1.__exportStar(require("./lib/objPropertyValueToGetter"), exports);
27
+ tslib_1.__exportStar(require("./lib/objReduce"), exports);
28
+ tslib_1.__exportStar(require("./lib/objReverse"), exports);
29
+ tslib_1.__exportStar(require("./lib/objSet"), exports);
30
+ tslib_1.__exportStar(require("./lib/objSize"), exports);
31
+ tslib_1.__exportStar(require("./lib/objSortKeys"), exports);
32
+ tslib_1.__exportStar(require("./lib/objToMap"), exports);
33
+ tslib_1.__exportStar(require("./lib/objUpdate"), exports);
34
+ tslib_1.__exportStar(require("./lib/objUpdatePropertyDescriptors"), exports);
35
+ tslib_1.__exportStar(require("./lib/objValues"), exports);
36
+ tslib_1.__exportStar(require("./lib/objValuesArray"), exports);
37
+ tslib_1.__exportStar(require("./lib/objWalk"), exports);
38
+ tslib_1.__exportStar(require("./lib/setEnumerable"), exports);
39
+ tslib_1.__exportStar(require("./lib/setNonConfigurable"), exports);
40
+ tslib_1.__exportStar(require("./lib/setNonEnumerable"), exports);
41
+ tslib_1.__exportStar(require("./lib/setNonWritable"), exports);
42
+ tslib_1.__exportStar(require("./lib/setWritable"), exports);
43
+ tslib_1.__exportStar(require("./lib/toJson"), exports);
44
+ tslib_1.__exportStar(require("./types/Constructor"), exports);
45
+ tslib_1.__exportStar(require("./types/ConstructorOf"), exports);
46
+ tslib_1.__exportStar(require("./types/ObjectKey"), exports);
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/object/src/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyC;AACzC,+DAAoC;AACpC,qEAA0C;AAC1C,qEAA0C;AAC1C,sEAA2C;AAC3C,8DAAmC;AACnC,0DAA+B;AAC/B,2DAAgC;AAChC,gEAAqC;AACrC,0DAA+B;AAC/B,2DAAgC;AAChC,uDAA4B;AAC5B,6DAAkC;AAClC,uDAA4B;AAC5B,2DAAgC;AAChC,wDAA6B;AAC7B,6DAAkC;AAClC,uDAA4B;AAC5B,2DAAgC;AAChC,8DAAmC;AACnC,4DAAiC;AACjC,mEAAwC;AACxC,yEAA8C;AAC9C,0DAA+B;AAC/B,2DAAgC;AAChC,uDAA4B;AAC5B,wDAA6B;AAC7B,4DAAiC;AACjC,yDAA8B;AAC9B,0DAA+B;AAC/B,6EAAkD;AAClD,0DAA+B;AAC/B,+DAAoC;AACpC,wDAA6B;AAC7B,8DAAmC;AACnC,mEAAwC;AACxC,iEAAsC;AACtC,+DAAoC;AACpC,4DAAiC;AACjC,uDAA4B;AAC5B,8DAAmC;AACnC,gEAAqC;AACrC,4DAAiC"}
@@ -11,4 +11,3 @@
11
11
  * ```
12
12
  */
13
13
  export declare function createObjectFactory<T>(keys: string[], defaultValues?: T[]): (values?: T[]) => Record<string, T>;
14
- //# sourceMappingURL=createObjectFactory.d.ts.map
@@ -0,0 +1,48 @@
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
@@ -0,0 +1 @@
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"}
@@ -11,4 +11,3 @@ import type { ConstructorOf } from '../types/ConstructorOf';
11
11
  * ```
12
12
  */
13
13
  export declare function getConstructor<T>(o: T): ConstructorOf<T>;
14
- //# sourceMappingURL=getConstructor.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConstructor = void 0;
4
+ /**
5
+ * Returns the constructor of the given object.
6
+ * @template T - The type of the object.
7
+ * @param o The object whose constructor is to be returned.
8
+ * @returns The constructor of the object.
9
+ * @example ```ts
10
+ * class MyClass {}
11
+ * getConstructor(new MyClass()) === MyClass;;
12
+ * //=> true
13
+ * ```
14
+ */
15
+ function getConstructor(o) {
16
+ return Object.getPrototypeOf(o).constructor;
17
+ }
18
+ exports.getConstructor = getConstructor;
19
+ //# sourceMappingURL=getConstructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getConstructor.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/getConstructor.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,SAAgB,cAAc,CAAI,CAAI;IACpC,OAAO,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;AAC7C,CAAC;AAFD,wCAEC"}
@@ -23,4 +23,3 @@ import type { Constructor } from '../types/Constructor';
23
23
  * ```
24
24
  */
25
25
  export declare function inheritStaticMembers(target: Constructor, source: Constructor, ignoreKeys?: string[]): Constructor;
26
- //# sourceMappingURL=inheritStaticMembers.d.ts.map
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inheritStaticMembers = void 0;
4
+ /**
5
+ * Copies static members from a source constructor to a target constructor, excluding specified keys.
6
+ * @param target The target constructor to inherit static members.
7
+ * @param source The source constructor to copy static members from.
8
+ * @param ignoreKeys An optional array of keys to exclude from copying.
9
+ * @returns The target constructor with the inherited static members.
10
+ * @throws If `target` or `source` is not a constructor.
11
+ * @param - The keys that should not be inherited.
12
+ * @example ```ts
13
+ * class Parent {
14
+ * static parentStaticMethod() {
15
+ * return 'Parent static method'
16
+ * }
17
+ * }
18
+ * class Child {
19
+ * static childStaticMethod() {
20
+ * return 'Child static method'
21
+ * }
22
+ * }
23
+ * inheritStaticMembers(Child, Parent)
24
+ * Child.parentStaticMethod() //=> 'Parent static method'
25
+ * ```
26
+ */
27
+ function inheritStaticMembers(target, source, ignoreKeys = []) {
28
+ const ignore = new Set([...ignoreKeys, 'prototype', 'name', 'constructor']);
29
+ for (const key of Reflect.ownKeys(source)) {
30
+ if (ignore.has(key))
31
+ continue;
32
+ if (Reflect.has(target, key))
33
+ continue;
34
+ const des = Object.getOwnPropertyDescriptor(source, key);
35
+ Object.defineProperty(target, key, des);
36
+ }
37
+ return target;
38
+ }
39
+ exports.inheritStaticMembers = inheritStaticMembers;
40
+ //# sourceMappingURL=inheritStaticMembers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inheritStaticMembers.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/inheritStaticMembers.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,oBAAoB,CAAC,MAAmB,EAAE,MAAmB,EAAE,aAAuB,EAAE;IACtG,MAAM,MAAM,GAAyB,IAAI,GAAG,CAAC,CAAC,GAAG,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;IACjG,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAQ;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;YAAE,SAAQ;QACtC,MAAM,GAAG,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACxD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,GAAyB,CAAC,CAAA;KAC9D;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AATD,oDASC"}
@@ -9,4 +9,3 @@
9
9
  * ```
10
10
  */
11
11
  export declare function iterableFirstElement<T>(iterable: Iterable<T>): T | undefined;
12
- //# sourceMappingURL=iterableFirstElement.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.iterableFirstElement = void 0;
4
+ /**
5
+ * Returns the first element of an iterable object.
6
+ * @template T - The type of elements in the iterable.
7
+ * @param iterable The iterable object.
8
+ * @returns The first element of the iterable object, or `undefined` if the iterable is empty.
9
+ * @example ```ts
10
+ * iterableFirstElement([1, 2, 3, 4, 5]);;
11
+ * //=> 1
12
+ * ```
13
+ */
14
+ function iterableFirstElement(iterable) {
15
+ for (const item of iterable)
16
+ return item;
17
+ }
18
+ exports.iterableFirstElement = iterableFirstElement;
19
+ //# sourceMappingURL=iterableFirstElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterableFirstElement.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/iterableFirstElement.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,SAAgB,oBAAoB,CAAI,QAAqB;IAC3D,KAAK,MAAM,IAAI,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAA;AAC1C,CAAC;AAFD,oDAEC"}
@@ -20,4 +20,3 @@
20
20
  * ```
21
21
  */
22
22
  export declare function iteratePrototypeChain(object: Record<string, any>): Generator<Record<string, any>>;
23
- //# sourceMappingURL=iteratePrototypeChain.d.ts.map
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.iteratePrototypeChain = void 0;
4
+ const validation_1 = require("@bemoje/validation");
5
+ /**
6
+ * Iterate the prototype chain of a given object.
7
+ * @remarks This function uses the `Reflect.getPrototypeOf` method to traverse the prototype chain.
8
+ * It also uses the `isPrototype` and `isConstructor` helper functions to determine whether
9
+ * the given object is a prototype or a constructor function.
10
+ * @param object The object whose prototype chain is to be iterated over.
11
+ * @throws If the provided object is not an object or a function, a TypeError will be thrown.
12
+ * @returns A generator that yields each prototype in the chain.
13
+ * @example ```ts
14
+ * class A {}
15
+ * class B extends A {}
16
+ * class C extends B {}
17
+ * const instance = new C()
18
+ * iteratePrototypeChain(C)
19
+ * //=> [ C, B, A, Function.prototype, Object.prototype]
20
+ * iteratePrototypeChain(C.prototype)
21
+ * //=> [C.prototype, B.prototype, A.prototype, Object.prototype]
22
+ * iteratePrototypeChain(instance)
23
+ * //=> [instance, C.prototype, B.prototype, A.prototype, Object.prototype]
24
+ * ```
25
+ */
26
+ function* iteratePrototypeChain(object) {
27
+ if (
28
+ // if the below false, then object must be an instance
29
+ !(0, validation_1.isPrototype)(object) &&
30
+ !(0, validation_1.isConstructor)(object) &&
31
+ // the two above depend on checking that typeof object is 'object',
32
+ // so this last check is in case of arrow functions and generator functions
33
+ object !== Function.prototype) {
34
+ yield object;
35
+ object = object.constructor.prototype;
36
+ }
37
+ let objectOrNull = object;
38
+ while (objectOrNull) {
39
+ yield objectOrNull;
40
+ objectOrNull = Reflect.getPrototypeOf(objectOrNull);
41
+ }
42
+ }
43
+ exports.iteratePrototypeChain = iteratePrototypeChain;
44
+ //# sourceMappingURL=iteratePrototypeChain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iteratePrototypeChain.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/iteratePrototypeChain.ts"],"names":[],"mappings":";;;AAAA,mDAA+D;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAe,CAAC,CAAC,qBAAqB,CAAC,MAA2B;IAChE;IACE,sDAAsD;IACtD,CAAC,IAAA,wBAAW,EAAC,MAAM,CAAC;QACpB,CAAC,IAAA,0BAAa,EAAC,MAAM,CAAC;QACtB,mEAAmE;QACnE,2EAA2E;QAC3E,MAAM,KAAK,QAAQ,CAAC,SAAS,EAC7B;QACA,MAAM,MAAM,CAAA;QACZ,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAA;KACtC;IACD,IAAI,YAAY,GAA+B,MAAM,CAAA;IACrD,OAAO,YAAY,EAAE;QACnB,MAAM,YAAY,CAAA;QAClB,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;KACpD;AACH,CAAC;AAjBD,sDAiBC"}
@@ -27,4 +27,3 @@
27
27
  * ```
28
28
  */
29
29
  export declare function objDeepFreeze(o: Record<string | symbol, any>): Record<string | symbol, any>;
30
- //# sourceMappingURL=objDeepFreeze.d.ts.map
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objDeepFreeze = void 0;
4
+ /**
5
+ * Deep freezes an object, making it immutable by recursively freezing all nested objects and functions.
6
+ * @returns The same object, but deeply frozen.
7
+ * @throws If the object is not an object or function.
8
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze | Object.freeze}
9
+ * @param o The object to deep freeze.
10
+ * This function uses `Object.freeze()` to freeze the object and all its nested objects and functions.
11
+ * @example ```ts
12
+ * const obj = {
13
+ * prop1: 'value1',
14
+ * prop2: {
15
+ * nestedProp1: 'nestedValue1',
16
+ * nestedProp2: {
17
+ * deeplyNestedProp: 'deeplyNestedValue'
18
+ * }
19
+ * },
20
+ * prop3: () => {
21
+ * //=> Hello, world!
22
+ * }
23
+ * }
24
+ * const frozenObj = objDeepFreeze(obj)
25
+ * // Attempting to modify the frozen object will throw an error
26
+ * frozenObj.prop1 //=> 'value1'
27
+ * frozenObj.prop2.nestedProp1 //=> 'nestedValue1'
28
+ * frozenObj.prop2.nestedProp2.deeplyNestedProp //=> 'deeplyNestedValue'
29
+ * frozenObj.prop3() //=> undefined
30
+ * ```
31
+ */
32
+ function objDeepFreeze(o) {
33
+ for (const key of Reflect.ownKeys(o)) {
34
+ const value = o[key];
35
+ if ((value && typeof value === 'object') || typeof value === 'function') {
36
+ objDeepFreeze(value);
37
+ }
38
+ }
39
+ return Object.freeze(o);
40
+ }
41
+ exports.objDeepFreeze = objDeepFreeze;
42
+ //# sourceMappingURL=objDeepFreeze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objDeepFreeze.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objDeepFreeze.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,aAAa,CAAC,CAA+B;IAC3D,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACpC,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;QACpB,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YACvE,aAAa,CAAC,KAAK,CAAC,CAAA;SACrB;KACF;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AACzB,CAAC;AARD,sCAQC"}
@@ -12,4 +12,3 @@ import { ObjectKey } from '../types/ObjectKey';
12
12
  * ```
13
13
  */
14
14
  export declare function objDelete<K extends ObjectKey, V>(obj: Record<K, V>, key: K): Omit<Record<K, V>, K>;
15
- //# sourceMappingURL=objDelete.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objDelete = void 0;
4
+ /**
5
+ * Deletes a property from an object and returns the modified object.
6
+ * @param obj The object from which to delete the property.
7
+ * @template K - The type of the keys in the object.
8
+ * @returns The modified object with the key deleted.
9
+ * @param key The key of the property to delete.
10
+ * @example ```ts
11
+ * const obj = { name: 'John', age: 30 };
12
+ * objDelete(obj, 'age');
13
+ * //=> { name: 'John' }
14
+ * ```
15
+ */
16
+ function objDelete(obj, key) {
17
+ delete obj[key];
18
+ return obj;
19
+ }
20
+ exports.objDelete = objDelete;
21
+ //# sourceMappingURL=objDelete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objDelete.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objDelete.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CAAyB,GAAiB,EAAE,GAAM;IACzE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,GAAG,CAAA;AACZ,CAAC;AAHD,8BAGC"}
@@ -13,4 +13,3 @@ import { ObjectKey } from '../types/ObjectKey';
13
13
  * ```
14
14
  */
15
15
  export declare function objEntries<V>(obj: Record<ObjectKey, V>): Iterable<[string, V]>;
16
- //# sourceMappingURL=objEntries.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objEntries = void 0;
4
+ /**
5
+ * Returns an iterable of key-value pairs from the given object.
6
+ * @remarks This function is a part of Object Utilities.
7
+ * @typeparam V - The type of values in the object.
8
+ * @returns An iterable of tuples where each tuple is a key-value pair from the object.
9
+ * @param obj The object to iterate over.
10
+ * @example ```ts
11
+ * const obj = { a: 1, b: 2, c: 3 };
12
+ * for (const [key, value] of objEntries(obj)) {
13
+ * //=> a //=> b //=> c 3
14
+ * }
15
+ * ```
16
+ */
17
+ function* objEntries(obj) {
18
+ yield* Object.entries(obj);
19
+ }
20
+ exports.objEntries = objEntries;
21
+ //# sourceMappingURL=objEntries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objEntries.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objEntries.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;GAYG;AACH,QAAe,CAAC,CAAC,UAAU,CAAI,GAAyB;IACtD,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AAC5B,CAAC;AAFD,gCAEC"}
@@ -13,4 +13,3 @@ import { ObjectKey } from '../types/ObjectKey';
13
13
  * ```
14
14
  */
15
15
  export declare function objEntriesArray<V>(obj: Record<ObjectKey, V>): Array<[string, V]>;
16
- //# sourceMappingURL=objEntriesArray.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objEntriesArray = void 0;
4
+ /**
5
+ * Returns an array of key-value pairs from the given object.
6
+ * @remarks This function is a utility for converting an object into an array of its entries.
7
+ * Each entry is a tuple where the first element is the key and the second is the value.
8
+ * @typeparam V - The type of the values in the object.
9
+ * @returns An array of entries, where each entry is a tuple of a string and a value of type `V`.
10
+ * @param obj The object to extract keyvalue pairs from.
11
+ * @example ```ts
12
+ * const obj = { a: 1, b: 2, c: 3 };
13
+ * objEntriesArray(obj);
14
+ * //=> [['a', 1], ['b', 2], ['c', 3]]
15
+ * ```
16
+ */
17
+ function objEntriesArray(obj) {
18
+ return Array.from(Object.entries(obj));
19
+ }
20
+ exports.objEntriesArray = objEntriesArray;
21
+ //# sourceMappingURL=objEntriesArray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objEntriesArray.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objEntriesArray.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAAI,GAAyB;IAC1D,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AACxC,CAAC;AAFD,0CAEC"}
@@ -13,4 +13,3 @@
13
13
  * ```
14
14
  */
15
15
  export declare function objFilter<T>(object: Record<string, T>, callback: (value: T, key: string) => boolean, getKeys?: (obj: typeof object) => Iterable<string>): Record<string, T>;
16
- //# sourceMappingURL=objFilter.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objFilter = void 0;
4
+ /**
5
+ * Filters the properties of an object based on a callback function.
6
+ * @param object The object to filter.
7
+ * @param callback The callback function used to filter the object properties.
8
+ * @template T - The type of the values in the object.
9
+ * @param - The function to get the keys of the object. Defaults to `Object.keys`.
10
+ * @returns A new object with the properties that passed the test. If no properties passed the test, an empty object will be returned.
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
+ * objFilter(obj, (value, key) => value > 1);
15
+ * //=> { b: 2, c: 3 }
16
+ * ```
17
+ */
18
+ function objFilter(object, callback, getKeys = Object.keys) {
19
+ const result = {};
20
+ for (const key of getKeys(object)) {
21
+ if (callback(object[key], key)) {
22
+ result[key] = object[key];
23
+ }
24
+ }
25
+ return result;
26
+ }
27
+ exports.objFilter = objFilter;
28
+ //# sourceMappingURL=objFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objFilter.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objFilter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CACvB,MAAyB,EACzB,QAA4C,EAC5C,UAAoD,MAAM,CAAC,IAAI;IAE/D,MAAM,MAAM,GAAsB,EAAE,CAAA;IACpC,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACjC,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE;YAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;SAC1B;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAZD,8BAYC"}
@@ -14,4 +14,3 @@
14
14
  * ```
15
15
  */
16
16
  export declare function objForEach<T>(object: Record<string, T>, callback: (value: T, key: string) => void, getKeys?: (obj: typeof object) => Iterable<string>): typeof object;
17
- //# sourceMappingURL=objForEach.d.ts.map
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objForEach = void 0;
4
+ /**
5
+ * Applies a callback function to each key-value pair in an object.
6
+ * @param object The object to iterate over.
7
+ * @param callback The function to apply to each keyvalue pair.
8
+ * @template T - The type of the object's properties.
9
+ * @param - An optional function to determine the keys to iterate over. Defaults to `Object.keys`.
10
+ * @returns The original object.
11
+ * @param getKeys The function to retrieve the keys of the object.
12
+ * @example ```ts
13
+ * const myObject = { a: 1, b: 2, c: 3 };
14
+ * objForEach(myObject, (value, key) => {
15
+ * //=> ${key}: ${value}
16
+ * });
17
+ * ```
18
+ */
19
+ function objForEach(object, callback, getKeys = Object.keys) {
20
+ for (const key of getKeys(object)) {
21
+ callback(object[key], key);
22
+ }
23
+ return object;
24
+ }
25
+ exports.objForEach = objForEach;
26
+ //# sourceMappingURL=objForEach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objForEach.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objForEach.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CACxB,MAAyB,EACzB,QAAyC,EACzC,UAAoD,MAAM,CAAC,IAAI;IAE/D,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACjC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;KAC3B;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AATD,gCASC"}
@@ -16,4 +16,3 @@ import { ObjectKey } from '../types/ObjectKey';
16
16
  * ```
17
17
  */
18
18
  export declare function objGet<V>(obj: Record<ObjectKey, V>, key: ObjectKey): V | undefined;
19
- //# sourceMappingURL=objGet.d.ts.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objGet = void 0;
4
+ /**
5
+ * Retrieves the value associated with the specified key from an object.
6
+ * @param obj The object from which to retrieve the value.
7
+ * @template K - The type of the keys in the object.
8
+ * @returns The value of the specified key in the object, or `undefined` if the key does not exist.
9
+ * @param key The key of the value to retrieve.
10
+ * @example ```ts
11
+ * const myObj = { name: 'John', age: 30 };
12
+ * objGet(myObj, 'name');
13
+ * //=> 'John'
14
+ * objGet(myObj, 'age');
15
+ * //=> 30
16
+ * objGet(myObj, 'address');
17
+ * //=> undefined
18
+ * ```
19
+ */
20
+ function objGet(obj, key) {
21
+ return obj[key];
22
+ }
23
+ exports.objGet = objGet;
24
+ //# sourceMappingURL=objGet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objGet.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objGet.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,MAAM,CAAI,GAAyB,EAAE,GAAc;IACjE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAA;AACjB,CAAC;AAFD,wBAEC"}