@commercetools/sync-actions 4.13.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,14 +18,9 @@
18
18
 
19
19
  if (Object.getOwnPropertySymbols) {
20
20
  var symbols = Object.getOwnPropertySymbols(object);
21
-
22
- if (enumerableOnly) {
23
- symbols = symbols.filter(function (sym) {
24
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
25
- });
26
- }
27
-
28
- keys.push.apply(keys, symbols);
21
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
22
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
23
+ })), keys.push.apply(keys, symbols);
29
24
  }
30
25
 
31
26
  return keys;
@@ -33,19 +28,12 @@
33
28
 
34
29
  function _objectSpread2(target) {
35
30
  for (var i = 1; i < arguments.length; i++) {
36
- var source = arguments[i] != null ? arguments[i] : {};
37
-
38
- if (i % 2) {
39
- ownKeys(Object(source), true).forEach(function (key) {
40
- _defineProperty(target, key, source[key]);
41
- });
42
- } else if (Object.getOwnPropertyDescriptors) {
43
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
44
- } else {
45
- ownKeys(Object(source)).forEach(function (key) {
46
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
47
- });
48
- }
31
+ var source = null != arguments[i] ? arguments[i] : {};
32
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
33
+ _defineProperty(target, key, source[key]);
34
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
35
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
36
+ });
49
37
  }
50
38
 
51
39
  return target;
@@ -54,17 +42,11 @@
54
42
  function _typeof(obj) {
55
43
  "@babel/helpers - typeof";
56
44
 
57
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
58
- _typeof = function (obj) {
59
- return typeof obj;
60
- };
61
- } else {
62
- _typeof = function (obj) {
63
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
64
- };
65
- }
66
-
67
- return _typeof(obj);
45
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
46
+ return typeof obj;
47
+ } : function (obj) {
48
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
49
+ }, _typeof(obj);
68
50
  }
69
51
 
