@wordpress/is-shallow-equal 5.24.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 +4 -0
- package/build/arrays.js +3 -3
- package/build/arrays.js.map +1 -1
- package/build/index.js +3 -7
- package/build/index.js.map +1 -1
- package/build/objects.js +7 -3
- package/build/objects.js.map +1 -1
- package/build-module/arrays.js +3 -3
- package/build-module/arrays.js.map +1 -1
- package/build-module/index.js +3 -8
- package/build-module/index.js.map +1 -1
- package/build-module/objects.js +7 -3
- package/build-module/objects.js.map +1 -1
- package/build-types/arrays.d.ts +4 -4
- package/build-types/arrays.d.ts.map +1 -1
- package/build-types/index.d.ts +6 -9
- package/build-types/index.d.ts.map +1 -1
- package/build-types/objects.d.ts +8 -4
- package/build-types/objects.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/{arrays.js → arrays.ts} +7 -4
- package/src/{index.js → index.ts} +5 -7
- package/src/{objects.js → objects.ts} +12 -4
package/CHANGELOG.md
CHANGED
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
|
|
11
|
-
* @param
|
|
10
|
+
* @param a First array to compare.
|
|
11
|
+
* @param b Second array to compare.
|
|
12
12
|
*
|
|
13
|
-
* @return
|
|
13
|
+
* @return Whether the two arrays are shallow equal.
|
|
14
14
|
*/
|
|
15
15
|
function isShallowEqualArrays(a, b) {
|
|
16
16
|
if (a === b) {
|
package/build/arrays.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isShallowEqualArrays","a","b","length","i","len"],"sources":["@wordpress/is-shallow-equal/src/arrays.
|
|
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
|
|
35
|
-
* @param
|
|
30
|
+
* @param a First object or array to compare.
|
|
31
|
+
* @param b Second object or array to compare.
|
|
36
32
|
*
|
|
37
|
-
* @return
|
|
33
|
+
* @return Whether the two values are shallow equal.
|
|
38
34
|
*/
|
|
39
35
|
function isShallowEqual(a, b) {
|
|
40
36
|
if (a && b) {
|
package/build/index.js.map
CHANGED
|
@@ -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.
|
|
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
|
|
11
|
-
* @param
|
|
14
|
+
* @param a First object to compare.
|
|
15
|
+
* @param b Second object to compare.
|
|
12
16
|
*
|
|
13
|
-
* @return
|
|
17
|
+
* @return Whether the two objects are shallow equal.
|
|
14
18
|
*/
|
|
15
19
|
function isShallowEqualObjects(a, b) {
|
|
16
20
|
if (a === b) {
|
package/build/objects.js.map
CHANGED
|
@@ -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.
|
|
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":[]}
|
package/build-module/arrays.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the two arrays are shallow equal, or false otherwise.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param a First array to compare.
|
|
5
|
+
* @param b Second array to compare.
|
|
6
6
|
*
|
|
7
|
-
* @return
|
|
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.
|
|
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":[]}
|
package/build-module/index.js
CHANGED
|
@@ -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
|
|
18
|
-
* @param
|
|
12
|
+
* @param a First object or array to compare.
|
|
13
|
+
* @param b Second object or array to compare.
|
|
19
14
|
*
|
|
20
|
-
* @return
|
|
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.
|
|
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":[]}
|
package/build-module/objects.js
CHANGED
|
@@ -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
|
|
5
|
-
* @param
|
|
8
|
+
* @param a First object to compare.
|
|
9
|
+
* @param b Second object to compare.
|
|
6
10
|
*
|
|
7
|
-
* @return
|
|
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.
|
|
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":[]}
|
package/build-types/arrays.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the two arrays are shallow equal, or false otherwise.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param a First array to compare.
|
|
5
|
+
* @param b Second array to compare.
|
|
6
6
|
*
|
|
7
|
-
* @return
|
|
7
|
+
* @return Whether the two arrays are shallow equal.
|
|
8
8
|
*/
|
|
9
|
-
export default function isShallowEqualArrays(a:
|
|
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.
|
|
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"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
9
|
-
* @param
|
|
8
|
+
* @param a First object or array to compare.
|
|
9
|
+
* @param b Second object or array to compare.
|
|
10
10
|
*
|
|
11
|
-
* @return
|
|
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.
|
|
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"}
|
package/build-types/objects.d.ts
CHANGED
|
@@ -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
|
|
5
|
-
* @param
|
|
8
|
+
* @param a First object to compare.
|
|
9
|
+
* @param b Second object to compare.
|
|
6
10
|
*
|
|
7
|
-
* @return
|
|
11
|
+
* @return Whether the two objects are shallow equal.
|
|
8
12
|
*/
|
|
9
|
-
export default function isShallowEqualObjects(a:
|
|
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.
|
|
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.
|
|
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": "
|
|
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
|
|
5
|
-
* @param
|
|
4
|
+
* @param a First array to compare.
|
|
5
|
+
* @param b Second array to compare.
|
|
6
6
|
*
|
|
7
|
-
* @return
|
|
7
|
+
* @return Whether the two arrays are shallow equal.
|
|
8
8
|
*/
|
|
9
|
-
export default function isShallowEqualArrays(
|
|
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
|
|
19
|
-
* @param
|
|
16
|
+
* @param a First object or array to compare.
|
|
17
|
+
* @param b Second object or array to compare.
|
|
20
18
|
*
|
|
21
|
-
* @return
|
|
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
|
|
5
|
-
* @param
|
|
9
|
+
* @param a First object to compare.
|
|
10
|
+
* @param b Second object to compare.
|
|
6
11
|
*
|
|
7
|
-
* @return
|
|
12
|
+
* @return Whether the two objects are shallow equal.
|
|
8
13
|
*/
|
|
9
|
-
export default function isShallowEqualObjects(
|
|
14
|
+
export default function isShallowEqualObjects(
|
|
15
|
+
a: ComparableObject,
|
|
16
|
+
b: ComparableObject
|
|
17
|
+
): boolean {
|
|
10
18
|
if ( a === b ) {
|
|
11
19
|
return true;
|
|
12
20
|
}
|