@wordpress/is-shallow-equal 5.25.0 → 5.26.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
+ ## 5.26.0 (2025-06-25)
6
+
5
7
  ## 5.25.0 (2025-06-04)
6
8
 
7
9
  ## 5.24.0 (2025-05-22)
package/build/arrays.js CHANGED
@@ -7,10 +7,10 @@ exports.default = isShallowEqualArrays;
7
7
  /**
8
8
  * Returns true if the two arrays are shallow equal, or false otherwise.
9
9
  *
10
- * @param {any[]} a First array to compare.
11
- * @param {any[]} b Second array to compare.
10
+ * @param a First array to compare.
11
+ * @param b Second array to compare.
12
12
  *
13
- * @return {boolean} Whether the two arrays are shallow equal.
13
+ * @return Whether the two arrays are shallow equal.
14
14
  */
15
15
  function isShallowEqualArrays(a, b) {
16
16
  if (a === b) {
@@ -1 +1 @@
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","ignoreList":[]}
1
+ {"version":3,"names":["isShallowEqualArrays","a","b","length","i","len"],"sources":["@wordpress/is-shallow-equal/src/arrays.ts"],"sourcesContent":["/**\n * Returns true if the two arrays are shallow equal, or false otherwise.\n *\n * @param a First array to compare.\n * @param b Second array to compare.\n *\n * @return Whether the two arrays are shallow equal.\n */\nexport default function isShallowEqualArrays(\n\ta: unknown[],\n\tb: unknown[]\n): boolean {\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,CAC3CC,CAAY,EACZC,CAAY,EACF;EACV,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","ignoreList":[]}
package/build/index.js CHANGED
@@ -23,18 +23,14 @@ var _arrays = _interopRequireDefault(require("./arrays"));
23
23
  * Internal dependencies
24
24
  */
25
25
 
26
- /**
27
- * @typedef {Record<string, any>} ComparableObject
28
- */
29
-
30
26
  /**
31
27
  * Returns true if the two arrays or objects are shallow equal, or false
32
28
  * otherwise. Also handles primitive values, just in case.
33
29
  *
34
- * @param {unknown} a First object or array to compare.
35
- * @param {unknown} b Second object or array to compare.
30
+ * @param a First object or array to compare.
31
+ * @param b Second object or array to compare.
36
32
  *
37
- * @return {boolean} Whether the two values are shallow equal.
33
+ * @return Whether the two values are shallow equal.
38
34
  */
39
35
  function isShallowEqual(a, b) {
40
36
  if (a && b) {
@@ -1 +1 @@
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","ignoreList":[]}
1
+ {"version":3,"names":["_objects","_interopRequireDefault","require","_arrays","isShallowEqual","a","b","constructor","Object","isShallowEqualObjects","Array","isArray","isShallowEqualArrays"],"sources":["@wordpress/is-shallow-equal/src/index.ts"],"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\nexport type ComparableObject = Record< string, any >;\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 a First object or array to compare.\n * @param b Second object or array to compare.\n *\n * @return Whether the two values are shallow equal.\n */\nexport default function isShallowEqual( a: unknown, b: unknown ): boolean {\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;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,cAAcA,CAAEC,CAAU,EAAEC,CAAU,EAAY;EACzE,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","ignoreList":[]}
package/build/objects.js CHANGED
@@ -4,13 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = isShallowEqualObjects;
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
7
11
  /**
8
12
  * Returns true if the two objects are shallow equal, or false otherwise.
9
13
  *
10
- * @param {import('.').ComparableObject} a First object to compare.
11
- * @param {import('.').ComparableObject} b Second object to compare.
14
+ * @param a First object to compare.
15
+ * @param b Second object to compare.
12
16
  *
13
- * @return {boolean} Whether the two objects are shallow equal.
17
+ * @return Whether the two objects are shallow equal.
14
18
  */
15
19
  function isShallowEqualObjects(a, b) {
16
20
  if (a === b) {
@@ -1 +1 @@
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","ignoreList":[]}
1
+ {"version":3,"names":["isShallowEqualObjects","a","b","aKeys","Object","keys","bKeys","length","i","key","aValue","undefined","hasOwnProperty"],"sources":["@wordpress/is-shallow-equal/src/objects.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { ComparableObject } from '.';\n\n/**\n * Returns true if the two objects are shallow equal, or false otherwise.\n *\n * @param a First object to compare.\n * @param b Second object to compare.\n *\n * @return Whether the two objects are shallow equal.\n */\nexport default function isShallowEqualObjects(\n\ta: ComparableObject,\n\tb: ComparableObject\n): boolean {\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;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAqBA,CAC5CC,CAAmB,EACnBC,CAAmB,EACT;EACV,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","ignoreList":[]}
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Returns true if the two arrays are shallow equal, or false otherwise.
3
3
  *
4
- * @param {any[]} a First array to compare.
5
- * @param {any[]} b Second array to compare.
4
+ * @param a First array to compare.
5
+ * @param b Second array to compare.
6
6
  *
7
- * @return {boolean} Whether the two arrays are shallow equal.
7
+ * @return Whether the two arrays are shallow equal.
8
8
  */
9
9
  export default function isShallowEqualArrays(a, b) {
10
10
  if (a === b) {
@@ -1 +1 @@
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","ignoreList":[]}
1
+ {"version":3,"names":["isShallowEqualArrays","a","b","length","i","len"],"sources":["@wordpress/is-shallow-equal/src/arrays.ts"],"sourcesContent":["/**\n * Returns true if the two arrays are shallow equal, or false otherwise.\n *\n * @param a First array to compare.\n * @param b Second array to compare.\n *\n * @return Whether the two arrays are shallow equal.\n */\nexport default function isShallowEqualArrays(\n\ta: unknown[],\n\tb: unknown[]\n): boolean {\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,CAC3CC,CAAY,EACZC,CAAY,EACF;EACV,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","ignoreList":[]}
@@ -5,19 +5,14 @@ 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
-
9
- /**
10
- * @typedef {Record<string, any>} ComparableObject
11
- */
12
-
13
8
  /**
14
9
  * Returns true if the two arrays or objects are shallow equal, or false
15
10
  * otherwise. Also handles primitive values, just in case.
16
11
  *
17
- * @param {unknown} a First object or array to compare.
18
- * @param {unknown} b Second object or array to compare.
12
+ * @param a First object or array to compare.
13
+ * @param b Second object or array to compare.
19
14
  *
20
- * @return {boolean} Whether the two values are shallow equal.
15
+ * @return Whether the two values are shallow equal.
21
16
  */
22
17
  export default function isShallowEqual(a, b) {
23
18
  if (a && b) {
@@ -1 +1 @@
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","ignoreList":[]}
1
+ {"version":3,"names":["isShallowEqualObjects","isShallowEqualArrays","default","isShallowEqual","a","b","constructor","Object","Array","isArray"],"sources":["@wordpress/is-shallow-equal/src/index.ts"],"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\nexport type ComparableObject = Record< string, any >;\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 a First object or array to compare.\n * @param b Second object or array to compare.\n *\n * @return Whether the two values are shallow equal.\n */\nexport default function isShallowEqual( a: unknown, b: unknown ): boolean {\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;AAI1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASE,cAAcA,CAAEC,CAAU,EAAEC,CAAU,EAAY;EACzE,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","ignoreList":[]}
@@ -1,10 +1,14 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+
1
5
  /**
2
6
  * Returns true if the two objects are shallow equal, or false otherwise.
3
7
  *
4
- * @param {import('.').ComparableObject} a First object to compare.
5
- * @param {import('.').ComparableObject} b Second object to compare.
8
+ * @param a First object to compare.
9
+ * @param b Second object to compare.
6
10
  *
7
- * @return {boolean} Whether the two objects are shallow equal.
11
+ * @return Whether the two objects are shallow equal.
8
12
  */
9
13
  export default function isShallowEqualObjects(a, b) {
10
14
  if (a === b) {
@@ -1 +1 @@
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","ignoreList":[]}
1
+ {"version":3,"names":["isShallowEqualObjects","a","b","aKeys","Object","keys","bKeys","length","i","key","aValue","undefined","hasOwnProperty"],"sources":["@wordpress/is-shallow-equal/src/objects.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { ComparableObject } from '.';\n\n/**\n * Returns true if the two objects are shallow equal, or false otherwise.\n *\n * @param a First object to compare.\n * @param b Second object to compare.\n *\n * @return Whether the two objects are shallow equal.\n */\nexport default function isShallowEqualObjects(\n\ta: ComparableObject,\n\tb: ComparableObject\n): boolean {\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;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,qBAAqBA,CAC5CC,CAAmB,EACnBC,CAAmB,EACT;EACV,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","ignoreList":[]}
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Returns true if the two arrays are shallow equal, or false otherwise.
3
3
  *
4
- * @param {any[]} a First array to compare.
5
- * @param {any[]} b Second array to compare.
4
+ * @param a First array to compare.
5
+ * @param b Second array to compare.
6
6
  *
7
- * @return {boolean} Whether the two arrays are shallow equal.
7
+ * @return Whether the two arrays are shallow equal.
8
8
  */
9
- export default function isShallowEqualArrays(a: any[], b: any[]): boolean;
9
+ export default function isShallowEqualArrays(a: unknown[], b: unknown[]): boolean;
10
10
  //# sourceMappingURL=arrays.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../src/arrays.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,gDALW,GAAG,EAAE,KACL,GAAG,EAAE,GAEJ,OAAO,CAkBlB"}
1
+ {"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../src/arrays.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC3C,CAAC,EAAE,OAAO,EAAE,EACZ,CAAC,EAAE,OAAO,EAAE,GACV,OAAO,CAgBT"}
@@ -1,17 +1,14 @@
1
- /**
2
- * @typedef {Record<string, any>} ComparableObject
3
- */
1
+ export { default as isShallowEqualObjects } from './objects';
2
+ export { default as isShallowEqualArrays } from './arrays';
3
+ export type ComparableObject = Record<string, any>;
4
4
  /**
5
5
  * Returns true if the two arrays or objects are shallow equal, or false
6
6
  * otherwise. Also handles primitive values, just in case.
7
7
  *
8
- * @param {unknown} a First object or array to compare.
9
- * @param {unknown} b Second object or array to compare.
8
+ * @param a First object or array to compare.
9
+ * @param b Second object or array to compare.
10
10
  *
11
- * @return {boolean} Whether the two values are shallow equal.
11
+ * @return Whether the two values are shallow equal.
12
12
  */
13
13
  export default function isShallowEqual(a: unknown, b: unknown): boolean;
14
- export { default as isShallowEqualObjects } from "./objects";
15
- export { default as isShallowEqualArrays } from "./arrays";
16
- export type ComparableObject = Record<string, any>;
17
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AASA;;GAEG;AAEH;;;;;;;;GAQG;AACH,0CALW,OAAO,KACP,OAAO,GAEN,OAAO,CAYlB;;;+BAtBY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,CAAC;AAErD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAI,OAAO,CAUxE"}
@@ -1,10 +1,14 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { ComparableObject } from '.';
1
5
  /**
2
6
  * Returns true if the two objects are shallow equal, or false otherwise.
3
7
  *
4
- * @param {import('.').ComparableObject} a First object to compare.
5
- * @param {import('.').ComparableObject} b Second object to compare.
8
+ * @param a First object to compare.
9
+ * @param b Second object to compare.
6
10
  *
7
- * @return {boolean} Whether the two objects are shallow equal.
11
+ * @return Whether the two objects are shallow equal.
8
12
  */
9
- export default function isShallowEqualObjects(a: import(".").ComparableObject, b: import(".").ComparableObject): boolean;
13
+ export default function isShallowEqualObjects(a: ComparableObject, b: ComparableObject): boolean;
10
14
  //# sourceMappingURL=objects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../src/objects.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iDALW,OAAO,GAAG,EAAE,gBAAgB,KAC5B,OAAO,GAAG,EAAE,gBAAgB,GAE3B,OAAO,CAoClB"}
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,GAAG,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC5C,CAAC,EAAE,gBAAgB,EACnB,CAAC,EAAE,gBAAgB,GACjB,OAAO,CAkCT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/is-shallow-equal",
3
- "version": "5.25.0",
3
+ "version": "5.26.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",
@@ -43,5 +43,5 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "d1acd76ffff33ab01f0a948d2f51e5e45c95158d"
46
+ "gitHead": "35e26942820d8237771af0c58e45b4303f0497f1"
47
47
  }
@@ -1,12 +1,15 @@
1
1
  /**
2
2
  * Returns true if the two arrays are shallow equal, or false otherwise.
3
3
  *
4
- * @param {any[]} a First array to compare.
5
- * @param {any[]} b Second array to compare.
4
+ * @param a First array to compare.
5
+ * @param b Second array to compare.
6
6
  *
7
- * @return {boolean} Whether the two arrays are shallow equal.
7
+ * @return Whether the two arrays are shallow equal.
8
8
  */
9
- export default function isShallowEqualArrays( a, b ) {
9
+ export default function isShallowEqualArrays(
10
+ a: unknown[],
11
+ b: unknown[]
12
+ ): boolean {
10
13
  if ( a === b ) {
11
14
  return true;
12
15
  }
@@ -7,20 +7,18 @@ import isShallowEqualArrays from './arrays';
7
7
  export { default as isShallowEqualObjects } from './objects';
8
8
  export { default as isShallowEqualArrays } from './arrays';
9
9
 
10
- /**
11
- * @typedef {Record<string, any>} ComparableObject
12
- */
10
+ export type ComparableObject = Record< string, any >;
13
11
 
14
12
  /**
15
13
  * Returns true if the two arrays or objects are shallow equal, or false
16
14
  * otherwise. Also handles primitive values, just in case.
17
15
  *
18
- * @param {unknown} a First object or array to compare.
19
- * @param {unknown} b Second object or array to compare.
16
+ * @param a First object or array to compare.
17
+ * @param b Second object or array to compare.
20
18
  *
21
- * @return {boolean} Whether the two values are shallow equal.
19
+ * @return Whether the two values are shallow equal.
22
20
  */
23
- export default function isShallowEqual( a, b ) {
21
+ export default function isShallowEqual( a: unknown, b: unknown ): boolean {
24
22
  if ( a && b ) {
25
23
  if ( a.constructor === Object && b.constructor === Object ) {
26
24
  return isShallowEqualObjects( a, b );
@@ -1,12 +1,20 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { ComparableObject } from '.';
5
+
1
6
  /**
2
7
  * Returns true if the two objects are shallow equal, or false otherwise.
3
8
  *
4
- * @param {import('.').ComparableObject} a First object to compare.
5
- * @param {import('.').ComparableObject} b Second object to compare.
9
+ * @param a First object to compare.
10
+ * @param b Second object to compare.
6
11
  *
7
- * @return {boolean} Whether the two objects are shallow equal.
12
+ * @return Whether the two objects are shallow equal.
8
13
  */
9
- export default function isShallowEqualObjects( a, b ) {
14
+ export default function isShallowEqualObjects(
15
+ a: ComparableObject,
16
+ b: ComparableObject
17
+ ): boolean {
10
18
  if ( a === b ) {
11
19
  return true;
12
20
  }