70
52
  function _defineProperty(obj, key, value) {
@@ -2690,78 +2672,6 @@
2690
2672
  var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
2691
2673
  var keys = Object.keys;
2692
2674
  /**
2693
- * @function addToCache
2694
- *
2695
- * add object to cache if an object
2696
- *
2697
- * @param value the value to potentially add to cache
2698
- * @param cache the cache to add to
2699
- */
2700
-
2701
- function addToCache(value, cache) {
2702
- if (value && _typeof(value) === 'object') {
2703
- cache.add(value);
2704
- }
2705
- }
2706
- /**
2707
- * @function hasPair
2708
- *
2709
- * @description
2710
- * does the `pairToMatch` exist in the list of `pairs` provided based on the
2711
- * `isEqual` check
2712
- *
2713
- * @param pairs the pairs to compare against
2714
- * @param pairToMatch the pair to match
2715
- * @param isEqual the equality comparator used
2716
- * @param meta the meta provided
2717
- * @returns does the pair exist in the pairs provided
2718
- */
2719
-
2720
-
2721
- function hasPair(pairs, pairToMatch, isEqual, meta) {
2722
- var length = pairs.length;
2723
- var pair;
2724
-
2725
- for (var index = 0; index < length; index++) {
2726
- pair = pairs[index];
2727
-
2728
- if (isEqual(pair[0], pairToMatch[0], meta) && isEqual(pair[1], pairToMatch[1], meta)) {
2729
- return true;
2730
- }
2731
- }
2732
-
2733
- return false;
2734
- }
2735
- /**
2736
- * @function hasValue
2737
- *
2738
- * @description
2739
- * does the `valueToMatch` exist in the list of `values` provided based on the
2740
- * `isEqual` check
2741
- *
2742
- * @param values the values to compare against
2743
- * @param valueToMatch the value to match
2744
- * @param isEqual the equality comparator used
2745
- * @param meta the meta provided
2746
- * @returns does the value exist in the values provided
2747
- */
2748
-
2749
-
2750
- function hasValue(values, valueToMatch, isEqual, meta) {
2751
- var length = values.length;
2752
-
2753
- for (var index = 0; index < length; index++) {
2754
- if (isEqual(values[index], valueToMatch, meta)) {
2755
- return true;
2756
- }
2757
- }
2758
-
2759
- return false;
2760
- }
2761
- /**
2762
- * @function sameValueZeroEqual
2763
- *
2764
- * @description
2765
2675
  * are the values passed strictly equal or both NaN
2766
2676
  *
2767
2677
  * @param a the value to compare against
@@ -2769,14 +2679,10 @@
2769
2679
  * @returns are the values equal by the SameValueZero principle
2770
2680
  */
2771
2681
 
2772
-
2773
2682
  function sameValueZeroEqual(a, b) {
2774
2683
  return a === b || a !== a && b !== b;
2775
2684
  }
2776
2685
  /**
2777
- * @function isPlainObject
2778
- *
2779
- * @description
2780
2686
  * is the value a plain object
2781
2687
  *
2782
2688
  * @param value the value to test
@@ -2788,9 +2694,6 @@
2788
2694
  return value.constructor === Object || value.constructor == null;
2789
2695
  }
2790
2696
  /**
2791
- * @function isPromiseLike
2792
- *
2793
- * @description
2794
2697
  * is the value promise-like (meaning it is thenable)
2795
2698
  *
2796
2699
  * @param value the value to test
@@ -2802,9 +2705,6 @@
2802
2705
  return !!value && typeof value.then === 'function';
2803
2706
  }
2804
2707
  /**
2805
- * @function isReactElement
2806
- *
2807
- * @description
2808
2708
  * is the value passed a react element
2809
2709
  *
2810
2710
  * @param value the value to test
@@ -2816,9 +2716,6 @@
2816
2716
  return !!(value && value.$$typeof);
2817
2717
  }
2818
2718
  /**
2819
- * @function getNewCacheFallback
2820
- *
2821
- * @description
2822
2719
  * in cases where WeakSet is not supported, creates a new custom
2823
2720
  * object that mimics the necessary API aspects for cache purposes
2824
2721
  *
@@ -2827,20 +2724,17 @@
2827
2724
 
2828
2725
 
2829
2726
  function getNewCacheFallback() {
2830
- return Object.create({
2831
- _values: [],
2727
+ var values = [];
2728
+ return {
2832
2729
  add: function add(value) {
2833
- this._values.push(value);
2730
+ values.push(value);
2834
2731
  },
2835
2732
  has: function has(value) {
2836
- return this._values.indexOf(value) !== -1;
2733
+ return values.indexOf(value) !== -1;
2837
2734
  }
2838
- });
2735
+ };
2839
2736
  }
2840
2737
  /**
2841
- * @function getNewCache
2842
- *
2843
- * @description
2844
2738
  * get a new cache object to prevent circular references
2845
2739
  *
2846
2740
  * @returns the new cache object
@@ -2857,9 +2751,6 @@
2857
2751
  return getNewCacheFallback;
2858
2752
  }(HAS_WEAKSET_SUPPORT);
2859
2753
  /**
2860
- * @function createCircularEqualCreator
2861
- *
2862
- * @description
2863
2754
  * create a custom isEqual handler specific to circular objects
2864
2755
  *
2865
2756
  * @param [isEqual] the isEqual comparator to use instead of isDeepEqual
@@ -2876,61 +2767,31 @@
2876
2767
  cache = getNewCache();
2877
2768
  }
2878
2769
 
2879
- var hasA = cache.has(a);
2880
- var hasB = cache.has(b);
2770
+ var isCacheableA = !!a && _typeof(a) === 'object';
2771
+ var isCacheableB = !!b && _typeof(b) === 'object';
2772
+
2773
+ if (isCacheableA || isCacheableB) {
2774
+ var hasA = isCacheableA && cache.has(a);
2775
+ var hasB = isCacheableB && cache.has(b);
2881
2776
 
2882
- if (hasA || hasB) {
2883
- return hasA && hasB;
2777
+ if (hasA || hasB) {
2778
+ return hasA && hasB;
2779
+ }
2780
+
2781
+ if (isCacheableA) {
2782
+ cache.add(a);
2783
+ }
2784
+
2785
+ if (isCacheableB) {
2786
+ cache.add(b);
2787
+ }
2884
2788
  }
2885
2789
 
2886
- addToCache(a, cache);
2887
- addToCache(b, cache);
2888
2790
  return _comparator(a, b, cache);
2889
2791
  };
2890
2792
  };
2891
2793
  }
2892
2794
  /**
2893
- * @function toPairs
2894
- *
2895
- * @description
2896
- * convert the map passed into pairs (meaning an array of [key, value] tuples)
2897
- *
2898
- * @param map the map to convert to [key, value] pairs (entries)
2899
- * @returns the [key, value] pairs
2900
- */
2901
-
2902
-
2903
- function toPairs(map) {
2904
- var pairs = new Array(map.size);
2905
- var index = 0;
2906
- map.forEach(function (value, key) {
2907
- pairs[index++] = [key, value];
2908
- });
2909
- return pairs;
2910
- }
2911
- /**
2912
- * @function toValues
2913
- *
2914
- * @description
2915
- * convert the set passed into values
2916
- *
2917
- * @param set the set to convert to values
2918
- * @returns the values
2919
- */
2920
-
2921
-
2922
- function toValues(set) {
2923
- var values = new Array(set.size);
2924
- var index = 0;
2925
- set.forEach(function (value) {
2926
- values[index++] = value;
2927
- });
2928
- return values;
2929
- }
2930
- /**
2931
- * @function areArraysEqual
2932
- *
2933
- * @description
2934
2795
  * are the arrays equal in value
2935
2796
  *
2936
2797
  * @param a the array to test
@@ -2942,13 +2803,13 @@
2942
2803
 
2943
2804
 
2944
2805
  function areArraysEqual(a, b, isEqual, meta) {
2945
- var length = a.length;
2806
+ var index = a.length;
2946
2807
 
2947
- if (b.length !== length) {
2808
+ if (b.length !== index) {
2948
2809
  return false;
2949
2810
  }
2950
2811
 
2951
- for (var index = 0; index < length; index++) {
2812
+ while (index-- > 0) {
2952
2813
  if (!isEqual(a[index], b[index], meta)) {
2953
2814
  return false;
2954
2815
  }
@@ -2957,9 +2818,6 @@
2957
2818
  return true;
2958
2819
  }
2959
2820
  /**
2960
- * @function areMapsEqual
2961
- *
2962
- * @description
2963
2821
  * are the maps equal in value
2964
2822
  *
2965
2823
  * @param a the map to test
@@ -2971,29 +2829,36 @@
2971
2829
 
2972
2830
 
2973
2831
  function areMapsEqual(a, b, isEqual, meta) {
2974
- if (a.size !== b.size) {
2975
- return false;
2976
- }
2977
-
2978
- var pairsA = toPairs(a);
2979
- var pairsB = toPairs(b);
2980
- var length = pairsA.length;
2832
+ var isValueEqual = a.size === b.size;
2833
+
2834
+ if (isValueEqual && a.size) {
2835
+ var matchedIndices_1 = {};
2836
+ a.forEach(function (aValue, aKey) {
2837
+ if (isValueEqual) {
2838
+ var hasMatch_1 = false;
2839
+ var matchIndex_1 = 0;
2840
+ b.forEach(function (bValue, bKey) {
2841
+ if (!hasMatch_1 && !matchedIndices_1[matchIndex_1]) {
2842
+ hasMatch_1 = isEqual(aKey, bKey, meta) && isEqual(aValue, bValue, meta);
2843
+
2844
+ if (hasMatch_1) {
2845
+ matchedIndices_1[matchIndex_1] = true;
2846
+ }
2847
+ }
2981
2848
 
2982
- for (var index = 0; index < length; index++) {
2983
- if (!hasPair(pairsB, pairsA[index], isEqual, meta) || !hasPair(pairsA, pairsB[index], isEqual, meta)) {
2984
- return false;
2985
- }
2849
+ matchIndex_1++;
2850
+ });
2851
+ isValueEqual = hasMatch_1;
2852
+ }
2853
+ });
2986
2854
  }
2987
2855
 
2988
- return true;
2856
+ return isValueEqual;
2989
2857
  }
2990
2858
 
2991
2859
  var OWNER = '_owner';
2992
2860
  var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
2993
2861
  /**
2994
- * @function areObjectsEqual
2995
- *
2996
- * @description
2997
2862
  * are the objects equal in value
2998
2863
  *
2999
2864
  * @param a the object to test
@@ -3005,36 +2870,36 @@
3005
2870
 
3006
2871
  function areObjectsEqual(a, b, isEqual, meta) {
3007
2872
  var keysA = keys(a);
3008
- var length = keysA.length;
2873
+ var index = keysA.length;
3009
2874
 
3010
- if (keys(b).length !== length) {
2875
+ if (keys(b).length !== index) {
3011
2876
  return false;
3012
2877
  }
3013
2878
 
3014
- var key;
2879
+ if (index) {
2880
+ var key = void 0;
3015
2881
 
3016
- for (var index = 0; index < length; index++) {
3017
- key = keysA[index];
2882
+ while (index-- > 0) {
2883
+ key = keysA[index];
3018
2884
 
3019
- if (!hasOwnProperty(b, key)) {
3020
- return false;
3021
- }
2885
+ if (key === OWNER) {
2886
+ var reactElementA = isReactElement(a);
2887
+ var reactElementB = isReactElement(b);
3022
2888
 
3023
- if (key === OWNER && isReactElement(a)) {
3024
- if (!isReactElement(b)) {
2889
+ if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
2890
+ return false;
2891
+ }
2892
+ }
2893
+
2894
+ if (!hasOwnProperty(b, key) || !isEqual(a[key], b[key], meta)) {
3025
2895
  return false;
3026
2896
  }
3027
- } else if (!isEqual(a[key], b[key], meta)) {
3028
- return false;
3029
2897
  }
3030
2898
  }
3031
2899
 
3032
2900
  return true;
3033
2901
  }
3034
2902
  /**
3035
- * @function areRegExpsEqual
3036
- *
3037
- * @description
3038
2903
  * are the regExps equal in value
3039
2904
  *
3040
2905
  * @param a the regExp to test
@@ -3047,9 +2912,6 @@
3047
2912
  return a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.unicode === b.unicode && a.sticky === b.sticky && a.lastIndex === b.lastIndex;
3048
2913
  }
3049
2914
  /**
3050
- * @function areSetsEqual
3051
- *
3052
- * @description
3053
2915
  * are the sets equal in value
3054
2916
  *
3055
2917
  * @param a the set to test
@@ -3061,27 +2923,35 @@
3061
2923
 
3062
2924
 
3063
2925
  function areSetsEqual(a, b, isEqual, meta) {
3064
- if (a.size !== b.size) {
3065
- return false;
3066
- }
3067
-
3068
- var valuesA = toValues(a);
3069
- var valuesB = toValues(b);
3070
- var length = valuesA.length;
2926
+ var isValueEqual = a.size === b.size;
2927
+
2928
+ if (isValueEqual && a.size) {
2929
+ var matchedIndices_2 = {};
2930
+ a.forEach(function (aValue) {
2931
+ if (isValueEqual) {
2932
+ var hasMatch_2 = false;
2933
+ var matchIndex_2 = 0;
2934
+ b.forEach(function (bValue) {
2935
+ if (!hasMatch_2 && !matchedIndices_2[matchIndex_2]) {
2936
+ hasMatch_2 = isEqual(aValue, bValue, meta);
2937
+
2938
+ if (hasMatch_2) {
2939
+ matchedIndices_2[matchIndex_2] = true;
2940
+ }
2941
+ }
3071
2942
 
3072
- for (var index = 0; index < length; index++) {
3073
- if (!hasValue(valuesB, valuesA[index], isEqual, meta) || !hasValue(valuesA, valuesB[index], isEqual, meta)) {
3074
- return false;
3075
- }
2943
+ matchIndex_2++;
2944
+ });
2945
+ isValueEqual = hasMatch_2;
2946
+ }
2947
+ });
3076
2948
  }
3077
2949
 
3078
- return true;
2950
+ return isValueEqual;
3079
2951
  }
3080
2952
 
3081
- var isArray = Array.isArray;
3082
2953
  var HAS_MAP_SUPPORT = typeof Map === 'function';
3083
2954
  var HAS_SET_SUPPORT = typeof Set === 'function';
3084
- var OBJECT_TYPEOF = 'object';
3085
2955
 
3086
2956
  function createComparator(createIsEqual) {
3087
2957
  var isEqual =
@@ -3090,9 +2960,6 @@
3090
2960
  /* eslint-enable */
3091
2961
 
3092
2962
  /**
3093
- * @function comparator
3094
- *
3095
- * @description
3096
2963
  * compare the value of the two objects and return true if they are equivalent in values
3097
2964
  *
3098
2965
  * @param a the value to test against
@@ -3102,34 +2969,34 @@
3102
2969
  */
3103
2970
 
3104
2971
  function comparator(a, b, meta) {
3105
- if (sameValueZeroEqual(a, b)) {
2972
+ if (a === b) {
3106
2973
  return true;
3107
2974
  }
3108
2975
 
3109
- if (a && b && _typeof(a) === OBJECT_TYPEOF && _typeof(b) === OBJECT_TYPEOF) {
2976
+ if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
3110
2977
  if (isPlainObject(a) && isPlainObject(b)) {
3111
2978
  return areObjectsEqual(a, b, isEqual, meta);
3112
2979
  }
3113
2980
 
3114
- var arrayA = isArray(a);
3115
- var arrayB = isArray(b);
2981
+ var aShape = Array.isArray(a);
2982
+ var bShape = Array.isArray(b);
3116
2983
 
3117
- if (arrayA || arrayB) {
3118
- return arrayA === arrayB && areArraysEqual(a, b, isEqual, meta);
2984
+ if (aShape || bShape) {
2985
+ return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
3119
2986
  }
3120
2987
 
3121
- var aDate = a instanceof Date;
3122
- var bDate = b instanceof Date;
2988
+ aShape = a instanceof Date;
2989
+ bShape = b instanceof Date;
3123
2990
 
3124
- if (aDate || bDate) {
3125
- return aDate === bDate && sameValueZeroEqual(a.getTime(), b.getTime());
2991
+ if (aShape || bShape) {
2992
+ return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
3126
2993
  }
3127
2994
 
3128
- var aRegExp = a instanceof RegExp;
3129
- var bRegExp = b instanceof RegExp;
2995
+ aShape = a instanceof RegExp;
2996
+ bShape = b instanceof RegExp;
3130
2997
 
3131
- if (aRegExp || bRegExp) {
3132
- return aRegExp === bRegExp && areRegExpsEqual(a, b);
2998
+ if (aShape || bShape) {
2999
+ return aShape === bShape && areRegExpsEqual(a, b);
3133
3000
  }
3134
3001
 
3135
3002
  if (isPromiseLike(a) || isPromiseLike(b)) {
@@ -3137,32 +3004,31 @@
3137
3004
  }
3138
3005
 
3139
3006
  if (HAS_MAP_SUPPORT) {
3140
- var aMap = a instanceof Map;
3141
- var bMap = b instanceof Map;
3007
+ aShape = a instanceof Map;
3008
+ bShape = b instanceof Map;
3142
3009
 
3143
- if (aMap || bMap) {
3144
- return aMap === bMap && areMapsEqual(a, b, isEqual, meta);
3010
+ if (aShape || bShape) {
3011
+ return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
3145
3012
  }
3146
3013
  }
3147
3014
 
3148
3015
  if (HAS_SET_SUPPORT) {
3149
- var aSet = a instanceof Set;
3150
- var bSet = b instanceof Set;
3016
+ aShape = a instanceof Set;
3017
+ bShape = b instanceof Set;
3151
3018
 
3152
- if (aSet || bSet) {
3153
- return aSet === bSet && areSetsEqual(a, b, isEqual, meta);
3019
+ if (aShape || bShape) {
3020
+ return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
3154
3021
  }
3155
3022
  }
3156
3023
 
3157
3024
  return areObjectsEqual(a, b, isEqual, meta);
3158
3025
  }
3159
3026
 
3160
- return false;
3027
+ return a !== a && b !== b;
3161
3028
  }
3162
3029
 
3163
3030
  return comparator;
3164
- } // comparator
3165
-
3031
+ }
3166
3032
 
3167
3033
  var deepEqual = createComparator();
3168
3034
  createComparator(function () {