PluginProbe
Gutenberg / 22.3.0
Gutenberg v22.3.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / is-shallow-equal / index.js

index.js in Gutenberg 22.3.0, at build/scripts/is-shallow-equal/index.js

89 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).isShallowEqual = (() => {
4 var __defProp = Object.defineProperty;
5 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6 var __getOwnPropNames = Object.getOwnPropertyNames;
7 var __hasOwnProp = Object.prototype.hasOwnProperty;
8 var __export = (target, all) => {
9 for (var name in all)
10 __defProp(target, name, { get: all[name], enumerable: true });
11 };
12 var __copyProps = (to, from, except, desc) => {
13 if (from && typeof from === "object" || typeof from === "function") {
14 for (let key of __getOwnPropNames(from))
15 if (!__hasOwnProp.call(to, key) && key !== except)
16 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17 }
18 return to;
19 };
20 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
22 // packages/is-shallow-equal/build-module/index.js
23 var index_exports = {};
24 __export(index_exports, {
25 default: () => isShallowEqual,
26 isShallowEqualArrays: () => isShallowEqualArrays,
27 isShallowEqualObjects: () => isShallowEqualObjects
28 });
29
30 // packages/is-shallow-equal/build-module/objects.js
31 function isShallowEqualObjects(a, b) {
32 if (a === b) {
33 return true;
34 }
35 const aKeys = Object.keys(a);
36 const bKeys = Object.keys(b);
37 if (aKeys.length !== bKeys.length) {
38 return false;
39 }
40 let i = 0;
41 while (i < aKeys.length) {
42 const key = aKeys[i];
43 const aValue = a[key];
44 if (
45 // In iterating only the keys of the first object after verifying
46 // equal lengths, account for the case that an explicit `undefined`
47 // value in the first is implicitly undefined in the second.
48 //
49 // Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )
50 aValue === void 0 && !b.hasOwnProperty(key) || aValue !== b[key]
51 ) {
52 return false;
53 }
54 i++;
55 }
56 return true;
57 }
58
59 // packages/is-shallow-equal/build-module/arrays.js
60 function isShallowEqualArrays(a, b) {
61 if (a === b) {
62 return true;
63 }
64 if (a.length !== b.length) {
65 return false;
66 }
67 for (let i = 0, len = a.length; i < len; i++) {
68 if (a[i] !== b[i]) {
69 return false;
70 }
71 }
72 return true;
73 }
74
75 // packages/is-shallow-equal/build-module/index.js
76 function isShallowEqual(a, b) {
77 if (a && b) {
78 if (a.constructor === Object && b.constructor === Object) {
79 return isShallowEqualObjects(a, b);
80 } else if (Array.isArray(a) && Array.isArray(b)) {
81 return isShallowEqualArrays(a, b);
82 }
83 }
84 return a === b;
85 }
86 return __toCommonJS(index_exports);
87 })();
88 //# sourceMappingURL=index.js.map
89