@mongez/reinforcements 2.2.4 → 2.2.6

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.
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
 
3
+ var get = require("../object/get.js");
4
+ require("../object/merge.js");
5
+
3
6
  /**
4
7
  * Group the given array by the given key(s).
5
8
  *
@@ -12,10 +15,11 @@ function groupBy(array, groupByKey, listAs = "data") {
12
15
  for (const item of array) {
13
16
  const baseKeys = [];
14
17
  for (const groupByKey of groupByKeys) {
15
- if (!item[groupByKey]) break;
18
+ const value = get(item, groupByKey);
19
+ if (!value) break;
16
20
  baseKeys.push({
17
21
  key: groupByKey,
18
- value: item[groupByKey],
22
+ value,
19
23
  });
20
24
  }
21
25
  const dataKey = JSON.stringify(baseKeys);
@@ -1,3 +1,6 @@
1
+ import get from "../object/get.js";
2
+ import "../object/merge.js";
3
+
1
4
  /**
2
5
  * Group the given array by the given key(s).
3
6
  *
@@ -10,10 +13,11 @@ function groupBy(array, groupByKey, listAs = "data") {
10
13
  for (const item of array) {
11
14
  const baseKeys = [];
12
15
  for (const groupByKey of groupByKeys) {
13
- if (!item[groupByKey]) break;
16
+ const value = get(item, groupByKey);
17
+ if (!value) break;
14
18
  baseKeys.push({
15
19
  key: groupByKey,
16
- value: item[groupByKey],
20
+ value,
17
21
  });
18
22
  }
19
23
  const dataKey = JSON.stringify(baseKeys);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongez/reinforcements",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "A lightweight package to give a massive reinforcements to variant types of data in Nodejs/Javascript",
5
5
  "main": "./cjs/index.js",
6
6
  "dependencies": {
@@ -31,6 +31,5 @@
31
31
  "author": "hassanzohdy",
32
32
  "license": "MIT",
33
33
  "module": "./esm/index.js",
34
- "type": "commonjs",
35
34
  "typings": "./cjs/index.d.ts"
36
35
  }