Blame view

天文台pc/tianwentai-ui/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js 1.63 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  function isObject(subject) {
    return Object.prototype.toString.call(subject) === '[object Object]';
  }
  function isRecord(subject) {
    return isObject(subject) || Array.isArray(subject);
  }
  function canUseDOM() {
    return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
  }
  function areOptionsEqual(optionsA, optionsB) {
    const optionsAKeys = Object.keys(optionsA);
    const optionsBKeys = Object.keys(optionsB);
    if (optionsAKeys.length !== optionsBKeys.length) return false;
    const breakpointsA = JSON.stringify(Object.keys(optionsA.breakpoints || {}));
    const breakpointsB = JSON.stringify(Object.keys(optionsB.breakpoints || {}));
    if (breakpointsA !== breakpointsB) return false;
    return optionsAKeys.every(key => {
      const valueA = optionsA[key];
      const valueB = optionsB[key];
      if (typeof valueA === 'function') return `${valueA}` === `${valueB}`;
      if (!isRecord(valueA) || !isRecord(valueB)) return valueA === valueB;
      return areOptionsEqual(valueA, valueB);
    });
  }
  function sortAndMapPluginToOptions(plugins) {
    return plugins.concat().sort((a, b) => a.name > b.name ? 1 : -1).map(plugin => plugin.options);
  }
  function arePluginsEqual(pluginsA, pluginsB) {
    if (pluginsA.length !== pluginsB.length) return false;
    const optionsA = sortAndMapPluginToOptions(pluginsA);
    const optionsB = sortAndMapPluginToOptions(pluginsB);
    return optionsA.every((optionA, index) => {
      const optionB = optionsB[index];
      return areOptionsEqual(optionA, optionB);
    });
  }
  
  export { areOptionsEqual, arePluginsEqual, canUseDOM, sortAndMapPluginToOptions };
  //# sourceMappingURL=embla-carousel-reactive-utils.esm.js.map