@akanjs/common 0.9.58 → 0.9.59

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.
@@ -33,6 +33,8 @@ const getAllPropertyDescriptors = (objRef) => {
33
33
  };
34
34
  const applyMixins = (derivedCtor, constructors, avoidKeys) => {
35
35
  constructors.forEach((baseCtor) => {
36
+ if (!baseCtor)
37
+ return;
36
38
  Object.entries(getAllPropertyDescriptors(baseCtor)).forEach(([name, descriptor]) => {
37
39
  if (name === "constructor" || avoidKeys?.has(name))
38
40
  return;
@@ -35,11 +35,12 @@ const deepObjectify = (obj, option = {}) => {
35
35
  return obj.map((o) => deepObjectify(o, option));
36
36
  } else if (obj && typeof obj === "object") {
37
37
  const val = {};
38
+ const objRecord = obj;
38
39
  Object.keys(obj).forEach((key) => {
39
- const fieldValue = obj[key];
40
+ const fieldValue = objRecord[key];
40
41
  if (fieldValue?.__ModelType__ && !option.serializable)
41
42
  val[key] = fieldValue;
42
- else if (typeof obj[key] !== "function")
43
+ else if (typeof objRecord[key] !== "function")
43
44
  val[key] = deepObjectify(fieldValue, option);
44
45
  });
45
46
  return val;
@@ -50,8 +50,10 @@ const isQueryEqual = (value1, value2) => {
50
50
  return value1 === value2;
51
51
  if (Object.keys(value1).length !== Object.keys(value2).length)
52
52
  return false;
53
+ const v1 = value1;
54
+ const v2 = value2;
53
55
  for (const key of Object.keys(value1))
54
- if (!isQueryEqual(value1[key], value2[key]))
56
+ if (!isQueryEqual(v1[key], v2[key]))
55
57
  return false;
56
58
  return true;
57
59
  }
package/cjs/pathGet.js CHANGED
@@ -22,8 +22,5 @@ __export(pathGet_exports, {
22
22
  module.exports = __toCommonJS(pathGet_exports);
23
23
  const pathGet = (path, obj, separator = ".", fallback = null) => {
24
24
  const properties = Array.isArray(path) ? path : path.split(separator);
25
- return properties.reduce(
26
- (prev, curr) => prev[curr] ?? fallback,
27
- obj
28
- );
25
+ return properties.reduce((prev, curr) => prev?.[curr] ?? fallback, obj);
29
26
  };
@@ -11,6 +11,8 @@ const getAllPropertyDescriptors = (objRef) => {
11
11
  };
12
12
  const applyMixins = (derivedCtor, constructors, avoidKeys) => {
13
13
  constructors.forEach((baseCtor) => {
14
+ if (!baseCtor)
15
+ return;
14
16
  Object.entries(getAllPropertyDescriptors(baseCtor)).forEach(([name, descriptor]) => {
15
17
  if (name === "constructor" || avoidKeys?.has(name))
16
18
  return;
@@ -13,11 +13,12 @@ const deepObjectify = (obj, option = {}) => {
13
13
  return obj.map((o) => deepObjectify(o, option));
14
14
  } else if (obj && typeof obj === "object") {
15
15
  const val = {};
16
+ const objRecord = obj;
16
17
  Object.keys(obj).forEach((key) => {
17
- const fieldValue = obj[key];
18
+ const fieldValue = objRecord[key];
18
19
  if (fieldValue?.__ModelType__ && !option.serializable)
19
20
  val[key] = fieldValue;
20
- else if (typeof obj[key] !== "function")
21
+ else if (typeof objRecord[key] !== "function")
21
22
  val[key] = deepObjectify(fieldValue, option);
22
23
  });
23
24
  return val;
@@ -18,8 +18,10 @@ const isQueryEqual = (value1, value2) => {
18
18
  return value1 === value2;
19
19
  if (Object.keys(value1).length !== Object.keys(value2).length)
20
20
  return false;
21
+ const v1 = value1;
22
+ const v2 = value2;
21
23
  for (const key of Object.keys(value1))
22
- if (!isQueryEqual(value1[key], value2[key]))
24
+ if (!isQueryEqual(v1[key], v2[key]))
23
25
  return false;
24
26
  return true;
25
27
  }
package/esm/pathGet.js CHANGED
@@ -1,9 +1,6 @@
1
1
  const pathGet = (path, obj, separator = ".", fallback = null) => {
2
2
  const properties = Array.isArray(path) ? path : path.split(separator);
3
- return properties.reduce(
4
- (prev, curr) => prev[curr] ?? fallback,
5
- obj
6
- );
3
+ return properties.reduce((prev, curr) => prev?.[curr] ?? fallback, obj);
7
4
  };
8
5
  export {
9
6
  pathGet
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/common",
3
- "version": "0.9.58",
3
+ "version": "0.9.59",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"