PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
24.1.0 24.0.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 All 404 releases
gutenberg / build / scripts / is-shallow-equal / index.js

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

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