si-funciona 2.3.4 → 2.4.1

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.
Files changed (94) hide show
  1. package/dist/helpers/arrays/addUniqueToArray.d.ts +10 -10
  2. package/dist/helpers/arrays/addUniqueToArray.js +17 -17
  3. package/dist/helpers/arrays/buildArray.d.ts +11 -11
  4. package/dist/helpers/arrays/buildArray.js +26 -26
  5. package/dist/helpers/arrays/buildArrayOfReferences.d.ts +11 -11
  6. package/dist/helpers/arrays/buildArrayOfReferences.js +23 -23
  7. package/dist/helpers/arrays/compareArrays.d.ts +97 -97
  8. package/dist/helpers/arrays/compareArrays.js +97 -97
  9. package/dist/helpers/arrays/mergeArrays.d.ts +9 -9
  10. package/dist/helpers/arrays/mergeArrays.js +22 -22
  11. package/dist/helpers/arrays/uniqueArray.d.ts +9 -9
  12. package/dist/helpers/arrays/uniqueArray.js +17 -17
  13. package/dist/helpers/descriptors/samples/descriptor.js +22 -22
  14. package/dist/helpers/descriptors/samples/descriptorDetail.js +24 -24
  15. package/dist/helpers/descriptors/samples/descriptorMap.js +14 -14
  16. package/dist/helpers/functions/callWithParams.d.ts +11 -11
  17. package/dist/helpers/functions/callWithParams.js +17 -17
  18. package/dist/helpers/functions/curry.d.ts +11 -11
  19. package/dist/helpers/functions/curry.js +17 -17
  20. package/dist/helpers/functions/delay.d.ts +21 -21
  21. package/dist/helpers/functions/delay.js +32 -32
  22. package/dist/helpers/functions/onBodyLoad.d.ts +10 -10
  23. package/dist/helpers/functions/onBodyLoad.js +74 -74
  24. package/dist/helpers/functions/pipe.d.ts +10 -10
  25. package/dist/helpers/functions/pipe.js +18 -18
  26. package/dist/helpers/functions/preloadParams.d.ts +20 -20
  27. package/dist/helpers/functions/preloadParams.js +21 -21
  28. package/dist/helpers/functions/queueTimeout.d.ts +21 -21
  29. package/dist/helpers/functions/queueTimeout.js +23 -23
  30. package/dist/helpers/functions.d.ts +29 -29
  31. package/dist/helpers/functions.js +40 -40
  32. package/dist/helpers/numbers/absoluteMax.d.ts +10 -10
  33. package/dist/helpers/numbers/absoluteMax.js +16 -16
  34. package/dist/helpers/numbers/absoluteMin.d.ts +10 -10
  35. package/dist/helpers/numbers/absoluteMin.js +16 -16
  36. package/dist/helpers/numbers/compare.d.ts +13 -13
  37. package/dist/helpers/numbers/compare.js +19 -19
  38. package/dist/helpers/numbers/greatestCommonDivisor.d.ts +10 -10
  39. package/dist/helpers/numbers/greatestCommonDivisor.js +16 -16
  40. package/dist/helpers/numbers/leastCommonMultiple.d.ts +10 -10
  41. package/dist/helpers/numbers/leastCommonMultiple.js +18 -18
  42. package/dist/helpers/numbers/randomInteger.d.ts +13 -13
  43. package/dist/helpers/numbers/randomInteger.js +19 -19
  44. package/dist/helpers/numbers/randomNumber.d.ts +13 -13
  45. package/dist/helpers/numbers/randomNumber.js +19 -19
  46. package/dist/helpers/numbers/simplestRatio.d.ts +9 -9
  47. package/dist/helpers/numbers/simplestRatio.js +29 -29
  48. package/dist/helpers/numbers.d.ts +21 -21
  49. package/dist/helpers/numbers.js +36 -36
  50. package/dist/helpers/objects/cloneObject.d.ts +20 -20
  51. package/dist/helpers/objects/cloneObject.js +32 -32
  52. package/dist/helpers/objects/dotGet.d.ts +12 -12
  53. package/dist/helpers/objects/dotGet.js +60 -60
  54. package/dist/helpers/objects/dotNotate.d.ts +28 -28
  55. package/dist/helpers/objects/dotNotate.js +80 -80
  56. package/dist/helpers/objects/dotSet.d.ts +12 -12
  57. package/dist/helpers/objects/dotSet.js +54 -54
  58. package/dist/helpers/objects/dotUnset.d.ts +11 -11
  59. package/dist/helpers/objects/dotUnset.js +53 -53
  60. package/dist/helpers/objects/emptyObject.d.ts +9 -9
  61. package/dist/helpers/objects/emptyObject.js +18 -18
  62. package/dist/helpers/objects/filterObject.d.ts +27 -27
  63. package/dist/helpers/objects/filterObject.js +32 -32
  64. package/dist/helpers/objects/isCloneable.d.ts +9 -9
  65. package/dist/helpers/objects/isCloneable.js +17 -17
  66. package/dist/helpers/objects/isInstanceObject.d.ts +9 -9
  67. package/dist/helpers/objects/isInstanceObject.js +27 -27
  68. package/dist/helpers/objects/isObject.d.ts +9 -9
  69. package/dist/helpers/objects/isObject.js +15 -15
  70. package/dist/helpers/objects/mapObject.d.ts +26 -26
  71. package/dist/helpers/objects/mapObject.js +26 -26
  72. package/dist/helpers/objects/mergeObjects.d.ts +13 -13
  73. package/dist/helpers/objects/mergeObjects.js +20 -20
  74. package/dist/helpers/objects/mergeObjectsBase.d.ts +36 -36
  75. package/dist/helpers/objects/mergeObjectsBase.js +92 -92
  76. package/dist/helpers/objects/mergeObjectsMutable.d.ts +13 -13
  77. package/dist/helpers/objects/mergeObjectsMutable.js +18 -18
  78. package/dist/helpers/objects/objectKeys.d.ts +14 -14
  79. package/dist/helpers/objects/objectKeys.js +40 -40
  80. package/dist/helpers/objects/objectValues.d.ts +14 -14
  81. package/dist/helpers/objects/objectValues.js +21 -21
  82. package/dist/helpers/objects/reduceObject.d.ts +31 -31
  83. package/dist/helpers/objects/reduceObject.js +26 -26
  84. package/dist/helpers/objects/setAndReturnValue.d.ts +14 -14
  85. package/dist/helpers/objects/setAndReturnValue.js +20 -20
  86. package/dist/helpers/objects/setValue.d.ts +15 -15
  87. package/dist/helpers/objects/setValue.js +22 -22
  88. package/dist/helpers/objects.d.ts +100 -100
  89. package/dist/helpers/objects.js +56 -56
  90. package/dist/helpers/strings.d.ts +25 -25
  91. package/dist/helpers/strings.js +44 -44
  92. package/dist/main.d.ts +9 -9
  93. package/dist/main.js +30 -30
  94. package/package.json +6 -5
