| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 { 2 "version": 3, 3 "sources": ["../../../packages/is-shallow-equal/src/objects.ts", "../../../packages/is-shallow-equal/src/arrays.ts", "../../../packages/is-shallow-equal/src/index.ts"], 4 "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", "/**\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", "/**\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"], 5 "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAae,WAAR,sBACN,GACA,GACU;AACV,QAAK,MAAM,GAAI;AACd,aAAO;IACR;AAEA,UAAM,QAAQ,OAAO,KAAM,CAAE;AAC7B,UAAM,QAAQ,OAAO,KAAM,CAAE;AAE7B,QAAK,MAAM,WAAW,MAAM,QAAS;AACpC,aAAO;IACR;AAEA,QAAI,IAAI;AAER,WAAQ,IAAI,MAAM,QAAS;AAC1B,YAAM,MAAM,MAAO,CAAE;AACrB,YAAM,SAAS,EAAG,GAAI;AAEtB;;;;;;QAMG,WAAW,UAAa,CAAE,EAAE,eAAgB,GAAI,KAClD,WAAW,EAAG,GAAI;QACjB;AACD,eAAO;MACR;AAEA;IACD;AAEA,WAAO;EACR;;;AC1Ce,WAAR,qBACN,GACA,GACU;AACV,QAAK,MAAM,GAAI;AACd,aAAO;IACR;AAEA,QAAK,EAAE,WAAW,EAAE,QAAS;AAC5B,aAAO;IACR;AAEA,aAAU,IAAI,GAAG,MAAM,EAAE,QAAQ,IAAI,KAAK,KAAM;AAC/C,UAAK,EAAG,CAAE,MAAM,EAAG,CAAE,GAAI;AACxB,eAAO;MACR;IACD;AAEA,WAAO;EACR;;;ACPe,WAAR,eAAiC,GAAY,GAAsB;AACzE,QAAK,KAAK,GAAI;AACb,UAAK,EAAE,gBAAgB,UAAU,EAAE,gBAAgB,QAAS;AAC3D,eAAO,sBAAuB,GAAG,CAAE;MACpC,WAAY,MAAM,QAAS,CAAE,KAAK,MAAM,QAAS,CAAE,GAAI;AACtD,eAAO,qBAAsB,GAAG,CAAE;MACnC;IACD;AAEA,WAAO,MAAM;EACd;", 6 "names": [] 7 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon Apr 20 08:20:11 2026 | Cross-referenced by PHPXref |