yummies 3.1.1 → 3.1.3

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 (3) hide show
  1. package/data.d.ts.map +1 -1
  2. package/data.js +24 -9
  3. package/package.json +1 -1
package/data.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,MAAO,OAAO,KAAK,OAAO,KAAG,OA8BvD,CAAC"}
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,MAAO,OAAO,KAAK,OAAO,KAAG,OA8CvD,CAAC"}
package/data.js CHANGED
@@ -7,20 +7,35 @@ export const isShallowEqual = (a, b) => {
7
7
  b === null) {
8
8
  return false;
9
9
  }
10
+ if (a.constructor !== b.constructor)
11
+ return false;
10
12
  const isArrayA = Array.isArray(a);
11
- const isArrayB = Array.isArray(b);
12
- if (isArrayA !== isArrayB)
13
+ if (isArrayA !== Array.isArray(b))
13
14
  return false;
14
- if (isArrayA && isArrayB) {
15
- return a.length === b.length && a.every((item, index) => item === b[index]);
15
+ if (isArrayA) {
16
+ const arrA = a;
17
+ const arrB = b;
18
+ if (arrA.length !== arrB.length)
19
+ return false;
20
+ for (const [i, element] of arrA.entries()) {
21
+ if (element !== arrB[i])
22
+ return false;
23
+ }
24
+ return true;
16
25
  }
26
+ if (a instanceof Date)
27
+ return a.getTime() === b.getTime();
28
+ if (a instanceof RegExp)
29
+ return a.toString() === b.toString();
17
30
  const aKeys = Object.keys(a);
18
31
  const bKeys = Object.keys(b);
19
32
  if (aKeys.length !== bKeys.length)
20
33
  return false;
21
- // eslint-disable-next-line no-prototype-builtins
22
- const hasAllKeys = aKeys.every((key) => b.hasOwnProperty(key));
23
- if (!hasAllKeys)
24
- return false;
25
- return aKeys.every((key) => a[key] === b[key]);
34
+ const bObj = b;
35
+ for (const key of aKeys) {
36
+ if (!bObj.hasOwnProperty(key) || a[key] !== bObj[key]) {
37
+ return false;
38
+ }
39
+ }
40
+ return true;
26
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yummies",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "keywords": [],
5
5
  "author": "js2me",
6
6
  "license": "MIT",