@@ -1,11 +1,11 @@
1
- import 'core-js/stable';
2
- /**
3
- * Having an array and a potential new array element, check if the element is in the array, if not append to array.
4
- * @memberOf module:arrayHelpers
5
- * @param {*} item - An potential array element, possibly a DomItem
6
- * @param {Array} array - An array where an element may be appended.
7
- * @returns {Array}
8
- */
9
- declare const addUniqueToArray: (item: any, array: Array<any>) => Array<any>;
10
- export default addUniqueToArray;
1
+ import 'core-js/stable';
2
+ /**
3
+ * Having an array and a potential new array element, check if the element is in the array, if not append to array.
4
+ * @memberOf module:arrayHelpers
5
+ * @param {*} item - An potential array element, possibly a DomItem
6
+ * @param {Array} array - An array where an element may be appended.
7
+ * @returns {Array}
8
+ */
9
+ declare const addUniqueToArray: (item: any, array: Array<any>) => Array<any>;
10
+ export default addUniqueToArray;
11
11
  //# sourceMappingURL=addUniqueToArray.d.ts.map
@@ -1,17 +1,17 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.default = void 0
7
- require('core-js/modules/es.array.includes.js')
8
- require('core-js/stable')
9
- /**
10
- * Having an array and a potential new array element, check if the element is in the array, if not append to array.
11
- * @memberOf module:arrayHelpers
12
- * @param {*} item - An potential array element, possibly a DomItem
13
- * @param {Array} array - An array where an element may be appended.
14
- * @returns {Array}
15
- */
16
- const addUniqueToArray = (item, array) => !array.includes(item) ? array.concat([item]) : array
17
- var _default = exports.default = addUniqueToArray
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.default = void 0
7
+ require('core-js/modules/es.array.includes.js')
8
+ require('core-js/stable')
9
+ /**
10
+ * Having an array and a potential new array element, check if the element is in the array, if not append to array.
11
+ * @memberOf module:arrayHelpers
12
+ * @param {*} item - An potential array element, possibly a DomItem
13
+ * @param {Array} array - An array where an element may be appended.
14
+ * @returns {Array}
15
+ */
16
+ const addUniqueToArray = (item, array) => !array.includes(item) ? array.concat([item]) : array
17
+ var _default = exports.default = addUniqueToArray
@@ -1,12 +1,12 @@
1
- import 'core-js/stable';
2
- /**
3
- * Leverage buildArrayBase to generate an array filled with a copy of the provided item.
4
- * The length defines how long the array should be.
5
- * @memberOf module:arrayHelpers
6
- * @param {*} item - The item to be used for each array element
7
- * @param {number} length - The desired length of the array
8
- * @returns {Array.<*>}
9
- */
10
- declare const buildArray: (item: any, length: number) => Array<any>;
11
- export default buildArray;
1
+ import 'core-js/stable';
2
+ /**
3
+ * Leverage buildArrayBase to generate an array filled with a copy of the provided item.
4
+ * The length defines how long the array should be.
5
+ * @memberOf module:arrayHelpers
6
+ * @param {*} item - The item to be used for each array element
7
+ * @param {number} length - The desired length of the array
8
+ * @returns {Array.<*>}
9
+ */
10
+ declare const buildArray: (item: any, length: number) => Array<any>;
11
+ export default buildArray;
12
12
  //# sourceMappingURL=buildArray.d.ts.map
