@wordpress/is-shallow-equal 4.39.0 → 4.40.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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.40.0 (2023-08-16)
6
+
5
7
  ## 4.39.0 (2023-08-10)
6
8
 
7
9
  ## 4.38.0 (2023-07-20)
package/build/arrays.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = isShallowEqualArrays;
7
-
8
7
  /**
9
8
  * Returns true if the two arrays are shallow equal, or false otherwise.
10
9
  *
@@ -17,17 +16,14 @@ function isShallowEqualArrays(a, b) {
17
16
  if (a === b) {
18
17
  return true;
19
18
  }
20
-
21
19
  if (a.length !== b.length) {
22
20
  return false;
23
21
  }
24
-
25
22
  for (let i = 0, len = a.length; i < len; i++) {
26
23
  if (a[i] !== b[i]) {
27
24
  return false;
28
25
  }
29
26
  }
30
-
31
27
  return true;
32
28
  }
33
29
  //# sourceMappingURL=arrays.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/is-shallow-equal/src/arrays.js"],"names":["isShallowEqualArrays","a","b","length","i","len"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,oBAAT,CAA+BC,CAA/B,EAAkCC,CAAlC,EAAsC;AACpD,MAAKD,CAAC,KAAKC,CAAX,EAAe;AACd,WAAO,IAAP;AACA;;AAED,MAAKD,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAApB,EAA6B;AAC5B,WAAO,KAAP;AACA;;AAED,OAAM,IAAIC,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGJ,CAAC,CAACE,MAAzB,EAAiCC,CAAC,GAAGC,GAArC,EAA0CD,CAAC,EAA3C,EAAgD;AAC/C,QAAKH,CAAC,CAAEG,CAAF,CAAD,KAAWF,CAAC,CAAEE,CAAF,CAAjB,EAAyB;AACxB,aAAO,KAAP;AACA;AACD;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * Returns true if the two arrays are shallow equal, or false otherwise.\n *\n * @param {any[]} a First array to compare.\n * @param {any[]} b Second array to compare.\n *\n * @return {boolean} Whether the two arrays are shallow equal.\n */\nexport default function isShallowEqualArrays( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tif ( a.length !== b.length ) {\n\t\treturn false;\n\t}\n\n\tfor ( let i = 0, len = a.length; i < len; i++ ) {\n\t\tif ( a[ i ] !== b[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"names":["isShallowEqualArrays","a","b","length","i","len"],"sources":["@wordpress/is-shallow-equal/src/arrays.js"],"sourcesContent":["/**\n * Returns true if the two arrays are shallow equal, or false otherwise.\n *\n * @param {any[]} a First array to compare.\n * @param {any[]} b Second array to compare.\n *\n * @return {boolean} Whether the two arrays are shallow equal.\n */\nexport default function isShallowEqualArrays( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tif ( a.length !== b.length ) {\n\t\treturn false;\n\t}\n\n\tfor ( let i = 0, len = a.length; i < len; i++ ) {\n\t\tif ( a[ i ] !== b[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,oBAAoBA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACpD,IAAKD,CAAC,KAAKC,CAAC,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,IAAKD,CAAC,CAACE,MAAM,KAAKD,CAAC,CAACC,MAAM,EAAG;IAC5B,OAAO,KAAK;EACb;EAEA,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEC,GAAG,GAAGJ,CAAC,CAACE,MAAM,EAAEC,CAAC,GAAGC,GAAG,EAAED,CAAC,EAAE,EAAG;IAC/C,IAAKH,CAAC,CAAEG,CAAC,CAAE,KAAKF,CAAC,CAAEE,CAAC,CAAE,EAAG;MACxB,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ"}
package/build/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -18,11 +17,8 @@ Object.defineProperty(exports, "isShallowEqualObjects", {
18
17
  return _objects.default;
19
18
  }
20
19
  });
21
-
22
20
  var _objects = _interopRequireDefault(require("./objects"));
23
-
24
21
  var _arrays = _interopRequireDefault(require("./arrays"));
25
-
26
22
  /**
27
23
  * Internal dependencies
28
24
  */
@@ -48,7 +44,6 @@ function isShallowEqual(a, b) {
48
44
  return (0, _arrays.default)(a, b);
49
45
  }
50
46
  }
51
-
52
47
  return a === b;
53
48
  }
54
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/is-shallow-equal/src/index.js"],"names":["isShallowEqual","a","b","constructor","Object","Array","isArray"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAOA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,CAAzB,EAA4BC,CAA5B,EAAgC;AAC9C,MAAKD,CAAC,IAAIC,CAAV,EAAc;AACb,QAAKD,CAAC,CAACE,WAAF,KAAkBC,MAAlB,IAA4BF,CAAC,CAACC,WAAF,KAAkBC,MAAnD,EAA4D;AAC3D,aAAO,sBAAuBH,CAAvB,EAA0BC,CAA1B,CAAP;AACA,KAFD,MAEO,IAAKG,KAAK,CAACC,OAAN,CAAeL,CAAf,KAAsBI,KAAK,CAACC,OAAN,CAAeJ,CAAf,CAA3B,EAAgD;AACtD,aAAO,qBAAsBD,CAAtB,EAAyBC,CAAzB,CAAP;AACA;AACD;;AAED,SAAOD,CAAC,KAAKC,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isShallowEqualObjects from './objects';\nimport isShallowEqualArrays from './arrays';\n\nexport { default as isShallowEqualObjects } from './objects';\nexport { default as isShallowEqualArrays } from './arrays';\n\n/**\n * @typedef {Record<string, any>} ComparableObject\n */\n\n/**\n * Returns true if the two arrays or objects are shallow equal, or false\n * otherwise. Also handles primitive values, just in case.\n *\n * @param {unknown} a First object or array to compare.\n * @param {unknown} b Second object or array to compare.\n *\n * @return {boolean} Whether the two values are shallow equal.\n */\nexport default function isShallowEqual( a, b ) {\n\tif ( a && b ) {\n\t\tif ( a.constructor === Object && b.constructor === Object ) {\n\t\t\treturn isShallowEqualObjects( a, b );\n\t\t} else if ( Array.isArray( a ) && Array.isArray( b ) ) {\n\t\t\treturn isShallowEqualArrays( a, b );\n\t\t}\n\t}\n\n\treturn a === b;\n}\n"]}
1
+ {"version":3,"names":["_objects","_interopRequireDefault","require","_arrays","isShallowEqual","a","b","constructor","Object","isShallowEqualObjects","Array","isArray","isShallowEqualArrays"],"sources":["@wordpress/is-shallow-equal/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isShallowEqualObjects from './objects';\nimport isShallowEqualArrays from './arrays';\n\nexport { default as isShallowEqualObjects } from './objects';\nexport { default as isShallowEqualArrays } from './arrays';\n\n/**\n * @typedef {Record<string, any>} ComparableObject\n */\n\n/**\n * Returns true if the two arrays or objects are shallow equal, or false\n * otherwise. Also handles primitive values, just in case.\n *\n * @param {unknown} a First object or array to compare.\n * @param {unknown} b Second object or array to compare.\n *\n * @return {boolean} Whether the two values are shallow equal.\n */\nexport default function isShallowEqual( a, b ) {\n\tif ( a && b ) {\n\t\tif ( a.constructor === Object && b.constructor === Object ) {\n\t\t\treturn isShallowEqualObjects( a, b );\n\t\t} else if ( Array.isArray( a ) && Array.isArray( b ) ) {\n\t\t\treturn isShallowEqualArrays( a, b );\n\t\t}\n\t}\n\n\treturn a === b;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAOA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,cAAcA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EAC9C,IAAKD,CAAC,IAAIC,CAAC,EAAG;IACb,IAAKD,CAAC,CAACE,WAAW,KAAKC,MAAM,IAAIF,CAAC,CAACC,WAAW,KAAKC,MAAM,EAAG;MAC3D,OAAO,IAAAC,gBAAqB,EAAEJ,CAAC,EAAEC,CAAE,CAAC;IACrC,CAAC,MAAM,IAAKI,KAAK,CAACC,OAAO,CAAEN,CAAE,CAAC,IAAIK,KAAK,CAACC,OAAO,CAAEL,CAAE,CAAC,EAAG;MACtD,OAAO,IAAAM,eAAoB,EAAEP,CAAC,EAAEC,CAAE,CAAC;IACpC;EACD;EAEA,OAAOD,CAAC,KAAKC,CAAC;AACf"}
package/build/objects.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = isShallowEqualObjects;
7
-
8
7
  /**
9
8
  * Returns true if the two objects are shallow equal, or false otherwise.
10
9
  *
@@ -17,21 +16,17 @@ function isShallowEqualObjects(a, b) {
17
16
  if (a === b) {
18
17
  return true;
19
18
  }
20
-
21
19
  const aKeys = Object.keys(a);
22
20
  const bKeys = Object.keys(b);
23
-
24
21
  if (aKeys.length !== bKeys.length) {
25
22
  return false;
26
23
  }
27
-
28
24
  let i = 0;
29
-
30
25
  while (i < aKeys.length) {
31
26
  const key = aKeys[i];
32
27
  const aValue = a[key];
33
-
34
- if ( // In iterating only the keys of the first object after verifying
28
+ if (
29
+ // In iterating only the keys of the first object after verifying
35
30
  // equal lengths, account for the case that an explicit `undefined`
36
31
  // value in the first is implicitly undefined in the second.
37
32
  //
@@ -39,10 +34,8 @@ function isShallowEqualObjects(a, b) {
39
34
  aValue === undefined && !b.hasOwnProperty(key) || aValue !== b[key]) {
40
35
  return false;
41
36
  }
42
-
43
37
  i++;
44
38
  }
45
-
46
39
  return true;
47
40
  }
48
41
  //# sourceMappingURL=objects.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/is-shallow-equal/src/objects.js"],"names":["isShallowEqualObjects","a","b","aKeys","Object","keys","bKeys","length","i","key","aValue","undefined","hasOwnProperty"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAT,CAAgCC,CAAhC,EAAmCC,CAAnC,EAAuC;AACrD,MAAKD,CAAC,KAAKC,CAAX,EAAe;AACd,WAAO,IAAP;AACA;;AAED,QAAMC,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAaJ,CAAb,CAAd;AACA,QAAMK,KAAK,GAAGF,MAAM,CAACC,IAAP,CAAaH,CAAb,CAAd;;AAEA,MAAKC,KAAK,CAACI,MAAN,KAAiBD,KAAK,CAACC,MAA5B,EAAqC;AACpC,WAAO,KAAP;AACA;;AAED,MAAIC,CAAC,GAAG,CAAR;;AAEA,SAAQA,CAAC,GAAGL,KAAK,CAACI,MAAlB,EAA2B;AAC1B,UAAME,GAAG,GAAGN,KAAK,CAAEK,CAAF,CAAjB;AACA,UAAME,MAAM,GAAGT,CAAC,CAAEQ,GAAF,CAAhB;;AAEA,SACC;AACA;AACA;AACA;AACA;AACEC,IAAAA,MAAM,KAAKC,SAAX,IAAwB,CAAET,CAAC,CAACU,cAAF,CAAkBH,GAAlB,CAA5B,IACAC,MAAM,KAAKR,CAAC,CAAEO,GAAF,CAPb,EAQE;AACD,aAAO,KAAP;AACA;;AAEDD,IAAAA,CAAC;AACD;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * Returns true if the two objects are shallow equal, or false otherwise.\n *\n * @param {import('.').ComparableObject} a First object to compare.\n * @param {import('.').ComparableObject} b Second object to compare.\n *\n * @return {boolean} Whether the two objects are shallow equal.\n */\nexport default function isShallowEqualObjects( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tconst aKeys = Object.keys( a );\n\tconst bKeys = Object.keys( b );\n\n\tif ( aKeys.length !== bKeys.length ) {\n\t\treturn false;\n\t}\n\n\tlet i = 0;\n\n\twhile ( i < aKeys.length ) {\n\t\tconst key = aKeys[ i ];\n\t\tconst aValue = a[ key ];\n\n\t\tif (\n\t\t\t// In iterating only the keys of the first object after verifying\n\t\t\t// equal lengths, account for the case that an explicit `undefined`\n\t\t\t// value in the first is implicitly undefined in the second.\n\t\t\t//\n\t\t\t// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )\n\t\t\t( aValue === undefined && ! b.hasOwnProperty( key ) ) ||\n\t\t\taValue !== b[ key ]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\ti++;\n\t}\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"names":["isShallowEqualObjects","a","b","aKeys","Object","keys","bKeys","length","i","key","aValue","undefined","hasOwnProperty"],"sources":["@wordpress/is-shallow-equal/src/objects.js"],"sourcesContent":["/**\n * Returns true if the two objects are shallow equal, or false otherwise.\n *\n * @param {import('.').ComparableObject} a First object to compare.\n * @param {import('.').ComparableObject} b Second object to compare.\n *\n * @return {boolean} Whether the two objects are shallow equal.\n */\nexport default function isShallowEqualObjects( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tconst aKeys = Object.keys( a );\n\tconst bKeys = Object.keys( b );\n\n\tif ( aKeys.length !== bKeys.length ) {\n\t\treturn false;\n\t}\n\n\tlet i = 0;\n\n\twhile ( i < aKeys.length ) {\n\t\tconst key = aKeys[ i ];\n\t\tconst aValue = a[ key ];\n\n\t\tif (\n\t\t\t// In iterating only the keys of the first object after verifying\n\t\t\t// equal lengths, account for the case that an explicit `undefined`\n\t\t\t// value in the first is implicitly undefined in the second.\n\t\t\t//\n\t\t\t// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )\n\t\t\t( aValue === undefined && ! b.hasOwnProperty( key ) ) ||\n\t\t\taValue !== b[ key ]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\ti++;\n\t}\n\n\treturn true;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAqBA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACrD,IAAKD,CAAC,KAAKC,CAAC,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAEJ,CAAE,CAAC;EAC9B,MAAMK,KAAK,GAAGF,MAAM,CAACC,IAAI,CAAEH,CAAE,CAAC;EAE9B,IAAKC,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAG;IACpC,OAAO,KAAK;EACb;EAEA,IAAIC,CAAC,GAAG,CAAC;EAET,OAAQA,CAAC,GAAGL,KAAK,CAACI,MAAM,EAAG;IAC1B,MAAME,GAAG,GAAGN,KAAK,CAAEK,CAAC,CAAE;IACtB,MAAME,MAAM,GAAGT,CAAC,CAAEQ,GAAG,CAAE;IAEvB;IACC;IACA;IACA;IACA;IACA;IACEC,MAAM,KAAKC,SAAS,IAAI,CAAET,CAAC,CAACU,cAAc,CAAEH,GAAI,CAAC,IACnDC,MAAM,KAAKR,CAAC,CAAEO,GAAG,CAAE,EAClB;MACD,OAAO,KAAK;IACb;IAEAD,CAAC,EAAE;EACJ;EAEA,OAAO,IAAI;AACZ"}
@@ -10,17 +10,14 @@ export default function isShallowEqualArrays(a, b) {
10
10
  if (a === b) {
11
11
  return true;
12
12
  }
13
-
14
13
  if (a.length !== b.length) {
15
14
  return false;
16
15
  }
17
-
18
16
  for (let i = 0, len = a.length; i < len; i++) {
19
17
  if (a[i] !== b[i]) {
20
18
  return false;
21
19
  }
22
20
  }
23
-
24
21
  return true;
25
22
  }
26
23
  //# sourceMappingURL=arrays.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/is-shallow-equal/src/arrays.js"],"names":["isShallowEqualArrays","a","b","length","i","len"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,oBAAT,CAA+BC,CAA/B,EAAkCC,CAAlC,EAAsC;AACpD,MAAKD,CAAC,KAAKC,CAAX,EAAe;AACd,WAAO,IAAP;AACA;;AAED,MAAKD,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAApB,EAA6B;AAC5B,WAAO,KAAP;AACA;;AAED,OAAM,IAAIC,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGJ,CAAC,CAACE,MAAzB,EAAiCC,CAAC,GAAGC,GAArC,EAA0CD,CAAC,EAA3C,EAAgD;AAC/C,QAAKH,CAAC,CAAEG,CAAF,CAAD,KAAWF,CAAC,CAAEE,CAAF,CAAjB,EAAyB;AACxB,aAAO,KAAP;AACA;AACD;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * Returns true if the two arrays are shallow equal, or false otherwise.\n *\n * @param {any[]} a First array to compare.\n * @param {any[]} b Second array to compare.\n *\n * @return {boolean} Whether the two arrays are shallow equal.\n */\nexport default function isShallowEqualArrays( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tif ( a.length !== b.length ) {\n\t\treturn false;\n\t}\n\n\tfor ( let i = 0, len = a.length; i < len; i++ ) {\n\t\tif ( a[ i ] !== b[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"names":["isShallowEqualArrays","a","b","length","i","len"],"sources":["@wordpress/is-shallow-equal/src/arrays.js"],"sourcesContent":["/**\n * Returns true if the two arrays are shallow equal, or false otherwise.\n *\n * @param {any[]} a First array to compare.\n * @param {any[]} b Second array to compare.\n *\n * @return {boolean} Whether the two arrays are shallow equal.\n */\nexport default function isShallowEqualArrays( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tif ( a.length !== b.length ) {\n\t\treturn false;\n\t}\n\n\tfor ( let i = 0, len = a.length; i < len; i++ ) {\n\t\tif ( a[ i ] !== b[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,oBAAoBA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACpD,IAAKD,CAAC,KAAKC,CAAC,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,IAAKD,CAAC,CAACE,MAAM,KAAKD,CAAC,CAACC,MAAM,EAAG;IAC5B,OAAO,KAAK;EACb;EAEA,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEC,GAAG,GAAGJ,CAAC,CAACE,MAAM,EAAEC,CAAC,GAAGC,GAAG,EAAED,CAAC,EAAE,EAAG;IAC/C,IAAKH,CAAC,CAAEG,CAAC,CAAE,KAAKF,CAAC,CAAEE,CAAC,CAAE,EAAG;MACxB,OAAO,KAAK;IACb;EACD;EAEA,OAAO,IAAI;AACZ"}
@@ -5,6 +5,7 @@ import isShallowEqualObjects from './objects';
5
5
  import isShallowEqualArrays from './arrays';
6
6
  export { default as isShallowEqualObjects } from './objects';
7
7
  export { default as isShallowEqualArrays } from './arrays';
8
+
8
9
  /**
9
10
  * @typedef {Record<string, any>} ComparableObject
10
11
  */
@@ -18,7 +19,6 @@ export { default as isShallowEqualArrays } from './arrays';
18
19
  *
19
20
  * @return {boolean} Whether the two values are shallow equal.
20
21
  */
21
-
22
22
  export default function isShallowEqual(a, b) {
23
23
  if (a && b) {
24
24
  if (a.constructor === Object && b.constructor === Object) {
@@ -27,7 +27,6 @@ export default function isShallowEqual(a, b) {
27
27
  return isShallowEqualArrays(a, b);
28
28
  }
29
29
  }
30
-
31
30
  return a === b;
32
31
  }
33
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/is-shallow-equal/src/index.js"],"names":["isShallowEqualObjects","isShallowEqualArrays","default","isShallowEqual","a","b","constructor","Object","Array","isArray"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,qBAAP,MAAkC,WAAlC;AACA,OAAOC,oBAAP,MAAiC,UAAjC;AAEA,SAASC,OAAO,IAAIF,qBAApB,QAAiD,WAAjD;AACA,SAASE,OAAO,IAAID,oBAApB,QAAgD,UAAhD;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASE,cAAT,CAAyBC,CAAzB,EAA4BC,CAA5B,EAAgC;AAC9C,MAAKD,CAAC,IAAIC,CAAV,EAAc;AACb,QAAKD,CAAC,CAACE,WAAF,KAAkBC,MAAlB,IAA4BF,CAAC,CAACC,WAAF,KAAkBC,MAAnD,EAA4D;AAC3D,aAAOP,qBAAqB,CAAEI,CAAF,EAAKC,CAAL,CAA5B;AACA,KAFD,MAEO,IAAKG,KAAK,CAACC,OAAN,CAAeL,CAAf,KAAsBI,KAAK,CAACC,OAAN,CAAeJ,CAAf,CAA3B,EAAgD;AACtD,aAAOJ,oBAAoB,CAAEG,CAAF,EAAKC,CAAL,CAA3B;AACA;AACD;;AAED,SAAOD,CAAC,KAAKC,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isShallowEqualObjects from './objects';\nimport isShallowEqualArrays from './arrays';\n\nexport { default as isShallowEqualObjects } from './objects';\nexport { default as isShallowEqualArrays } from './arrays';\n\n/**\n * @typedef {Record<string, any>} ComparableObject\n */\n\n/**\n * Returns true if the two arrays or objects are shallow equal, or false\n * otherwise. Also handles primitive values, just in case.\n *\n * @param {unknown} a First object or array to compare.\n * @param {unknown} b Second object or array to compare.\n *\n * @return {boolean} Whether the two values are shallow equal.\n */\nexport default function isShallowEqual( a, b ) {\n\tif ( a && b ) {\n\t\tif ( a.constructor === Object && b.constructor === Object ) {\n\t\t\treturn isShallowEqualObjects( a, b );\n\t\t} else if ( Array.isArray( a ) && Array.isArray( b ) ) {\n\t\t\treturn isShallowEqualArrays( a, b );\n\t\t}\n\t}\n\n\treturn a === b;\n}\n"]}
1
+ {"version":3,"names":["isShallowEqualObjects","isShallowEqualArrays","default","isShallowEqual","a","b","constructor","Object","Array","isArray"],"sources":["@wordpress/is-shallow-equal/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isShallowEqualObjects from './objects';\nimport isShallowEqualArrays from './arrays';\n\nexport { default as isShallowEqualObjects } from './objects';\nexport { default as isShallowEqualArrays } from './arrays';\n\n/**\n * @typedef {Record<string, any>} ComparableObject\n */\n\n/**\n * Returns true if the two arrays or objects are shallow equal, or false\n * otherwise. Also handles primitive values, just in case.\n *\n * @param {unknown} a First object or array to compare.\n * @param {unknown} b Second object or array to compare.\n *\n * @return {boolean} Whether the two values are shallow equal.\n */\nexport default function isShallowEqual( a, b ) {\n\tif ( a && b ) {\n\t\tif ( a.constructor === Object && b.constructor === Object ) {\n\t\t\treturn isShallowEqualObjects( a, b );\n\t\t} else if ( Array.isArray( a ) && Array.isArray( b ) ) {\n\t\t\treturn isShallowEqualArrays( a, b );\n\t\t}\n\t}\n\n\treturn a === b;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,qBAAqB,MAAM,WAAW;AAC7C,OAAOC,oBAAoB,MAAM,UAAU;AAE3C,SAASC,OAAO,IAAIF,qBAAqB,QAAQ,WAAW;AAC5D,SAASE,OAAO,IAAID,oBAAoB,QAAQ,UAAU;;AAE1D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASE,cAAcA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EAC9C,IAAKD,CAAC,IAAIC,CAAC,EAAG;IACb,IAAKD,CAAC,CAACE,WAAW,KAAKC,MAAM,IAAIF,CAAC,CAACC,WAAW,KAAKC,MAAM,EAAG;MAC3D,OAAOP,qBAAqB,CAAEI,CAAC,EAAEC,CAAE,CAAC;IACrC,CAAC,MAAM,IAAKG,KAAK,CAACC,OAAO,CAAEL,CAAE,CAAC,IAAII,KAAK,CAACC,OAAO,CAAEJ,CAAE,CAAC,EAAG;MACtD,OAAOJ,oBAAoB,CAAEG,CAAC,EAAEC,CAAE,CAAC;IACpC;EACD;EAEA,OAAOD,CAAC,KAAKC,CAAC;AACf"}
@@ -10,21 +10,17 @@ export default function isShallowEqualObjects(a, b) {
10
10
  if (a === b) {
11
11
  return true;
12
12
  }
13
-
14
13
  const aKeys = Object.keys(a);
15
14
  const bKeys = Object.keys(b);
16
-
17
15
  if (aKeys.length !== bKeys.length) {
18
16
  return false;
19
17
  }
20
-
21
18
  let i = 0;
22
-
23
19
  while (i < aKeys.length) {
24
20
  const key = aKeys[i];
25
21
  const aValue = a[key];
26
-
27
- if ( // In iterating only the keys of the first object after verifying
22
+ if (
23
+ // In iterating only the keys of the first object after verifying
28
24
  // equal lengths, account for the case that an explicit `undefined`
29
25
  // value in the first is implicitly undefined in the second.
30
26
  //
@@ -32,10 +28,8 @@ export default function isShallowEqualObjects(a, b) {
32
28
  aValue === undefined && !b.hasOwnProperty(key) || aValue !== b[key]) {
33
29
  return false;
34
30
  }
35
-
36
31
  i++;
37
32
  }
38
-
39
33
  return true;
40
34
  }
41
35
  //# sourceMappingURL=objects.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/is-shallow-equal/src/objects.js"],"names":["isShallowEqualObjects","a","b","aKeys","Object","keys","bKeys","length","i","key","aValue","undefined","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,qBAAT,CAAgCC,CAAhC,EAAmCC,CAAnC,EAAuC;AACrD,MAAKD,CAAC,KAAKC,CAAX,EAAe;AACd,WAAO,IAAP;AACA;;AAED,QAAMC,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAaJ,CAAb,CAAd;AACA,QAAMK,KAAK,GAAGF,MAAM,CAACC,IAAP,CAAaH,CAAb,CAAd;;AAEA,MAAKC,KAAK,CAACI,MAAN,KAAiBD,KAAK,CAACC,MAA5B,EAAqC;AACpC,WAAO,KAAP;AACA;;AAED,MAAIC,CAAC,GAAG,CAAR;;AAEA,SAAQA,CAAC,GAAGL,KAAK,CAACI,MAAlB,EAA2B;AAC1B,UAAME,GAAG,GAAGN,KAAK,CAAEK,CAAF,CAAjB;AACA,UAAME,MAAM,GAAGT,CAAC,CAAEQ,GAAF,CAAhB;;AAEA,SACC;AACA;AACA;AACA;AACA;AACEC,IAAAA,MAAM,KAAKC,SAAX,IAAwB,CAAET,CAAC,CAACU,cAAF,CAAkBH,GAAlB,CAA5B,IACAC,MAAM,KAAKR,CAAC,CAAEO,GAAF,CAPb,EAQE;AACD,aAAO,KAAP;AACA;;AAEDD,IAAAA,CAAC;AACD;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * Returns true if the two objects are shallow equal, or false otherwise.\n *\n * @param {import('.').ComparableObject} a First object to compare.\n * @param {import('.').ComparableObject} b Second object to compare.\n *\n * @return {boolean} Whether the two objects are shallow equal.\n */\nexport default function isShallowEqualObjects( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tconst aKeys = Object.keys( a );\n\tconst bKeys = Object.keys( b );\n\n\tif ( aKeys.length !== bKeys.length ) {\n\t\treturn false;\n\t}\n\n\tlet i = 0;\n\n\twhile ( i < aKeys.length ) {\n\t\tconst key = aKeys[ i ];\n\t\tconst aValue = a[ key ];\n\n\t\tif (\n\t\t\t// In iterating only the keys of the first object after verifying\n\t\t\t// equal lengths, account for the case that an explicit `undefined`\n\t\t\t// value in the first is implicitly undefined in the second.\n\t\t\t//\n\t\t\t// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )\n\t\t\t( aValue === undefined && ! b.hasOwnProperty( key ) ) ||\n\t\t\taValue !== b[ key ]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\ti++;\n\t}\n\n\treturn true;\n}\n"]}
1
+ {"version":3,"names":["isShallowEqualObjects","a","b","aKeys","Object","keys","bKeys","length","i","key","aValue","undefined","hasOwnProperty"],"sources":["@wordpress/is-shallow-equal/src/objects.js"],"sourcesContent":["/**\n * Returns true if the two objects are shallow equal, or false otherwise.\n *\n * @param {import('.').ComparableObject} a First object to compare.\n * @param {import('.').ComparableObject} b Second object to compare.\n *\n * @return {boolean} Whether the two objects are shallow equal.\n */\nexport default function isShallowEqualObjects( a, b ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\n\tconst aKeys = Object.keys( a );\n\tconst bKeys = Object.keys( b );\n\n\tif ( aKeys.length !== bKeys.length ) {\n\t\treturn false;\n\t}\n\n\tlet i = 0;\n\n\twhile ( i < aKeys.length ) {\n\t\tconst key = aKeys[ i ];\n\t\tconst aValue = a[ key ];\n\n\t\tif (\n\t\t\t// In iterating only the keys of the first object after verifying\n\t\t\t// equal lengths, account for the case that an explicit `undefined`\n\t\t\t// value in the first is implicitly undefined in the second.\n\t\t\t//\n\t\t\t// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )\n\t\t\t( aValue === undefined && ! b.hasOwnProperty( key ) ) ||\n\t\t\taValue !== b[ key ]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\ti++;\n\t}\n\n\treturn true;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,qBAAqBA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACrD,IAAKD,CAAC,KAAKC,CAAC,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAEJ,CAAE,CAAC;EAC9B,MAAMK,KAAK,GAAGF,MAAM,CAACC,IAAI,CAAEH,CAAE,CAAC;EAE9B,IAAKC,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAG;IACpC,OAAO,KAAK;EACb;EAEA,IAAIC,CAAC,GAAG,CAAC;EAET,OAAQA,CAAC,GAAGL,KAAK,CAACI,MAAM,EAAG;IAC1B,MAAME,GAAG,GAAGN,KAAK,CAAEK,CAAC,CAAE;IACtB,MAAME,MAAM,GAAGT,CAAC,CAAEQ,GAAG,CAAE;IAEvB;IACC;IACA;IACA;IACA;IACA;IACEC,MAAM,KAAKC,SAAS,IAAI,CAAET,CAAC,CAACU,cAAc,CAAEH,GAAI,CAAC,IACnDC,MAAM,KAAKR,CAAC,CAAEO,GAAG,CAAE,EAClB;MACD,OAAO,KAAK;IACb;IAEAD,CAAC,EAAE;EACJ;EAEA,OAAO,IAAI;AACZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/is-shallow-equal",
3
- "version": "4.39.0",
3
+ "version": "4.40.0",
4
4
  "description": "Test for shallow equality between two objects or arrays.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
44
+ "gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
45
45
  }