[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> is-shallow-equal.js (source)

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/define property getters */
   8  /******/     (() => {
   9  /******/         // define getter functions for harmony exports
  10  /******/         __webpack_require__.d = (exports, definition) => {
  11  /******/             for(var key in definition) {
  12  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14  /******/                 }
  15  /******/             }
  16  /******/         };
  17  /******/     })();
  18  /******/     
  19  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  20  /******/     (() => {
  21  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  22  /******/     })();
  23  /******/     
  24  /******/     /* webpack/runtime/make namespace object */
  25  /******/     (() => {
  26  /******/         // define __esModule on exports
  27  /******/         __webpack_require__.r = (exports) => {
  28  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30  /******/             }
  31  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  32  /******/         };
  33  /******/     })();
  34  /******/     
  35  /************************************************************************/
  36  var __webpack_exports__ = {};
  37  // ESM COMPAT FLAG
  38  __webpack_require__.r(__webpack_exports__);
  39  
  40  // EXPORTS
  41  __webpack_require__.d(__webpack_exports__, {
  42    "default": () => (/* binding */ isShallowEqual),
  43    isShallowEqualArrays: () => (/* reexport */ isShallowEqualArrays),
  44    isShallowEqualObjects: () => (/* reexport */ isShallowEqualObjects)
  45  });
  46  
  47  ;// ./node_modules/@wordpress/is-shallow-equal/build-module/objects.js
  48  function isShallowEqualObjects(a, b) {
  49    if (a === b) {
  50      return true;
  51    }
  52    const aKeys = Object.keys(a);
  53    const bKeys = Object.keys(b);
  54    if (aKeys.length !== bKeys.length) {
  55      return false;
  56    }
  57    let i = 0;
  58    while (i < aKeys.length) {
  59      const key = aKeys[i];
  60      const aValue = a[key];
  61      if (
  62        // In iterating only the keys of the first object after verifying
  63        // equal lengths, account for the case that an explicit `undefined`
  64        // value in the first is implicitly undefined in the second.
  65        //
  66        // Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )
  67        aValue === void 0 && !b.hasOwnProperty(key) || aValue !== b[key]
  68      ) {
  69        return false;
  70      }
  71      i++;
  72    }
  73    return true;
  74  }
  75  
  76  
  77  ;// ./node_modules/@wordpress/is-shallow-equal/build-module/arrays.js
  78  function isShallowEqualArrays(a, b) {
  79    if (a === b) {
  80      return true;
  81    }
  82    if (a.length !== b.length) {
  83      return false;
  84    }
  85    for (let i = 0, len = a.length; i < len; i++) {
  86      if (a[i] !== b[i]) {
  87        return false;
  88      }
  89    }
  90    return true;
  91  }
  92  
  93  
  94  ;// ./node_modules/@wordpress/is-shallow-equal/build-module/index.js
  95  
  96  
  97  
  98  
  99  function isShallowEqual(a, b) {
 100    if (a && b) {
 101      if (a.constructor === Object && b.constructor === Object) {
 102        return isShallowEqualObjects(a, b);
 103      } else if (Array.isArray(a) && Array.isArray(b)) {
 104        return isShallowEqualArrays(a, b);
 105      }
 106    }
 107    return a === b;
 108  }
 109  
 110  
 111  (window.wp = window.wp || {}).isShallowEqual = __webpack_exports__;
 112  /******/ })()
 113  ;


Generated : Thu Oct 30 08:20:06 2025 Cross-referenced by PHPXref