@@ -1,26 +1,26 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.default = void 0
7
- require('core-js/stable')
8
- var _cloneObject = _interopRequireDefault(require('../objects/cloneObject'))
9
- function _interopRequireDefault (e) { return e && e.__esModule ? e : { default: e } }
10
- /**
11
- * Leverage buildArrayBase to generate an array filled with a copy of the provided item.
12
- * The length defines how long the array should be.
13
- * @memberOf module:arrayHelpers
14
- * @param {*} item - The item to be used for each array element
15
- * @param {number} length - The desired length of the array
16
- * @returns {Array.<*>}
17
- */
18
- const buildArray = (item, length) => {
19
- const arr = []
20
- while (arr.length < length) {
21
- const cloned = (0, _cloneObject.default)(item)
22
- arr.push(cloned)
23
- }
24
- return arr
25
- }
26
- var _default = exports.default = buildArray
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.default = void 0
7
+ require('core-js/stable')
8
+ var _cloneObject = _interopRequireDefault(require('../objects/cloneObject'))
9
+ function _interopRequireDefault (e) { return e && e.__esModule ? e : { default: e } }
10
+ /**
11
+ * Leverage buildArrayBase to generate an array filled with a copy of the provided item.
12
+ * The length defines how long the array should be.
13
+ * @memberOf module:arrayHelpers
14
+ * @param {*} item - The item to be used for each array element
15
+ * @param {number} length - The desired length of the array
16
+ * @returns {Array.<*>}
17
+ */
18
+ const buildArray = (item, length) => {
19
+ const arr = []
20
+ while (arr.length < length) {
21
+ const cloned = (0, _cloneObject.default)(item)
22
+ arr.push(cloned)
23
+ }
24
+ return arr
25
+ }
26
+ var _default = exports.default = buildArray
@@ -1,12 +1,12 @@
1
- import 'core-js/stable';
2
- /**
3
- * Leverage buildArrayBase to generate an array filled with references to the provided item.
4
- * The length defines how long the array should be.
5
- * @memberOf module:arrayHelpers
6
- * @param {*} item - The item to be used for each array element
7
- * @param {number} length - The desired length of the array
8
- * @returns {Array.<*>}
9
- */
10
- declare const buildArrayOfReferences: (item: any, length: number) => Array<any>;
11
- export default buildArrayOfReferences;
1
+ import 'core-js/stable';
2
+ /**
3
+ * Leverage buildArrayBase to generate an array filled with references to the provided item.
4
+ * The length defines how long the array should be.
5
+ * @memberOf module:arrayHelpers
6
+ * @param {*} item - The item to be used for each array element
7
+ * @param {number} length - The desired length of the array
8
+ * @returns {Array.<*>}
9
+ */
10
+ declare const buildArrayOfReferences: (item: any, length: number) => Array<any>;
11
+ export default buildArrayOfReferences;
12
12
  //# sourceMappingURL=buildArrayOfReferences.d.ts.map
