@mongez/reinforcements 1.0.16 → 1.0.20

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 (143) hide show
  1. package/cjs/__helpers/tslib/tslib.es6.js +28 -15
  2. package/cjs/arr.js +645 -2
  3. package/cjs/index.d.ts +1 -0
  4. package/cjs/index.js +84 -2
  5. package/cjs/obj.d.ts +4 -0
  6. package/cjs/obj.js +108 -2
  7. package/cjs/utilities/escapeRegex.js +10 -2
  8. package/cjs/utilities/number/round.js +16 -2
  9. package/cjs/utilities/object/objClone.d.ts +3 -0
  10. package/cjs/utilities/object/objClone.js +12 -2
  11. package/cjs/utilities/object/objFlatten.d.ts +5 -0
  12. package/cjs/utilities/object/objFlatten.js +29 -0
  13. package/cjs/utilities/object/objGet.js +22 -2
  14. package/cjs/utilities/object/objMap.js +16 -2
  15. package/cjs/utilities/object/objOnly.js +19 -2
  16. package/cjs/utilities/object/objSet.js +35 -2
  17. package/cjs/utilities/object/objSort.js +21 -2
  18. package/cjs/utilities/random.js +63 -2
  19. package/cjs/utilities/str/capitalize.js +14 -2
  20. package/cjs/utilities/str/extension.js +11 -2
  21. package/cjs/utilities/str/ltrim.js +17 -2
  22. package/cjs/utilities/str/readMoreChars.js +14 -2
  23. package/cjs/utilities/str/readMoreWords.js +14 -2
  24. package/cjs/utilities/str/removeFirst.js +15 -2
  25. package/cjs/utilities/str/removeLast.js +15 -2
  26. package/cjs/utilities/str/repeatsOf.js +19 -2
  27. package/cjs/utilities/str/replaceAll.js +16 -2
  28. package/cjs/utilities/str/replaceFirst.js +16 -2
  29. package/cjs/utilities/str/replaceLast.js +18 -2
  30. package/cjs/utilities/str/rtrim.js +17 -2
  31. package/cjs/utilities/str/sprintf.js +16 -2
  32. package/cjs/utilities/str/startsWithArabic.js +17 -2
  33. package/cjs/utilities/str/toCamelCase.js +13 -2
  34. package/cjs/utilities/str/toInputName.js +30 -2
  35. package/cjs/utilities/str/toSnakeCase.js +18 -2
  36. package/cjs/utilities/str/toStudlyCase.js +22 -2
  37. package/cjs/utilities/str/trim.js +21 -2
  38. package/cjs/utilities/str/ucfirst.js +12 -2
  39. package/esm/__helpers/tslib/tslib.es6.js +25 -15
  40. package/esm/arr.js +643 -2
  41. package/esm/index.d.ts +1 -0
  42. package/esm/index.js +33 -2
  43. package/esm/obj.d.ts +4 -0
  44. package/esm/obj.js +106 -2
  45. package/esm/utilities/escapeRegex.js +8 -2
  46. package/esm/utilities/number/round.js +14 -2
  47. package/esm/utilities/object/objClone.d.ts +3 -0
  48. package/esm/utilities/object/objClone.js +10 -2
  49. package/esm/utilities/object/objFlatten.d.ts +5 -0
  50. package/esm/utilities/object/objFlatten.js +27 -0
  51. package/esm/utilities/object/objGet.js +20 -2
  52. package/esm/utilities/object/objMap.js +14 -2
  53. package/esm/utilities/object/objOnly.js +17 -2
  54. package/esm/utilities/object/objSet.js +33 -2
  55. package/esm/utilities/object/objSort.js +19 -2
  56. package/esm/utilities/random.js +61 -2
  57. package/esm/utilities/str/capitalize.js +12 -2
  58. package/esm/utilities/str/extension.js +9 -2
  59. package/esm/utilities/str/ltrim.js +15 -2
  60. package/esm/utilities/str/readMoreChars.js +12 -2
  61. package/esm/utilities/str/readMoreWords.js +12 -2
  62. package/esm/utilities/str/removeFirst.js +13 -2
  63. package/esm/utilities/str/removeLast.js +13 -2
  64. package/esm/utilities/str/repeatsOf.js +17 -2
  65. package/esm/utilities/str/replaceAll.js +14 -2
  66. package/esm/utilities/str/replaceFirst.js +14 -2
  67. package/esm/utilities/str/replaceLast.js +16 -2
  68. package/esm/utilities/str/rtrim.js +15 -2
  69. package/esm/utilities/str/sprintf.js +2 -2
  70. package/esm/utilities/str/startsWithArabic.js +12 -2
  71. package/esm/utilities/str/toCamelCase.js +11 -2
  72. package/esm/utilities/str/toInputName.js +28 -2
  73. package/esm/utilities/str/toSnakeCase.js +16 -2
  74. package/esm/utilities/str/toStudlyCase.js +20 -2
  75. package/esm/utilities/str/trim.js +19 -2
  76. package/esm/utilities/str/ucfirst.js +10 -2
  77. package/package.json +1 -1
  78. package/cjs/__helpers/tslib/tslib.es6.js.map +0 -1
  79. package/cjs/arr.js.map +0 -1
  80. package/cjs/index.js.map +0 -1
  81. package/cjs/obj.js.map +0 -1
  82. package/cjs/utilities/escapeRegex.js.map +0 -1
  83. package/cjs/utilities/number/round.js.map +0 -1
  84. package/cjs/utilities/object/objClone.js.map +0 -1
  85. package/cjs/utilities/object/objGet.js.map +0 -1
  86. package/cjs/utilities/object/objMap.js.map +0 -1
  87. package/cjs/utilities/object/objOnly.js.map +0 -1
  88. package/cjs/utilities/object/objSet.js.map +0 -1
  89. package/cjs/utilities/object/objSort.js.map +0 -1
  90. package/cjs/utilities/random.js.map +0 -1
  91. package/cjs/utilities/str/capitalize.js.map +0 -1
  92. package/cjs/utilities/str/extension.js.map +0 -1
  93. package/cjs/utilities/str/ltrim.js.map +0 -1
  94. package/cjs/utilities/str/readMoreChars.js.map +0 -1
  95. package/cjs/utilities/str/readMoreWords.js.map +0 -1
  96. package/cjs/utilities/str/removeFirst.js.map +0 -1
  97. package/cjs/utilities/str/removeLast.js.map +0 -1
  98. package/cjs/utilities/str/repeatsOf.js.map +0 -1
  99. package/cjs/utilities/str/replaceAll.js.map +0 -1
  100. package/cjs/utilities/str/replaceFirst.js.map +0 -1
  101. package/cjs/utilities/str/replaceLast.js.map +0 -1
  102. package/cjs/utilities/str/rtrim.js.map +0 -1
  103. package/cjs/utilities/str/sprintf.js.map +0 -1
  104. package/cjs/utilities/str/startsWithArabic.js.map +0 -1
  105. package/cjs/utilities/str/toCamelCase.js.map +0 -1
  106. package/cjs/utilities/str/toInputName.js.map +0 -1
  107. package/cjs/utilities/str/toSnakeCase.js.map +0 -1
  108. package/cjs/utilities/str/toStudlyCase.js.map +0 -1
  109. package/cjs/utilities/str/trim.js.map +0 -1
  110. package/cjs/utilities/str/ucfirst.js.map +0 -1
  111. package/esm/__helpers/tslib/tslib.es6.js.map +0 -1
  112. package/esm/arr.js.map +0 -1
  113. package/esm/index.js.map +0 -1
  114. package/esm/obj.js.map +0 -1
  115. package/esm/utilities/escapeRegex.js.map +0 -1
  116. package/esm/utilities/number/round.js.map +0 -1
  117. package/esm/utilities/object/objClone.js.map +0 -1
  118. package/esm/utilities/object/objGet.js.map +0 -1
  119. package/esm/utilities/object/objMap.js.map +0 -1
  120. package/esm/utilities/object/objOnly.js.map +0 -1
  121. package/esm/utilities/object/objSet.js.map +0 -1
  122. package/esm/utilities/object/objSort.js.map +0 -1
  123. package/esm/utilities/random.js.map +0 -1
  124. package/esm/utilities/str/capitalize.js.map +0 -1
  125. package/esm/utilities/str/extension.js.map +0 -1
  126. package/esm/utilities/str/ltrim.js.map +0 -1
  127. package/esm/utilities/str/readMoreChars.js.map +0 -1
  128. package/esm/utilities/str/readMoreWords.js.map +0 -1
  129. package/esm/utilities/str/removeFirst.js.map +0 -1
  130. package/esm/utilities/str/removeLast.js.map +0 -1
  131. package/esm/utilities/str/repeatsOf.js.map +0 -1
  132. package/esm/utilities/str/replaceAll.js.map +0 -1
  133. package/esm/utilities/str/replaceFirst.js.map +0 -1
  134. package/esm/utilities/str/replaceLast.js.map +0 -1
  135. package/esm/utilities/str/rtrim.js.map +0 -1
  136. package/esm/utilities/str/sprintf.js.map +0 -1
  137. package/esm/utilities/str/startsWithArabic.js.map +0 -1
  138. package/esm/utilities/str/toCamelCase.js.map +0 -1
  139. package/esm/utilities/str/toInputName.js.map +0 -1
  140. package/esm/utilities/str/toSnakeCase.js.map +0 -1
  141. package/esm/utilities/str/toStudlyCase.js.map +0 -1
  142. package/esm/utilities/str/trim.js.map +0 -1
  143. package/esm/utilities/str/ucfirst.js.map +0 -1
