PluginProbe
Gutenberg / 23.2.0
Gutenberg v23.2.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 12.6.0 All 403 releases
gutenberg / build / scripts / is-shallow-equal / index.js
build/scripts/is-shallow-equal
index.js 2.7 KB 7 months ago index.js.map 3.8 KB 7 months ago index.min.asset.php 83 B 7 months ago index.min.js 1.1 KB 7 months ago index.min.js.map 4.0 KB 7 months ago

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

90 lines 2.7 KB 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.mjs
23 var index_exports = {};
24 __export(index_exports, {
25 default: () => isShallowEqual,
26 isShallowEqual: () => isShallowEqual,
27 isShallowEqualArrays: () => isShallowEqualArrays,
28 isShallowEqualObjects: () => isShallowEqualObjects
29 });
30
31 // packages/is-shallow-equal/build-module/objects.mjs
32 function isShallowEqualObjects(a, b) {
33 if (a === b) {
34 return true;
35 }
36 const aKeys = Object.keys(a);
37 const bKeys = Object.keys(b);
38 if (aKeys.length !== bKeys.length) {
39 return false;
40 }
41 let i = 0;
42 while (i < aKeys.length) {
43 const key = aKeys[i];
44 const aValue = a[key];
45 if (
46 // In iterating only the keys of the first object after verifying
47 // equal lengths, account for the case that an explicit `undefined`
48 // value in the first is implicitly undefined in the second.
49 //
50 // Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )
51 aValue === void 0 && !b.hasOwnProperty(key) || aValue !== b[key]
52 ) {
53 return false;
54 }
55 i++;
56 }
57 return true;
58 }
59
60 // packages/is-shallow-equal/build-module/arrays.mjs
61 function isShallowEqualArrays(a, b) {
62 if (a === b) {
63 return true;
64 }
65 if (a.length !== b.length) {
66 return false;
67 }
68 for (let i = 0, len = a.length; i < len; i++) {
69 if (a[i] !== b[i]) {
70 return false;
71 }
72 }
73 return true;
74 }
75
76 // packages/is-shallow-equal/build-module/index.mjs
77 function isShallowEqual(a, b) {
78 if (a && b) {
79 if (a.constructor === Object && b.constructor === Object) {
80 return isShallowEqualObjects(a, b);
81 } else if (Array.isArray(a) && Array.isArray(b)) {
82 return isShallowEqualArrays(a, b);
83 }
84 }
85 return a === b;
86 }
87 return __toCommonJS(index_exports);
88 })();
89 //# sourceMappingURL=index.js.map
90