@@ -1,23 +1,23 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.default = void 0
7
- require('core-js/stable')
8
- /**
9
- * Leverage buildArrayBase to generate an array filled with references to the provided item.
10
- * The length defines how long the array should be.
11
- * @memberOf module:arrayHelpers
12
- * @param {*} item - The item to be used for each array element
13
- * @param {number} length - The desired length of the array
14
- * @returns {Array.<*>}
15
- */
16
- const buildArrayOfReferences = (item, length) => {
17
- const arr = []
18
- while (arr.length < length) {
19
- arr.push(item)
20
- }
21
- return arr
22
- }
23
- var _default = exports.default = buildArrayOfReferences
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.default = void 0
7
+ require('core-js/stable')
8
+ /**
9
+ * Leverage buildArrayBase to generate an array filled with references to the provided item.
10
+ * The length defines how long the array should be.
11
+ * @memberOf module:arrayHelpers
12
+ * @param {*} item - The item to be used for each array element
13
+ * @param {number} length - The desired length of the array
14
+ * @returns {Array.<*>}
15
+ */
16
+ const buildArrayOfReferences = (item, length) => {
17
+ const arr = []
18
+ while (arr.length < length) {
19
+ arr.push(item)
20
+ }
21
+ return arr
22
+ }
23
+ var _default = exports.default = buildArrayOfReferences
@@ -1,98 +1,98 @@
1
- import 'core-js/stable';
2
- /**
3
- * Store the comparison result for an element that may exist in either of compared arrays.
4
- * - value stores the element value from the arrays being compared
5
- * - results has the comparison results where first index (0) is result for first compared array
6
- * and the second index (1) will be the result for the second compared array
7
- * @example
8
- * // example of input and resulting output
9
- *
10
- * const arr1 = ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1']
11
- * const arr2 = ['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
12
- *
13
- * // Taking the first element in both, then the value: 'match1' exists in both arrays
14
- * // compareArrayResult will be { value: 'match1', result: [0, 0] }
15
- * // First index of 0 indicates this value in the first array exists in the second array
16
- * // Second index of 0 indicates this value in the second array exists in the first array
17
- *
18
- * // Taking the second element in the first array, then the value: 'firstMismatch1' exists in only the first array
19
- * // compareArrayResult will be { value: 'firstMismatch1', result: [1, -1] }
20
- * // First index of 1 indicates this value in the first array might need to be added to the second array
21
- * // Second index of -1 indicates this value only exists in the first array
22
- *
23
- * // Taking the third element in the second array, then the value: 'secondMismatch1' exists in only the second array
24
- * // compareArrayResult will be { value: 'secondMismatch1', result: [-1, 1] }
25
- * // First index of -1 indicates this value only exists in the second array
26
- * // Second index of 1 indicates this value in the second array might need to be added to the first array
27
- * @typedef {Object.<string, string|Array.<number>>} module:arrayHelpers~compareArrayResult
28
- * @memberOf module:arrayHelpers
29
- * @property {string} value - The element value being compared
30
- * @property {Array.<Array.<string|number>>} keys - Keys in arrays associated with this value
31
- * @property {Array.<number>} result - The results in the order of the compared arrays
32
- */
33
- export type compareArrayResult = {
34
- value: string;
35
- keys: Array<Array<number | string>>;
36
- result: Array<number>;
37
- };
38
- export type compareArrayResultMap = Array<compareArrayResult>;
39
- /**
40
- * Compare two Arrays and return the Object where the value for each property is as follows:
41
- * -1 to indicate val1 is less than val2
42
- * 0 to indicate both values are the equal
43
- * 1 to indicate val1 is greater than val2
44
- * The returned Object uses the element values as the property names
45
- * This functions works by first creating a concatenated array of all unique values. Then for each unique values,
46
- * convert to a string and use it as a new property name. Array filter each array checking if it has the unique value.
47
- * Use the lengths of these filtered arrays to compare. So if the first array has the value and the second one doesn't
48
- * the first length will be one or more and the second will be zero, if the both have the value then both will be one
49
- * or more.
50
- * @example
51
- * // example of input and resulting output
52
- * compareArrays(
53
- * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1'],
54
- * ['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
55
- * )
56
- * // unique array
57
- * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1', 'secondMismatch1']
58
- * // result object
59
- * [
60
- * {
61
- * value: 'match1',
62
- * keys: [[0], [0]],
63
- * result: [0, 0]
64
- * },
65
- * {
66
- * value: 'firstMismatch1',
67
- * keys: [[1], []],
68
- * result: [1, -1]
69
- * },
70
- * {
71
- * value: 'match2',
72
- * keys: [[2], [1]],
73
- * result: [0, 0]
74
- * },
75
- * {
76
- * value: 'firstMismatch2',
77
- * keys: [[3], []],
78
- * result: [1, -1]
79
- * },
80
- * {
81
- * value: 'badMatch1',
82
- * keys: [[4], [3, 4]],
83
- * result: [0, 0]
84
- * },
85
- * {
86
- * value: 'secondMismatch1',
87
- * keys: [[], [2]],
88
- * result: [-1, 1]
89
- * }
90
- * ]
91
- *
92
- * @memberOf module:arrayHelpers
93
- * @param {...Array} arrays - The arrays to compare
94
- * @returns {Array.<module:arrayHelpers~compareArrayResult>}
95
- */
96
- declare const compareArrays: (...arrays: Array<Array<any>>) => compareArrayResultMap;
97
- export default compareArrays;
1
+ import 'core-js/stable';
2
+ /**
3
+ * Store the comparison result for an element that may exist in either of compared arrays.
4
+ * - value stores the element value from the arrays being compared
5
+ * - results has the comparison results where first index (0) is result for first compared array
6
+ * and the second index (1) will be the result for the second compared array
7
+ * @example
8
+ * // example of input and resulting output
9
+ *
10
+ * const arr1 = ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1']
11
+ * const arr2 = ['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
12
+ *
13
+ * // Taking the first element in both, then the value: 'match1' exists in both arrays
14
+ * // compareArrayResult will be { value: 'match1', result: [0, 0] }
15
+ * // First index of 0 indicates this value in the first array exists in the second array
16
+ * // Second index of 0 indicates this value in the second array exists in the first array
17
+ *
18
+ * // Taking the second element in the first array, then the value: 'firstMismatch1' exists in only the first array
19
+ * // compareArrayResult will be { value: 'firstMismatch1', result: [1, -1] }
20
+ * // First index of 1 indicates this value in the first array might need to be added to the second array
21
+ * // Second index of -1 indicates this value only exists in the first array
22
+ *
23
+ * // Taking the third element in the second array, then the value: 'secondMismatch1' exists in only the second array
24
+ * // compareArrayResult will be { value: 'secondMismatch1', result: [-1, 1] }
25
+ * // First index of -1 indicates this value only exists in the second array
26
+ * // Second index of 1 indicates this value in the second array might need to be added to the first array
27
+ * @typedef {Object.<string, string|Array.<number>>} module:arrayHelpers~compareArrayResult
28
+ * @memberOf module:arrayHelpers
29
+ * @property {string} value - The element value being compared
30
+ * @property {Array.<Array.<string|number>>} keys - Keys in arrays associated with this value
31
+ * @property {Array.<number>} result - The results in the order of the compared arrays
32
+ */
33
+ export type compareArrayResult = {
34
+ value: string;
35
+ keys: Array<Array<number | string>>;
36
+ result: Array<number>;
37
+ };
38
+ export type compareArrayResultMap = Array<compareArrayResult>;
39
+ /**
40
+ * Compare two Arrays and return the Object where the value for each property is as follows:
41
+ * -1 to indicate val1 is less than val2
42
+ * 0 to indicate both values are the equal
43
+ * 1 to indicate val1 is greater than val2
44
+ * The returned Object uses the element values as the property names
45
+ * This functions works by first creating a concatenated array of all unique values. Then for each unique values,
46
+ * convert to a string and use it as a new property name. Array filter each array checking if it has the unique value.
47
+ * Use the lengths of these filtered arrays to compare. So if the first array has the value and the second one doesn't
48
+ * the first length will be one or more and the second will be zero, if the both have the value then both will be one
49
+ * or more.
50
+ * @example
51
+ * // example of input and resulting output
52
+ * compareArrays(
53
+ * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1'],
54
+ * ['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
55
+ * )
56
+ * // unique array
57
+ * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1', 'secondMismatch1']
58
+ * // result object
59
+ * [
60
+ * {
61
+ * value: 'match1',
62
+ * keys: [[0], [0]],
63
+ * result: [0, 0]
64
+ * },
65
+ * {
66
+ * value: 'firstMismatch1',
67
+ * keys: [[1], []],
68
+ * result: [1, -1]
69
+ * },
70
+ * {
71
+ * value: 'match2',
72
+ * keys: [[2], [1]],
73
+ * result: [0, 0]
74
+ * },
75
+ * {
76
+ * value: 'firstMismatch2',
77
+ * keys: [[3], []],
78
+ * result: [1, -1]
79
+ * },
80
+ * {
81
+ * value: 'badMatch1',
82
+ * keys: [[4], [3, 4]],
83
+ * result: [0, 0]
84
+ * },
85
+ * {
86
+ * value: 'secondMismatch1',
87
+ * keys: [[], [2]],
88
+ * result: [-1, 1]
89
+ * }
90
+ * ]
91
+ *
92
+ * @memberOf module:arrayHelpers
93
+ * @param {...Array} arrays - The arrays to compare
94
+ * @returns {Array.<module:arrayHelpers~compareArrayResult>}
95
+ */
96
+ declare const compareArrays: (...arrays: Array<Array<any>>) => compareArrayResultMap;
97
+ export default compareArrays;
98
98
  //# sourceMappingURL=compareArrays.d.ts.map