@@ -1,17 +1,30 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.__spreadArray=
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
1
+ 'use strict';
4
2
 
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
3
+ Object.defineProperty(exports, '__esModule', { value: true });
7
4
 
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */
16
- function(e,r,t){if(t||2===arguments.length)for(var o,l=0,a=r.length;l<a;l++)!o&&l in r||(o||(o=Array.prototype.slice.call(r,0,l)),o[l]=r[l]);return e.concat(o||Array.prototype.slice.call(r))};
17
- //# sourceMappingURL=tslib.es6.js.map
5
+ /*! *****************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */
19
+
20
+ function __spreadArray(to, from, pack) {
21
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
22
+ if (ar || !(i in from)) {
23
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
24
+ ar[i] = from[i];
25
+ }
26
+ }
27
+ return to.concat(ar || Array.prototype.slice.call(from));
28
+ }
29
+
30
+ exports.__spreadArray = __spreadArray;
package/cjs/arr.js CHANGED
@@ -1,2 +1,645 @@
1
- "use strict";var t=require('./__helpers/tslib/tslib.es6.js'),e=require("./obj.js");function r(t,e){return Object.is(t,e)}var n=function(){function n(t){void 0===t&&(t=[]),this.counter=0,this.items=[],this.items=t}return n.prototype.min=function(t){if(!t)return Math.min.apply(Math,this.items);for(var r=Number.MIN_VALUE,n=0,o=this.items;n<o.length;n++){var i=o[n];if(null===i||"object"!=typeof i){var s=Number(e.get(i,t));isNaN(s)||(s=Number(s))<r&&(r=s)}}return r},n.prototype.max=function(t){if(!t)return Math.max.apply(Math,this.items);for(var r=Number.MAX_VALUE,n=0,o=this.items;n<o.length;n++){var i=o[n];if(null===i||"object"!=typeof i){var s=Number(e.get(i,t));isNaN(s)||s>r&&(r=s)}}return r},n.prototype.avg=function(t){return this.items.reduce((function(r,n){return r+(t?e.get(n,t):n)}),Number.MIN_VALUE)/this.items.length},n.prototype.average=function(t){return this.avg(t)},n.prototype.merge=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return new n((t=this.items).concat.apply(t,e))},n.prototype.mergeUnique=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.merge.apply(this,t).unique()},n.prototype.concat=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.merge.apply(this,t)},n.prototype.set=function(t,e){return this.items[t]=e,this},n.prototype.get=function(t){return this.items[t]},n.prototype.unique=function(t){for(var r=new n,o=0,i=this.items;o<i.length;o++){var s=i[o];r.pushOnce(t?e.get(s,t):s)}return r},n.prototype.toggle=function(t,e,n){void 0===n&&(n=r);var o=this.items;if(!0===e){if(o.includes(t))return this;o.push(t)}else{var i=o.findIndex((function(e){return n(e,t)}));o.splice(i,1)}return this},n.prototype.shift=function(){return this.items.shift()},n.prototype.unshift=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return(t=this.items).unshift.apply(t,e),this},n.prototype.push=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return(t=this.items).push.apply(t,e),this},n.prototype.pushOnce=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,n=t;r<n.length;r++){var o=n[r];this.items.includes(o)||this.items.push(o)}return this},n.prototype.pop=function(){return this.items.pop()},n.prototype.end=function(){return this.items[this.length-1]},n.prototype.remove=function(t){var e=!1;return this.items=this.items.filter((function(r){return!!e||(r!=t||(e=!0,!1))})),this},n.prototype.removeAll=function(t){return this.items=this.items.filter((function(e){return e!=t})),this},n.prototype.first=function(t){if(void 0===t)return this.items[0];for(var e=t,r=0;r<this.length;r++){var n=this.items[r];if(!0===e(n,r))return n}return null},n.prototype.includes=function(t){return this.items.includes(t)},n.prototype.toArray=function(){return this.items},n.prototype.map=function(t){return new n(this.items.map(t))},n.prototype.forEach=function(t){this.items.forEach(t)},n.prototype.filter=function(t){return new n(this.items.filter(t))},n.prototype.sort=function(t){return new n(this.items.sort(t))},n.prototype.sortBy=function(t){var r=this.items.concat([]),o="function"==typeof t,i=function(r){return o?t(r):e.get(r,t)};return r.sort((function(t,e){var r=i(t),n=i(e);return null==r?1:null==n||r<n?-1:r>n?1:0})),new n(r)},n.prototype.sortByDesc=function(t){return this.sortBy(t).reverse()},n.prototype.reduce=function(t,e){return this.items.forEach((function(r){e=t(e,r)})),e},n.prototype.chunk=function(t){var e=[],r=0;do{var o=new n(this.items.slice(r,r+t));e.push(o),r+=t}while(r<this.items.length);return new n(e)},n.prototype.clone=function(){return new n(Array.from(this.items))},n.prototype.reverse=function(){return new n(this.items.reverse())},n.prototype.indexOf=function(t){return this.items.indexOf(t)},n.prototype.lastIndexOf=function(t){return this.items.lastIndexOf(t)},n.prototype.isEmpty=function(){return 0===this.length},n.prototype.isNotEmpty=function(){return!1===this.isEmpty()},n.prototype.random=function(){return this.shuffle().first()},n.prototype.replace=function(t,e){for(var r=0;r<this.length;r++){if(this.get(r)==t){this.set(r,e);break}}return this},n.prototype.replaceAll=function(t,e){for(var r=0;r<this.length;r++){this.get(r)==t&&this.set(r,e)}return this},n.prototype.shuffle=function(){var t,e,r,n=this.clone();for(r=n.length;r;r-=1)t=Math.floor(Math.random()*r),e=n.get(r-1),n.set(r-1,n.get(t)),n.set(t,e);return n},n.prototype.slice=function(t,e){return new n(this.items.slice(t,e))},n.prototype.splice=function(e,r){for(var n,o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];var s=(n=this.items).splice.apply(n,t.__spreadArray([e,r],o,!1));return s},n.prototype.some=function(t){return this.items.some(t)},n.prototype.every=function(t){return this.items.every(t)},n.prototype.unset=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,n=t;r<n.length;r++){var o=n[r];this.items.splice(o,1)}},n.prototype.off=function(t){throw new Error("Method not implemented.")},n.prototype.pluck=function(t){for(var r=new n,o=0,i=this.items;o<i.length;o++){var s=i[o];r.pushOnce(e.get(s,t))}return r},n.prototype.where=function(t,r,o){void 0===r&&(r=null),void 0===o&&(o=null);var i,s,u=r,p=o,h=(i=this.items,(s=[]).push.apply(s,i),s);return void 0===r||!0===r?new n(h.filter((function(r){return e.get(r,t)}))):!1===r?new n(h.filter((function(r){return!e.get(r,t)}))):(null===o&&(p=r,u="==="),new n(h.filter((function(r){switch(u){case"==":return e.get(r,t)===Number(p)||e.get(r,t)===p.toString();default:case"===":return e.get(r,t)===p;case"!=":case"<>":return e.get(r,t)!==Number(p)&&e.get(r,t)!==p.toString();case"!==":return e.get(r,t)!==p;case"<":return e.get(r,t)<p;case"<=":return e.get(r,t)<=p;case">":return e.get(r,t)>p;case">=":return e.get(r,t)>=p}}))))},n.prototype.firstWhere=function(t,e,r){return this.where(t,e,r).first()||null},Object.defineProperty(n.prototype,"length",{get:function(){return this.items.length},enumerable:!1,configurable:!0}),n.prototype.last=function(t,e){var r=this.clone(),n="function"==typeof t;return n&&(r=r.filter(t)),r.isEmpty()&&n?e():r.end()},n.prototype.on=function(t,e){throw new Error("Method not implemented.")},n.prototype.once=function(t,e){throw new Error("Method not implemented.")},n.prototype.subscribe=function(t,e){throw new Error("Method not implemented.")},n.prototype.trigger=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];throw new Error("Method not implemented.")},n.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];throw new Error("Method not implemented.")},n.prototype[Symbol.iterator]=function(){var t=this;return this.counter=0,{next:function(){return{done:t.length==t.counter,value:t.items[t.counter++]}}}},n}();module.exports=n;
2
- //# sourceMappingURL=arr.js.map
1
+ 'use strict';
2
+
3
+ var tslib_es6 = require('./__helpers/tslib/tslib.es6.js');
4
+ var obj = require('./obj.js');
5
+
6
+ function values(array) {
7
+ var newArray = [];
8
+ newArray.push.apply(newArray, array);
9
+ return newArray;
10
+ }
11
+ function defaultIndexFilter(arrayValue, comingValue) {
12
+ return Object.is(arrayValue, comingValue);
13
+ }
14
+ var Arr = /** @class */ (function () {
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @param {array} items
19
+ */
20
+ function Arr(items) {
21
+ if (items === void 0) { items = []; }
22
+ /**
23
+ * Counter of array;
24
+ *
25
+ * @type {number}
26
+ */
27
+ this.counter = 0;
28
+ /**
29
+ * {@inheritdoc}
30
+ */
31
+ this.items = [];
32
+ this.items = items;
33
+ }
34
+ /**
35
+ * {@inheritdoc}
36
+ */
37
+ Arr.prototype.min = function (key) {
38
+ if (!key)
39
+ return Math.min.apply(Math, this.items);
40
+ var minValue = Number.MIN_VALUE;
41
+ for (var _i = 0, _a = this.items; _i < _a.length; _i++) {
42
+ var item = _a[_i];
43
+ if (item !== null && typeof item === "object")
44
+ continue;
45
+ var itemValue = Number(obj.get(item, key));
46
+ if (isNaN(itemValue))
47
+ continue;
48
+ itemValue = Number(itemValue);
49
+ if (itemValue < minValue) {
50
+ minValue = itemValue;
51
+ }
52
+ }
53
+ return minValue;
54
+ };
55
+ /**
56
+ * {@inheritdoc}
57
+ */
58
+ Arr.prototype.max = function (key) {
59
+ if (!key)
60
+ return Math.max.apply(Math, this.items);
61
+ var maxValue = Number.MAX_VALUE;
62
+ for (var _i = 0, _a = this.items; _i < _a.length; _i++) {
63
+ var item = _a[_i];
64
+ if (item !== null && typeof item === "object")
65
+ continue;
66
+ var itemValue = Number(obj.get(item, key));
67
+ if (isNaN(itemValue))
68
+ continue;
69
+ if (itemValue > maxValue) {
70
+ maxValue = itemValue;
71
+ }
72
+ }
73
+ return maxValue;
74
+ };
75
+ /**
76
+ * {@inheritdoc}
77
+ */
78
+ Arr.prototype.avg = function (key) {
79
+ return (this.items.reduce(function (total, item) {
80
+ return total + (!key ? item : obj.get(item, key));
81
+ }, Number.MIN_VALUE) / this.items.length);
82
+ };
83
+ /**
84
+ * {@inheritdoc}
85
+ */
86
+ Arr.prototype.average = function (key) {
87
+ return this.avg(key);
88
+ };
89
+ /**
90
+ * {@inheritdoc}
91
+ */
92
+ Arr.prototype.merge = function () {
93
+ var _a;
94
+ var arrays = [];
95
+ for (var _i = 0; _i < arguments.length; _i++) {
96
+ arrays[_i] = arguments[_i];
97
+ }
98
+ return new Arr((_a = this.items).concat.apply(_a, arrays));
99
+ };
100
+ /**
101
+ * Merge all unique values from all of the given array with current
102
+ * array and return new one
103
+ *
104
+ * @param {...array} arrays
105
+ * @returns {Arrayable<T>}
106
+ */
107
+ Arr.prototype.mergeUnique = function () {
108
+ var arrays = [];
109
+ for (var _i = 0; _i < arguments.length; _i++) {
110
+ arrays[_i] = arguments[_i];
111
+ }
112
+ return this.merge.apply(this, arrays).unique();
113
+ };
114
+ /**
115
+ * {@inheritdoc}
116
+ */
117
+ Arr.prototype.concat = function () {
118
+ var arrays = [];
119
+ for (var _i = 0; _i < arguments.length; _i++) {
120
+ arrays[_i] = arguments[_i];
121
+ }
122
+ return this.merge.apply(this, arrays);
123
+ };
124
+ /**
125
+ * Get the value of the given index
126
+ *
127
+ * @param {number} index
128
+ * @returns {Arrayable}
129
+ */
130
+ Arr.prototype.set = function (index, value) {
131
+ this.items[index] = value;
132
+ return this;
133
+ };
134
+ /**
135
+ * Get the value of the given index
136
+ *
137
+ * @param {number} index
138
+ * @returns {*}
139
+ * @memberof Arr
140
+ */
141
+ Arr.prototype.get = function (index) {
142
+ return this.items[index];
143
+ };
144
+ /**
145
+ * {@inheritdoc}
146
+ */
147
+ Arr.prototype.unique = function (key) {
148
+ var newItems = new Arr();
149
+ for (var _i = 0, _a = this.items; _i < _a.length; _i++) {
150
+ var item = _a[_i];
151
+ newItems.pushOnce(key ? obj.get(item, key) : item);
152
+ }
153
+ return newItems;
154
+ };
155
+ /**
156
+ * Toggle the given value using the given callback
157
+ *
158
+ *
159
+ * @param {any} value
160
+ * @param {boolean} toggleIn
161
+ * @param {Function} indexFilter
162
+ * @returns {Array}
163
+ */
164
+ Arr.prototype.toggle = function (value, toggleIn, indexFilter) {
165
+ if (indexFilter === void 0) { indexFilter = defaultIndexFilter; }
166
+ var array = this.items;
167
+ if (toggleIn === true) {
168
+ if (array.includes(value))
169
+ return this;
170
+ array.push(value);
171
+ }
172
+ else {
173
+ var valueIndex = array.findIndex(function (arrayValue) {
174
+ return indexFilter(arrayValue, value);
175
+ });
176
+ array.splice(valueIndex, 1);
177
+ }
178
+ return this;
179
+ };
180
+ /**
181
+ * {@inheritdoc}
182
+ */
183
+ Arr.prototype.shift = function () {
184
+ return this.items.shift();
185
+ };
186
+ /**
187
+ * {@inheritdoc}
188
+ */
189
+ Arr.prototype.unshift = function () {
190
+ var _a;
191
+ var items = [];
192
+ for (var _i = 0; _i < arguments.length; _i++) {
193
+ items[_i] = arguments[_i];
194
+ }
195
+ (_a = this.items).unshift.apply(_a, items);
196
+ return this;
197
+ };
198
+ /**
199
+ * {@inheritdoc}
200
+ */
201
+ Arr.prototype.push = function () {
202
+ var _a;
203
+ var items = [];
204
+ for (var _i = 0; _i < arguments.length; _i++) {
205
+ items[_i] = arguments[_i];
206
+ }
207
+ (_a = this.items).push.apply(_a, items);
208
+ return this;
209
+ };
210
+ /**
211
+ * {@inheritdoc}
212
+ */
213
+ Arr.prototype.pushOnce = function () {
214
+ var items = [];
215
+ for (var _i = 0; _i < arguments.length; _i++) {
216
+ items[_i] = arguments[_i];
217
+ }
218
+ for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
219
+ var item = items_1[_a];
220
+ if (!this.items.includes(item)) {
221
+ this.items.push(item);
222
+ }
223
+ }
224
+ return this;
225
+ };
226
+ /**
227
+ * {@inheritdoc}
228
+ */
229
+ Arr.prototype.pop = function () {
230
+ return this.items.pop();
231
+ };
232
+ /**
233
+ * {@inheritdoc}
234
+ */
235
+ Arr.prototype.end = function () {
236
+ return this.items[this.length - 1];
237
+ };
238
+ /**
239
+ * {@inheritdoc}
240
+ */
241
+ Arr.prototype.remove = function (value) {
242
+ var found = false;
243
+ this.items = this.items.filter(function (item) {
244
+ if (found)
245
+ return true;
246
+ if (item == value) {
247
+ found = true;
248
+ return false;
249
+ }
250
+ return true;
251
+ });
252
+ return this;
253
+ };
254
+ /**
255
+ * {@inheritdoc}
256
+ */
257
+ Arr.prototype.removeAll = function (value) {
258
+ this.items = this.items.filter(function (item) { return item != value; });
259
+ return this;
260
+ };
261
+ /**
262
+ * {@inheritdoc}
263
+ */
264
+ Arr.prototype.first = function (key) {
265
+ if (key === undefined)
266
+ return this.items[0];
267
+ var callback = key;
268
+ for (var i = 0; i < this.length; i++) {
269
+ var item = this.items[i];
270
+ if (callback(item, i) === true)
271
+ return item;
272
+ }
273
+ return null;
274
+ };
275
+ /**
276
+ * {@inheritdoc}
277
+ */
278
+ Arr.prototype.includes = function (value) {
279
+ return this.items.includes(value);
280
+ };
281
+ /**
282
+ * {@inheritdoc}
283
+ */
284
+ Arr.prototype.toArray = function () {
285
+ return this.items;
286
+ };
287
+ /**
288
+ * {@inheritdoc}
289
+ */
290
+ Arr.prototype.map = function (callback) {
291
+ return new Arr(this.items.map(callback));
292
+ };
293
+ /**
294
+ * {@inheritdoc}
295
+ */
296
+ Arr.prototype.forEach = function (callback) {
297
+ this.items.forEach(callback);
298
+ };
299
+ /**
300
+ * {@inheritdoc}
301
+ */
302
+ Arr.prototype.filter = function (callback) {
303
+ return new Arr(this.items.filter(callback));
304
+ };
305
+ /**
306
+ * {@inheritdoc}
307
+ */
308
+ Arr.prototype.sort = function (callback) {
309
+ return new Arr(this.items.sort(callback));
310
+ };
311
+ /**
312
+ * {@inheritdoc}
313
+ */
314
+ Arr.prototype.sortBy = function (valueOrFunction) {
315
+ var collection = this.items.concat([]);
316
+ var isFunction = typeof valueOrFunction === "function";
317
+ var getValue = function (item) {
318
+ if (isFunction) {
319
+ return valueOrFunction(item);
320
+ }
321
+ return obj.get(item, valueOrFunction);
322
+ };
323
+ collection.sort(function (a, b) {
324
+ var valueA = getValue(a);
325
+ var valueB = getValue(b);
326
+ if (valueA === null || valueA === undefined) {
327
+ return 1;
328
+ }
329
+ if (valueB === null || valueB === undefined) {
330
+ return -1;
331
+ }
332
+ if (valueA < valueB) {
333
+ return -1;
334
+ }
335
+ if (valueA > valueB) {
336
+ return 1;
337
+ }
338
+ return 0;
339
+ });
340
+ return new Arr(collection);
341
+ };
342
+ /**
343
+ * {@inheritdoc}
344
+ */
345
+ Arr.prototype.sortByDesc = function (key) {
346
+ return this.sortBy(key).reverse();
347
+ };
348
+ /**
349
+ * {@inheritdoc}
350
+ */
351
+ Arr.prototype.reduce = function (callback, initialValue) {
352
+ this.items.forEach(function (item) {
353
+ initialValue = callback(initialValue, item);
354
+ });
355
+ return initialValue;
356
+ };
357
+ /**
358
+ * {@inheritdoc}
359
+ */
360
+ Arr.prototype.chunk = function (size) {
361
+ var chunks = [];
362
+ var index = 0;
363
+ do {
364
+ var items = this.items.slice(index, index + size);
365
+ var collection = new Arr(items);
366
+ chunks.push(collection);
367
+ index += size;
368
+ } while (index < this.items.length);
369
+ return new Arr(chunks);
370
+ };
371
+ /**
372
+ * {@inheritdoc}
373
+ */
374
+ Arr.prototype.clone = function () {
375
+ return new Arr(Array.from(this.items));
376
+ };
377
+ /**
378
+ * {@inheritdoc}
379
+ */
380
+ Arr.prototype.reverse = function () {
381
+ return new Arr(this.items.reverse());
382
+ };
383
+ /**
384
+ * {@inheritdoc}
385
+ */
386
+ Arr.prototype.indexOf = function (value) {
387
+ return this.items.indexOf(value);
388
+ };
389
+ /**
390
+ * {@inheritdoc}
391
+ */
392
+ Arr.prototype.lastIndexOf = function (value) {
393
+ return this.items.lastIndexOf(value);
394
+ };
395
+ /**
396
+ * {@inheritdoc}
397
+ */
398
+ Arr.prototype.isEmpty = function () {
399
+ return 0 === this.length;
400
+ };
401
+ /**
402
+ * {@inheritdoc}
403
+ */
404
+ Arr.prototype.isNotEmpty = function () {
405
+ return false === this.isEmpty();
406
+ };
407
+ /**
408
+ * {@inheritdoc}
409
+ */
410
+ Arr.prototype.random = function () {
411
+ return this.shuffle().first();
412
+ };
413
+ /**
414
+ * {@inheritdoc}
415
+ */
416
+ Arr.prototype.replace = function (oldValue, newValue) {
417
+ for (var i = 0; i < this.length; i++) {
418
+ var item = this.get(i);
419
+ if (item == oldValue) {
420
+ this.set(i, newValue);
421
+ break;
422
+ }
423
+ }
424
+ return this;
425
+ };
426
+ /**
427
+ * {@inheritdoc}
428
+ */
429
+ Arr.prototype.replaceAll = function (oldValue, newValue) {
430
+ for (var i = 0; i < this.length; i++) {
431
+ var item = this.get(i);
432
+ if (item == oldValue) {
433
+ this.set(i, newValue);
434
+ }
435
+ }
436
+ return this;
437
+ };
438
+ /**
439
+ * {@inheritdoc}
440
+ */
441
+ Arr.prototype.shuffle = function () {
442
+ var items = this.clone();
443
+ var j;
444
+ var x;
445
+ var i;
446
+ for (i = items.length; i; i -= 1) {
447
+ j = Math.floor(Math.random() * i);
448
+ x = items.get(i - 1);
449
+ items.set(i - 1, items.get(j));
450
+ items.set(j, x);
451
+ }
452
+ return items;
453
+ };
454
+ /**
455
+ * {@inheritdoc}
456
+ */
457
+ Arr.prototype.slice = function (begin, end) {
458
+ return new Arr(this.items.slice(begin, end));
459
+ };
460
+ /**
461
+ * {@inheritdoc}
462
+ */
463
+ Arr.prototype.splice = function (start, deleteCount) {
464
+ var _a;
465
+ var items = [];
466
+ for (var _i = 2; _i < arguments.length; _i++) {
467
+ items[_i - 2] = arguments[_i];
468
+ }
469
+ var removedItems = (_a = this.items).splice.apply(_a, tslib_es6.__spreadArray([start, deleteCount], items, false));
470
+ return removedItems;
471
+ };
472
+ /**
473
+ * {@inheritdoc}
474
+ */
475
+ Arr.prototype.some = function (callback) {
476
+ return this.items.some(callback);
477
+ };
478
+ /**
479
+ * {@inheritdoc}
480
+ */
481
+ Arr.prototype.every = function (callback) {
482
+ return this.items.every(callback);
483
+ };
484
+ /**
485
+ * {@inheritdoc}
486
+ */
487
+ Arr.prototype.unset = function () {
488
+ var keys = [];
489
+ for (var _i = 0; _i < arguments.length; _i++) {
490
+ keys[_i] = arguments[_i];
491
+ }
492
+ for (var _a = 0, keys_1 = keys; _a < keys_1.length; _a++) {
493
+ var key = keys_1[_a];
494
+ this.items.splice(key, 1);
495
+ }
496
+ };
497
+ /**
498
+ * {@inheritdoc}
499
+ */
500
+ Arr.prototype.off = function (event) {
501
+ throw new Error("Method not implemented.");
502
+ };
503
+ /**
504
+ * {@inheritdoc}
505
+ */
506
+ Arr.prototype.pluck = function (key) {
507
+ var data = new Arr();
508
+ for (var _i = 0, _a = this.items; _i < _a.length; _i++) {
509
+ var item = _a[_i];
510
+ data.pushOnce(obj.get(item, key));
511
+ }
512
+ return data;
513
+ };
514
+ /**
515
+ * {@inheritdoc}
516
+ */
517
+ Arr.prototype.where = function (key, operator, value) {
518
+ if (operator === void 0) { operator = null; }
519
+ if (value === void 0) { value = null; }
520
+ var comparisonOperator = operator;
521
+ var comparisonValue = value;
522
+ var items = values(this.items);
523
+ if (operator === undefined || operator === true) {
524
+ return new Arr(items.filter(function (item) { return obj.get(item, key); }));
525
+ }
526
+ if (operator === false) {
527
+ return new Arr(items.filter(function (item) { return !obj.get(item, key); }));
528
+ }
529
+ if (value === null) {
530
+ comparisonValue = operator;
531
+ comparisonOperator = "===";
532
+ }
533
+ var collection = items.filter(function (item) {
534
+ switch (comparisonOperator) {
535
+ case "==":
536
+ return (obj.get(item, key) === Number(comparisonValue) ||
537
+ obj.get(item, key) === comparisonValue.toString());
538
+ default:
539
+ case "===":
540
+ return obj.get(item, key) === comparisonValue;
541
+ case "!=":
542
+ case "<>":
543
+ return (obj.get(item, key) !== Number(comparisonValue) &&
544
+ obj.get(item, key) !== comparisonValue.toString());
545
+ case "!==":
546
+ return obj.get(item, key) !== comparisonValue;
547
+ case "<":
548
+ return obj.get(item, key) < comparisonValue;
549
+ case "<=":
550
+ return obj.get(item, key) <= comparisonValue;
551
+ case ">":
552
+ return obj.get(item, key) > comparisonValue;
553
+ case ">=":
554
+ return obj.get(item, key) >= comparisonValue;
555
+ }
556
+ });
557
+ return new Arr(collection);
558
+ };
559
+ /**
560
+ * {@inheritdoc}
561
+ */
562
+ Arr.prototype.firstWhere = function (key, operator, value) {
563
+ return this.where(key, operator, value).first() || null;
564
+ };
565
+ Object.defineProperty(Arr.prototype, "length", {
566
+ /**
567
+ * {@inheritdoc}
568
+ */
569
+ get: function () {
570
+ return this.items.length;
571
+ },
572
+ enumerable: false,
573
+ configurable: true
574
+ });
575
+ /**
576
+ * Get last value based on given function callback
577
+ */
578
+ Arr.prototype.last = function (fn, defaultValue) {
579
+ var items = this.clone();
580
+ var isFunction = typeof fn === "function";
581
+ if (isFunction) {
582
+ items = items.filter(fn);
583
+ }
584
+ if (items.isEmpty() && isFunction) {
585
+ return defaultValue();
586
+ }
587
+ return items.end();
588
+ };
589
+ /**
590
+ * {@inheritdoc}
591
+ */
592
+ Arr.prototype.on = function (event, callback) {
593
+ throw new Error("Method not implemented.");
594
+ };
595
+ /**
596
+ * {@inheritdoc}
597
+ */
598
+ Arr.prototype.once = function (event, callback) {
599
+ throw new Error("Method not implemented.");
600
+ };
601
+ /**
602
+ * {@inheritdoc}
603
+ */
604
+ Arr.prototype.subscribe = function (event, callback) {
605
+ throw new Error("Method not implemented.");
606
+ };
607
+ /**
608
+ * {@inheritdoc}
609
+ */
610
+ Arr.prototype.trigger = function (event) {
611
+ var values = [];
612
+ for (var _i = 1; _i < arguments.length; _i++) {
613
+ values[_i - 1] = arguments[_i];
614
+ }
615
+ throw new Error("Method not implemented.");
616
+ };
617
+ /**
618
+ * {@inheritdoc}
619
+ */
620
+ Arr.prototype.emit = function (event) {
621
+ var values = [];
622
+ for (var _i = 1; _i < arguments.length; _i++) {
623
+ values[_i - 1] = arguments[_i];
624
+ }
625
+ throw new Error("Method not implemented.");
626
+ };
627
+ /**
628
+ * {@inheritdoc}
629
+ */
630
+ Arr.prototype[Symbol.iterator] = function () {
631
+ var _this = this;
632
+ this.counter = 0;
633
+ return {
634
+ next: function () {
635
+ return {
636
+ done: _this.length == _this.counter,
637
+ value: _this.items[_this.counter++],
638
+ };
639
+ },
640
+ };
641
+ };
642
+ return Arr;
643
+ }());
644
+
645
+ module.exports = Arr;