@@ -1,97 +1,97 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- })
6
- exports.default = void 0
7
- require('core-js/modules/esnext.iterator.constructor.js')
8
- require('core-js/modules/esnext.iterator.every.js')
9
- require('core-js/modules/esnext.iterator.map.js')
10
- require('core-js/modules/esnext.iterator.reduce.js')
11
- require('core-js/stable')
12
- var _isObject = _interopRequireDefault(require('../objects/isObject'))
13
- var _mergeArrays = _interopRequireDefault(require('./mergeArrays'))
14
- var _objectKeys = _interopRequireDefault(require('../objects/objectKeys'))
15
- function _interopRequireDefault (e) { return e && e.__esModule ? e : { default: e } }
16
- /**
17
- * Compare two Arrays and return the Object where the value for each property is as follows:
18
- * -1 to indicate val1 is less than val2
19
- * 0 to indicate both values are the equal
20
- * 1 to indicate val1 is greater than val2
21
- * The returned Object uses the element values as the property names
22
- * This functions works by first creating a concatenated array of all unique values. Then for each unique values,
23
- * convert to a string and use it as a new property name. Array filter each array checking if it has the unique value.
24
- * Use the lengths of these filtered arrays to compare. So if the first array has the value and the second one doesn't
25
- * the first length will be one or more and the second will be zero, if the both have the value then both will be one
26
- * or more.
27
- * @example
28
- * // example of input and resulting output
29
- * compareArrays(
30
- * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1'],
31
- * ['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
32
- * )
33
- * // unique array
34
- * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1', 'secondMismatch1']
35
- * // result object
36
- * [
37
- * {
38
- * value: 'match1',
39
- * keys: [[0], [0]],
40
- * result: [0, 0]
41
- * },
42
- * {
43
- * value: 'firstMismatch1',
44
- * keys: [[1], []],
45
- * result: [1, -1]
46
- * },
47
- * {
48
- * value: 'match2',
49
- * keys: [[2], [1]],
50
- * result: [0, 0]
51
- * },
52
- * {
53
- * value: 'firstMismatch2',
54
- * keys: [[3], []],
55
- * result: [1, -1]
56
- * },
57
- * {
58
- * value: 'badMatch1',
59
- * keys: [[4], [3, 4]],
60
- * result: [0, 0]
61
- * },
62
- * {
63
- * value: 'secondMismatch1',
64
- * keys: [[], [2]],
65
- * result: [-1, 1]
66
- * }
67
- * ]
68
- *
69
- * @memberOf module:arrayHelpers
70
- * @param {...Array} arrays - The arrays to compare
71
- * @returns {Array.<module:arrayHelpers~compareArrayResult>}
72
- */
73
- const compareArrays = (...arrays) => (0, _mergeArrays.default)(...arrays).reduce((results, attr) => {
74
- const attrType = typeof attr
75
- const useArray = Array.isArray(attr)
76
- const keys = arrays.map(array => array.reduce((results, current, key) => {
77
- const currentType = typeof current
78
- if (attrType !== currentType) {
79
- return results
80
- }
81
- if (!(0, _isObject.default)(attr)) {
82
- return current === attr ? [...results, key] : results
83
- }
84
- if (useArray !== Array.isArray(current)) {
85
- return results
86
- }
87
- const compareKeys = useArray ? compareArrays(attr, current) : compareArrays((0, _objectKeys.default)(attr), (0, _objectKeys.default)(current))
88
- return compareKeys.every(compare => compare.result.every(result => result === 0)) ? [...results, key] : results
89
- }, []))
90
- const arrayResults = keys.map(array => array.length ? 1 : -1)
91
- return [...results, {
92
- value: attr,
93
- keys: keys,
94
- result: arrayResults.every(result => result === 1) ? arrayResults.map(result => 0) : arrayResults
95
- }]
96
- }, [])
97
- var _default = exports.default = compareArrays
1
+ 'use strict'
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ })
6
+ exports.default = void 0
7
+ require('core-js/modules/esnext.iterator.constructor.js')
8
+ require('core-js/modules/esnext.iterator.every.js')
9
+ require('core-js/modules/esnext.iterator.map.js')
10
+ require('core-js/modules/esnext.iterator.reduce.js')
11
+ require('core-js/stable')
12
+ var _isObject = _interopRequireDefault(require('../objects/isObject'))
13
+ var _mergeArrays = _interopRequireDefault(require('./mergeArrays'))
14
+ var _objectKeys = _interopRequireDefault(require('../objects/objectKeys'))
15
+ function _interopRequireDefault (e) { return e && e.__esModule ? e : { default: e } }
16
+ /**
17
+ * Compare two Arrays and return the Object where the value for each property is as follows:
18
+ * -1 to indicate val1 is less than val2
19
+ * 0 to indicate both values are the equal
20
+ * 1 to indicate val1 is greater than val2
21
+ * The returned Object uses the element values as the property names
22
+ * This functions works by first creating a concatenated array of all unique values. Then for each unique values,
23
+ * convert to a string and use it as a new property name. Array filter each array checking if it has the unique value.
24
+ * Use the lengths of these filtered arrays to compare. So if the first array has the value and the second one doesn't
25
+ * the first length will be one or more and the second will be zero, if the both have the value then both will be one
26
+ * or more.
27
+ * @example
28
+ * // example of input and resulting output
29
+ * compareArrays(
30
+ * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1'],
31
+ * ['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
32
+ * )
33
+ * // unique array
34
+ * ['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1', 'secondMismatch1']
35
+ * // result object
36
+ * [
37
+ * {
38
+ * value: 'match1',
39
+ * keys: [[0], [0]],
40
+ * result: [0, 0]
41
+ * },
42
+ * {
43
+ * value: 'firstMismatch1',
44
+ * keys: [[1], []],
45
+ * result: [1, -1]
46
+ * },
47
+ * {
48
+ * value: 'match2',
49
+ * keys: [[2], [1]],
50
+ * result: [0, 0]
51
+ * },
52
+ * {
53
+ * value: 'firstMismatch2',
54
+ * keys: [[3], []],
55
+ * result: [1, -1]
56
+ * },
57
+ * {
58
+ * value: 'badMatch1',
59
+ * keys: [[4], [3, 4]],
60
+ * result: [0, 0]
61
+ * },
62
+ * {
63
+ * value: 'secondMismatch1',
64
+ * keys: [[], [2]],
65
+ * result: [-1, 1]
66
+ * }
67
+ * ]
68
+ *
69
+ * @memberOf module:arrayHelpers
70
+ * @param {...Array} arrays - The arrays to compare
71
+ * @returns {Array.<module:arrayHelpers~compareArrayResult>}
72
+ */
73
+ const compareArrays = (...arrays) => (0, _mergeArrays.default)(...arrays).reduce((results, attr) => {
74
+ const attrType = typeof attr
75
+ const useArray = Array.isArray(attr)
76
+ const keys = arrays.map(array => array.reduce((results, current, key) => {
77
+ const currentType = typeof current
78
+ if (attrType !== currentType) {
79
+ return results
80
+ }
81
+ if (!(0, _isObject.default)(attr)) {
82
+ return current === attr ? [...results, key] : results
83
+ }
84
+ if (useArray !== Array.isArray(current)) {
85
+ return results
86
+ }
87
+ const compareKeys = useArray ? compareArrays(attr, current) : compareArrays((0, _objectKeys.default)(attr), (0, _objectKeys.default)(current))
88
+ return compareKeys.every(compare => compare.result.every(result => result === 0)) ? [...results, key] : results
89
+ }, []))
90
+ const arrayResults = keys.map(array => array.length ? 1 : -1)
91
+ return [...results, {
92
+ value: attr,
93
+ keys: keys,
94
+ result: arrayResults.every(result => result === 1) ? arrayResults.map(result => 0) : arrayResults
95
+ }]
96
+ }, [])
97
+ var _default = exports.default = compareArrays
@@ -1,10 +1,10 @@
1
- import 'core-js/stable';
2
- /**
3
- * Take multiple arrays and then filter all these into one unique array.
4
- * @memberOf module:arrayHelpers
5
- * @param {...Array} arrays - Provide multiple arrays to create one unique array
6
- * @returns {Array}
7
- */
8
- declare const mergeArrays: (...arrays: Array<Array<any>>) => Array<any>;
9
- export default mergeArrays;
1
+ import 'core-js/stable';
2
+ /**
3
+ * Take multiple arrays and then filter all these into one unique array.
4
+ * @memberOf module:arrayHelpers
5
+ * @param {...Array} arrays - Provide multiple arrays to create one unique array
6
+ * @returns {Array}
7
+ */
8
+ declare const mergeArrays: (...arrays: Array<Array<any>>) => Array<any>;
9
+ export default mergeArrays;
10
10
  //# sourceMappingURL=mergeArrays.d.ts.map