@valkyriestudios/utils 5.2.0 → 5.3.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 (129) hide show
  1. package/.nyc_output/1a7d1a21-08be-4f94-911a-00cfdce52f8c.json +1 -0
  2. package/.nyc_output/4de4b713-79af-403d-b012-c25e5d50454d.json +1 -0
  3. package/.nyc_output/processinfo/1a7d1a21-08be-4f94-911a-00cfdce52f8c.json +1 -0
  4. package/.nyc_output/processinfo/4de4b713-79af-403d-b012-c25e5d50454d.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -1
  6. package/CHANGELOG.md +23 -0
  7. package/README.md +71 -55
  8. package/array/dedupe.js +3 -4
  9. package/array/is.js +0 -1
  10. package/array/isNotEmpty.js +0 -3
  11. package/array/join.js +1 -15
  12. package/array/mapFn.js +2 -15
  13. package/array/mapKey.js +1 -13
  14. package/array/mapPrimitive.js +1 -14
  15. package/array/shuffle.js +17 -0
  16. package/boolean/is.js +0 -1
  17. package/caching/memoize.js +14 -10
  18. package/codecov +0 -0
  19. package/codecov.sh +1 -1
  20. package/coverage/lcov-report/index.html +58 -58
  21. package/coverage/lcov-report/src/array/dedupe.js.html +7 -7
  22. package/coverage/lcov-report/src/array/index.html +50 -35
  23. package/coverage/lcov-report/src/array/is.js.html +5 -5
  24. package/coverage/lcov-report/src/array/isNotEmpty.js.html +8 -8
  25. package/coverage/lcov-report/src/array/join.js.html +10 -10
  26. package/coverage/lcov-report/src/array/mapFn.js.html +10 -10
  27. package/coverage/lcov-report/src/array/mapKey.js.html +10 -10
  28. package/coverage/lcov-report/src/array/mapPrimitive.js.html +10 -10
  29. package/coverage/lcov-report/src/array/shuffle.js.html +133 -0
  30. package/coverage/lcov-report/src/boolean/index.html +5 -5
  31. package/coverage/lcov-report/src/boolean/is.js.html +4 -4
  32. package/coverage/lcov-report/src/caching/index.html +9 -9
  33. package/coverage/lcov-report/src/caching/memoize.js.html +40 -22
  34. package/coverage/lcov-report/src/date/index.html +5 -5
  35. package/coverage/lcov-report/src/date/is.js.html +4 -4
  36. package/coverage/lcov-report/src/deep/define.js.html +8 -8
  37. package/coverage/lcov-report/src/deep/freeze.js.html +11 -11
  38. package/coverage/lcov-report/src/deep/get.js.html +9 -9
  39. package/coverage/lcov-report/src/deep/index.html +31 -31
  40. package/coverage/lcov-report/src/deep/seal.js.html +11 -11
  41. package/coverage/lcov-report/src/deep/set.js.html +9 -9
  42. package/coverage/lcov-report/src/equal.js.html +7 -7
  43. package/coverage/lcov-report/src/function/index.html +22 -22
  44. package/coverage/lcov-report/src/function/is.js.html +5 -5
  45. package/coverage/lcov-report/src/function/noop.js.html +9 -9
  46. package/coverage/lcov-report/src/function/noopresolve.js.html +4 -4
  47. package/coverage/lcov-report/src/function/noopreturn.js.html +4 -4
  48. package/coverage/lcov-report/src/function/sleep.js.html +4 -4
  49. package/coverage/lcov-report/src/hash/fnv1A.js.html +24 -24
  50. package/coverage/lcov-report/src/hash/guid.js.html +9 -9
  51. package/coverage/lcov-report/src/hash/index.html +23 -23
  52. package/coverage/lcov-report/src/index.html +13 -13
  53. package/coverage/lcov-report/src/is.js.html +7 -7
  54. package/coverage/lcov-report/src/number/index.html +50 -50
  55. package/coverage/lcov-report/src/number/is.js.html +8 -8
  56. package/coverage/lcov-report/src/number/isAbove.js.html +6 -6
  57. package/coverage/lcov-report/src/number/isBelow.js.html +6 -6
  58. package/coverage/lcov-report/src/number/isBetween.js.html +6 -6
  59. package/coverage/lcov-report/src/number/isInteger.js.html +6 -6
  60. package/coverage/lcov-report/src/number/isIntegerAbove.js.html +7 -7
  61. package/coverage/lcov-report/src/number/isIntegerBelow.js.html +7 -7
  62. package/coverage/lcov-report/src/number/isIntegerBetween.js.html +7 -7
  63. package/coverage/lcov-report/src/number/isNumericalNaN.js.html +5 -5
  64. package/coverage/lcov-report/src/number/randomBetween.js.html +11 -11
  65. package/coverage/lcov-report/src/number/round.js.html +7 -7
  66. package/coverage/lcov-report/src/number/toPercentage.js.html +7 -7
  67. package/coverage/lcov-report/src/object/define.js.html +6 -6
  68. package/coverage/lcov-report/src/object/defineFrozen.js.html +6 -6
  69. package/coverage/lcov-report/src/object/defineSealed.js.html +6 -6
  70. package/coverage/lcov-report/src/object/forValues.js.html +9 -9
  71. package/coverage/lcov-report/src/object/index.html +41 -41
  72. package/coverage/lcov-report/src/object/is.js.html +4 -4
  73. package/coverage/lcov-report/src/object/isNotEmpty.js.html +6 -6
  74. package/coverage/lcov-report/src/object/merge.js.html +10 -10
  75. package/coverage/lcov-report/src/object/pick.js.html +7 -7
  76. package/coverage/lcov-report/src/object/zip.js.html +6 -6
  77. package/coverage/lcov-report/src/regexp/index.html +5 -5
  78. package/coverage/lcov-report/src/regexp/is.js.html +4 -4
  79. package/coverage/lcov-report/src/string/index.html +19 -19
  80. package/coverage/lcov-report/src/string/is.js.html +5 -5
  81. package/coverage/lcov-report/src/string/isBetween.js.html +7 -7
  82. package/coverage/lcov-report/src/string/isNotEmpty.js.html +6 -6
  83. package/coverage/lcov-report/src/string/shorten.js.html +7 -7
  84. package/coverage/lcov.info +1044 -736
  85. package/date/is.js +0 -1
  86. package/deep/define.js +0 -3
  87. package/deep/freeze.js +0 -5
  88. package/deep/get.js +2 -12
  89. package/deep/seal.js +0 -5
  90. package/deep/set.js +2 -12
  91. package/equal.js +0 -13
  92. package/function/is.js +0 -1
  93. package/function/noop.js +2 -2
  94. package/function/noopresolve.js +0 -1
  95. package/function/noopreturn.js +0 -1
  96. package/function/sleep.js +0 -1
  97. package/hash/fnv1A.js +1 -10
  98. package/hash/guid.js +2 -2
  99. package/is.js +0 -21
  100. package/number/is.js +0 -3
  101. package/number/isAbove.js +0 -3
  102. package/number/isBelow.js +0 -3
  103. package/number/isBetween.js +0 -3
  104. package/number/isInteger.js +0 -3
  105. package/number/isIntegerAbove.js +0 -4
  106. package/number/isIntegerBelow.js +0 -4
  107. package/number/isIntegerBetween.js +0 -4
  108. package/number/randomBetween.js +1 -4
  109. package/number/round.js +1 -4
  110. package/number/toPercentage.js +0 -4
  111. package/object/define.js +0 -5
  112. package/object/defineFrozen.js +0 -3
  113. package/object/defineSealed.js +0 -3
  114. package/object/forValues.js +0 -7
  115. package/object/is.js +0 -1
  116. package/object/isNotEmpty.js +0 -3
  117. package/object/merge.js +0 -8
  118. package/object/pick.js +0 -9
  119. package/object/zip.js +0 -6
  120. package/package.json +7 -7
  121. package/regexp/is.js +0 -1
  122. package/string/is.js +0 -1
  123. package/string/isBetween.js +0 -4
  124. package/string/isNotEmpty.js +0 -3
  125. package/string/shorten.js +0 -5
  126. package/.nyc_output/58f73d7a-e507-4792-bfca-ebfb34732639.json +0 -1
  127. package/.nyc_output/86a24097-14b3-4c83-9aaf-69614f599a22.json +0 -1
  128. package/.nyc_output/processinfo/58f73d7a-e507-4792-bfca-ebfb34732639.json +0 -1
  129. package/.nyc_output/processinfo/86a24097-14b3-4c83-9aaf-69614f599a22.json +0 -1
package/README.md CHANGED
@@ -14,14 +14,14 @@ A collection of single-function utilities for common tasks
14
14
  ### array
15
15
  - **isArray(val:any)**
16
16
  Check if a variable is of type Array
17
- ```
17
+ ```js
18
18
  isArray({a:1}); // FALSE
19
19
  isArray([]); // TRUE
20
20
  ```
21
21
 
22
22
  - **isNotEmptyArray(val:any)**
23
23
  Check if a variable a non-empty array
24
- ```
24
+ ```js
25
25
  isNotEmptyArray({a:1}); // FALSE
26
26
  isNotEmptyArray([]); // FALSE
27
27
  isNotEmptyArray([0, 1, 2]); // TRUE
@@ -29,7 +29,7 @@ isNotEmptyArray([0, 1, 2]); // TRUE
29
29
 
30
30
  - **mapKey(val:array[Object], key:string, opts:object={})**
31
31
  Map a non-primitive object array into an object map by key
32
- ```
32
+ ```js
33
33
  mapKey([
34
34
  {uid: 12, name: 'Peter'},
35
35
  {uid: 15, name: 'Jonas'},
@@ -46,7 +46,7 @@ output:
46
46
  ```
47
47
 
48
48
  Autofilters anything not meeting the spec:
49
- ```
49
+ ```js
50
50
  [
51
51
  0,
52
52
  {uid: 12, name: 'Peter'},
@@ -70,7 +70,7 @@ output:
70
70
  ```
71
71
 
72
72
  allows merging objects onto existing keys:
73
- ```
73
+ ```js
74
74
  [
75
75
  0,
76
76
  {uid: 12, name: 'Peter'},
@@ -99,7 +99,7 @@ output:
99
99
  - **mapFn(val:array[Object], key:Function, opts:object={})**
100
100
  Same behavior as mapKey but instead of a key, a function is passed to generate your own key. Eg:
101
101
 
102
- ```
102
+ ```js
103
103
  mapFn([
104
104
  {uid: 12, name: 'Peter'},
105
105
  {uid: 15, name: 'Jonas'},
@@ -119,7 +119,7 @@ options are the same as the mapKey function
119
119
 
120
120
  - **mapPrimitive(val:any, opts:object={keytrim:true,valtrim:false,keyround:false,valround:false})**
121
121
  Map an array of primitives (number/string)
122
- ```
122
+ ```js
123
123
  mapPrimitive([1,2,3]); // {1: 1, 2: 2, 3: 3}
124
124
  mapPrimitive(['hello', 'hello', 'foo', 'bar']); // {hello: 'hello', foo: 'foo', bar: 'bar'}
125
125
  mapPrimitive(['hello', ' hello', 'foo', ' foo'], {keytrim: true, valtrim: true}); // {hello: 'hello', foo: 'foo'}
@@ -127,7 +127,7 @@ mapPrimitive(['hello', ' hello', 'foo', ' foo'], {keytrim: true, valtrim: true}
127
127
 
128
128
  - **dedupe(val:Array)**
129
129
  Remove all duplicates from an array, behind the scenes it uses the fnv 1A hash algorithm to performantly do comparisons.
130
- ```
130
+ ```js
131
131
  dedupe(['a','a','b','c','c']); // ['a', 'b', 'c']
132
132
  dedupe(['1',1,'2',2]); // ['1','2']
133
133
  dedupe([new RegExp(/ab+c/, 'i'), new RegExp(/ab+c/, 'i')]); // [new RegExp(/ab+c/, 'i')]
@@ -138,7 +138,7 @@ dedupe(['hello', 'hello', 'world']); // ['hello', 'world']
138
138
  - **join(val:Array, opts:object={delim:' ',trim:true,valtrim:true,valround:false})**
139
139
  Concatenate the values within an array into a string, behind the scenes this will automatically filter out any value that is not a string or numerical value. For strings it will automatically trim (and remove if empty after trimming) before joining.
140
140
 
141
- ```
141
+ ```js
142
142
  join(['Valkyrie', 'Studios']); // 'Valkyrie Studios'
143
143
  join([5.1, ' years ', 'ago'], {valround: 0}); // '5 years ago'
144
144
  join(['peter ', ' valkyrie '], {delim: '@'}); // 'peter@valkyrie'
@@ -146,28 +146,38 @@ join([user.first_name, user.last_name]); // 'John' (where user is {first_name: '
146
146
  join([' a', 1], {delim: '', valtrim: false, trim: false}); // ' a1'
147
147
  ```
148
148
 
149
+ - **shuffle(val:Array)**
150
+ Shuffle an array (Fisher-Yates) in O(n), take note this changes the passed value
151
+
152
+ ```js
153
+ const arr = [1, 2, 3, 4, 5, 6];
154
+ shuffle(arr);
155
+ // [4, 6, 3, 2, 5, 1]
156
+ ```
157
+
149
158
  ### boolean
150
159
  - **isBoolean(val:any)**
151
160
  Check if a variable is of type Boolean
152
- ```
161
+ ```js
153
162
  isBoolean(null); // FALSE
154
163
  isBoolean(false); // TRUE
155
164
  isBoolean(true); // TRUE
156
165
  ```
157
166
 
158
167
  ### caching
159
- - **memoize(fn:Function)**
160
- memoize the output of a specific function to allow for the creation of an internal cache using the fnv 1A hash algorithm
161
- ```
162
- const memoized_function = memoize((a, b) => {
163
- return a + b;
168
+ - **memoize(fn:Function, resolver:Function=false)**
169
+ memoize the output of a specific function. An optional resolver function can be passed which allows custom cache key generation.
170
+
171
+ ```js
172
+ const memoized_function = memoize((a) => {
173
+ return fnv1A(a);
164
174
  });
165
175
  ```
166
176
 
167
177
  ### date
168
178
  - **isDate(val:any)**
169
179
  Check if a variable is of type Date
170
- ```
180
+ ```js
171
181
  isDate(new Date('December 17, 1995 03:24:00'); // TRUE
172
182
  isDate('December 17, 1995 03:24:00'); // FALSE
173
183
  ```
@@ -175,7 +185,7 @@ isDate('December 17, 1995 03:24:00'); // FALSE
175
185
  ### deep
176
186
  - **deepFreeze(val:Object)**
177
187
  Recursively freezes all properties of an object
178
- ```
188
+ ```js
179
189
  const myObj = deepFreeze({
180
190
  a: 2,
181
191
  b: {
@@ -192,7 +202,7 @@ Object.isFrozen(myObj.b.d); // TRUE
192
202
 
193
203
  - **deepSeal(val:Object)**
194
204
  Recursively freezes all properties of an object
195
- ```
205
+ ```js
196
206
  const myObj = deepSeal({
197
207
  a: 2,
198
208
  b: {
@@ -210,14 +220,15 @@ Object.isFrozen(myObj.b.d); // FALSE
210
220
 
211
221
  - **deepSet(obj:Object, path:string, value:any=null, define:boolean=false)**
212
222
  Sets a property and its value deep in the structure of an object
213
- ```
223
+ ```js
214
224
  const myObj = {
215
225
  a: 2,
216
226
  });
217
227
  deepSet(myObj, 'b.c.d.e', 4);
218
228
  myObj.b.c.d.e; // 4
219
229
  ```
220
- ```
230
+
231
+ ```js
221
232
  const myObj = {
222
233
  a: 2,
223
234
  b: [
@@ -230,7 +241,8 @@ deepSet(myObj, 'b[1].price', 500);
230
241
  myObj.b[0].price; // 100
231
242
  myObj.b[1].price; // 500
232
243
  ```
233
- ```
244
+
245
+ ```js
234
246
  const myObj = {
235
247
  a: 2,
236
248
  });
@@ -240,7 +252,7 @@ myObj.b.c; // Function
240
252
 
241
253
  - **deepGet(obj:Object, path:string, get_parent:boolean=false)**
242
254
  Retrieves a value based on a path in a deeply nested object
243
- ```
255
+ ```js
244
256
  const myObj = {
245
257
  a: 2,
246
258
  b: [
@@ -250,7 +262,8 @@ const myObj = {
250
262
  });
251
263
  deepGet(myObj, 'b[0].price', true); // [{price: 2}, {price: 4}]
252
264
  ```
253
- ```
265
+
266
+ ```js
254
267
  const myObj = {
255
268
  a: 2,
256
269
  b: [
@@ -264,7 +277,7 @@ deepGet(myObj, 'b[0].price'); // 2
264
277
  ### equal
265
278
  - **equal(a:any, b:any)**
266
279
  Check if a variable is equal to another one
267
- ```
280
+ ```js
268
281
  equal(5, 6); // FALSE
269
282
  equal(1, 1); // TRUE
270
283
  equal([0, 1, 2], [1, 2]); // FALSE
@@ -294,13 +307,13 @@ An empty function that returns a promise that will resolve after X milliseconds,
294
307
  ### hash
295
308
  - **guid()**
296
309
  Generate a unique identifier (guid) according to RFC4122
297
- ```
310
+ ```js
298
311
  guid(); // 245caf1a-86af-11e7-bb31-be2e44b06b34
299
312
  ```
300
313
 
301
314
  - **fnv1A(val:any)**
302
315
  Generate a fnv1A hash from an object, using a 32-bit prime/offset
303
- ```
316
+ ```js
304
317
  fnv1A('hello world'); // -2023343616
305
318
  fnv1A({a:1,b:2}); // 361168128
306
319
  fnv1A(4); // 1630425728
@@ -311,7 +324,7 @@ fnv1A(new Date('2012-02-02')); // 1655579136
311
324
  ### number
312
325
  - **isNumber(val:any)**
313
326
  Check if a variable is a number
314
- ```
327
+ ```js
315
328
  isNumber('foo'); // FALSE
316
329
  isNumber(4); // TRUE
317
330
  isNumber(0.5); // TRUE
@@ -319,7 +332,7 @@ isNumber(0.5); // TRUE
319
332
 
320
333
  - **isNumberAbove(val:number, comp:number)**
321
334
  Check if a variable is above a certain bound
322
- ```
335
+ ```js
323
336
  isNumberAbove(5, 0); // TRUE
324
337
  isNumberAbove(.1, 0); // TRUE
325
338
  isNumberAbove(-1, -1); // FALSE
@@ -328,7 +341,7 @@ isNumberAbove(-10, -9); // FALSE
328
341
 
329
342
  - **isNumberBelow(val:number, comp:number)**
330
343
  Check if a variable is below a certain bound
331
- ```
344
+ ```js
332
345
  isNumberBelow(0, 5); // TRUE
333
346
  isNumberBelow(0, .1); // TRUE
334
347
  isNumberBelow(-1, -1); // FALSE
@@ -337,7 +350,7 @@ isNumberBelow(-9, -10); // FALSE
337
350
 
338
351
  - **isNumberBetween(val:number, min:number, max:number)**
339
352
  Check if a variable is between a range of numbers
340
- ```
353
+ ```js
341
354
  isNumberBetween(5, 0, 10); // TRUE
342
355
  isNumberBetween(.1, 0, 1); // TRUE
343
356
  isNumberBetween(-.1, -1, 0); // TRUE
@@ -347,7 +360,7 @@ isNumberBetween(-1, 0, 1); // FALSE
347
360
 
348
361
  - **isInteger(val:any)**
349
362
  Check if a variable is an integer
350
- ```
363
+ ```js
351
364
  isInteger('foo'); // FALSE
352
365
  isInteger(4); // TRUE
353
366
  isInteger(0.5); // FALSE
@@ -355,7 +368,7 @@ isInteger(0.5); // FALSE
355
368
 
356
369
  - **isIntegerAbove(val:number, comp:number)**
357
370
  Check if a variable is an integer above a certain bound
358
- ```
371
+ ```js
359
372
  isIntegerAbove(5, 0); // TRUE
360
373
  isIntegerAbove(.1, 0); // FALSE
361
374
  isIntegerAbove(-1, -1); // FALSE
@@ -364,7 +377,7 @@ isIntegerAbove(-10, -9); // FALSE
364
377
 
365
378
  - **isIntegerBelow(val:number, comp:number)**
366
379
  Check if a variable is an integer below a certain bound
367
- ```
380
+ ```js
368
381
  isIntegerBelow(0, 5); // TRUE
369
382
  isIntegerBelow(0, .1); // TRUE
370
383
  isIntegerBelow(.4, 5); // FALsE
@@ -374,7 +387,7 @@ isIntegerBelow(-9, -10); // FALSE
374
387
 
375
388
  - **isIntegerBetween(val:number, min:number, max:number)**
376
389
  Check if a variable is an integer between a range of numbers
377
- ```
390
+ ```js
378
391
  isIntegerBetween(5, 0, 10); // TRUE
379
392
  isIntegerBetween(.1, 0, 1); // FALSE
380
393
  isIntegerBetween(-.1, -1, 0); // FALSE
@@ -384,14 +397,14 @@ isIntegerBetween(-1, 0, 1); // FALSE
384
397
 
385
398
  - **isNumericalNaN(val:any)**
386
399
  Check if a variable is a numerical nan ( a number that is a NaN, this distinguishment is made since both a string or a number can be NaN)
387
- ```
400
+ ```js
388
401
  isNumericalNaN('foo'); // FALSE
389
402
  isNumericalNaN(NaN); // TRUE
390
403
  ```
391
404
 
392
405
  - **toPercentage(val:Number,precision:Number=0,min:Number=0,max:Number=1)**
393
406
  Calculate the percentage of a specific value in a range
394
- ```
407
+ ```js
395
408
  toPercentage(0.50106579, 5); // 50.11658
396
409
  toPercentage(-356, 0, -1000, 1000); // 32
397
410
  toPercentage(0.5); // 50
@@ -399,7 +412,7 @@ toPercentage(0.5); // 50
399
412
 
400
413
  - **round(val:Number,precision:Number=0)**
401
414
  Round a numeric value to a specific amount of decimals
402
- ```
415
+ ```js
403
416
  round(5.123456789, 0); // 5
404
417
  round(5.123456789, 2); // 5.12
405
418
  round(5.123456789, 5); // 5.12346
@@ -407,7 +420,7 @@ round(5.123456789, 5); // 5.12346
407
420
 
408
421
  - **randomBetween(min:Number=0,max:Number=10)**
409
422
  Generate a random numeric value between a min and max range
410
- ```
423
+ ```js
411
424
  randomBetween(); // Will generate a random between 0 and 10
412
425
  randomBetween(25, 100); // Will generate a random between 25 and 100
413
426
  ```
@@ -415,21 +428,21 @@ randomBetween(25, 100); // Will generate a random between 25 and 100
415
428
  ### object
416
429
  - **forValues(obj:Object={}, cb:Function=noopreturn)**
417
430
  Iterate over the keys of the object and apply the callback function to their values
418
- ```
431
+ ```js
419
432
  const obj = {a: 1, b: 2, c: 3};
420
433
  forValues(obj, (key, value, index) => value + 1); // {a: 2, b:3, c:4}
421
434
  ```
422
435
 
423
436
  - **isObject(val:any)**
424
437
  Check if a variable is of type Object
425
- ```
438
+ ```js
426
439
  isObject({a: 1}); // TRUE
427
440
  isObject(1); // FALSE
428
441
  ```
429
442
 
430
443
  - **isNotEmptyObject(val:any)**
431
444
  Check if a variable a non-empty object
432
- ```
445
+ ```js
433
446
  isNotEmptyObject({a:1}); // TRUE
434
447
  isNotEmptyObject({}); // FALSE
435
448
  isNotEmptyObject('Hi'); // FALSE
@@ -438,31 +451,33 @@ isNotEmptyObject('Hi'); // FALSE
438
451
  - **pick(obj:Object={}, keys:Array[string]=[])**
439
452
  Copies the keys passed in the 'keys' array from the passed object to a new object and returns that object.**
440
453
  <small>If a key wasn't found it will be set as undefined</small>
441
- ```
454
+ ```js
442
455
  pick({a: 1, b: 2, c: 3}, ['a','b']); // {a: 1, b: 2}
443
456
  ```
444
457
 
445
458
  - **merge(target:Object={},obj:Object={})**
446
459
  Merges two objects together, with the preference over the second object.
447
- ```
460
+ ```js
448
461
  merge({a: 1, b: false}, {a: 900, c: 50}); // {a: 900, b: false, c: 50}
449
462
  ```
450
463
 
451
464
  - **zip(keys:Array[string]=[], values:Array[string]=[], default_to:any=null)**
452
465
  Creates an object from a keys and a values array. Mapping them together.
453
- ```
466
+ ```js
454
467
  zip(['a', 'b'], [100, 200]); // {a: 100, b: 200}
455
468
  ```
456
- ```
469
+
470
+ ```js
457
471
  zip(['a','b']); // {a: null, b: null}
458
472
  ```
459
- ```
473
+
474
+ ```js
460
475
  zip(['a','b', false, 9999]); // {a: 9999, b: 9999}
461
476
  ```
462
477
 
463
478
  - **define(props:Object, obj:Object={})**
464
479
  Creates an object with the passed accessors set on it
465
- ```
480
+ ```js
466
481
  define(
467
482
  {
468
483
  a: {
@@ -474,7 +489,8 @@ define(
474
489
  );
475
490
  // { a : () => ..., b: 2 }
476
491
  ```
477
- ```
492
+
493
+ ```js
478
494
  define({
479
495
  a : {
480
496
  enumerable: false,
@@ -485,7 +501,7 @@ define({
485
501
 
486
502
  - **defineFrozen(props:Object, obj:Object={})**
487
503
  Creates an object with the passed accessors set on it, and returns it as a frozen object
488
- ```
504
+ ```js
489
505
  const myObject = defineFrozen({
490
506
  a : {
491
507
  enumerable: false,
@@ -498,7 +514,7 @@ Object.isFrozen(myObject); // TRUE
498
514
 
499
515
  - **defineSealed(props:Object, obj:Object={})**
500
516
  Creates an object with the passed accessors set on it, and returns it as a sealed object
501
- ```
517
+ ```js
502
518
  const myObject = defineSealed({
503
519
  a : {
504
520
  enumerable: false,
@@ -512,7 +528,7 @@ Object.isSealed(myObject); // TRUE
512
528
  ### regexp
513
529
  - **isRegExp(val:any)**
514
530
  Check if a variable is an instance of RegExp
515
- ```
531
+ ```js
516
532
  isRegExp('foo'); // FALSE
517
533
  isRegExp(new RegExp('ab+c', 'i')); // TRUE
518
534
  isRegExp(new RegExp(/ab+c/, 'i')); // TRUE
@@ -522,14 +538,14 @@ isRegExp(/ab+c/i); // FALSE
522
538
  ### string
523
539
  - **isString(val:any)**
524
540
  Check if a variable is a string
525
- ```
541
+ ```js
526
542
  isString('foo'); // TRUE
527
543
  isString(4); // FALSE
528
544
  ```
529
545
 
530
546
  - **isStringBetween(val:string, min:number, max:number, trimmed:boolean=true)**
531
547
  Check if a variable is between a range of numbers
532
- ```
548
+ ```js
533
549
  isStringBetween('Peter', 4, 10); // TRUE
534
550
  isStringBetween('Jeff', 4, 10); // TRUE
535
551
  isStringBetween('Moe', 4, 10); // FALSE
@@ -540,7 +556,7 @@ isStringBetween(' Joe', 1, 3, false); // FALSE
540
556
 
541
557
  - **isNotEmptyString(val:any, trimmed:boolean=true)**
542
558
  Check if a variable a non-empty string
543
- ```
559
+ ```js
544
560
  isNotEmptyString({a:1}); // FALSE
545
561
  isNotEmptyString(''); // FALSE
546
562
  isNotEmptyString(' '); // FALSE
@@ -550,7 +566,7 @@ isNotEmptyString('Hi'); // TRUE
550
566
 
551
567
  - **shorten(val:any, length:integer, postfix:string=...)**
552
568
  Shorten a string and add a postfix if string went over length
553
- ```
569
+ ```js
554
570
  shorten('To the moon and beyond', 11, '..'); // 'To the moon..'
555
571
  shorten('Hi', 250); // 'Hi'
556
572
  shorten('To the moon and beyond'); // 'To the moon...'
package/array/dedupe.js CHANGED
@@ -4,21 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  });
6
6
  exports["default"] = _default;
7
-
8
7
  var _fnv1A = _interopRequireDefault(require("../hash/fnv1A"));
9
-
10
8
  var _isNotEmpty = _interopRequireDefault(require("./isNotEmpty"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  function _default() {
15
11
  var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
16
12
  if (!(0, _isNotEmpty["default"])(val)) return [];
17
13
  var seen = {};
18
14
  return val.filter(function (item) {
19
15
  var hash = (0, _fnv1A["default"])(item);
16
+
20
17
  if (Object.prototype.hasOwnProperty.call(seen, hash)) return !1;
18
+
21
19
  seen[hash] = !0;
20
+
22
21
  return !0;
23
22
  });
24
23
  }
package/array/is.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  });
6
6
  exports["default"] = _default;
7
-
8
7
  function _default(val) {
9
8
  return Array.isArray(val);
10
9
  }
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  });
6
6
  exports["default"] = _default;
7
-
8
7
  var _is = _interopRequireDefault(require("./is"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
9
  function _default(val) {
13
10
  if (!(0, _is["default"])(val)) return !1;
14
11
  return val.length !== 0;
package/array/join.js CHANGED
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  });
6
6
  exports["default"] = _default;
7
-
8
7
  var _isNotEmpty = _interopRequireDefault(require("./isNotEmpty"));
9
-
10
8
  var _isNotEmpty2 = _interopRequireDefault(require("../string/isNotEmpty"));
11
-
12
9
  var _is = _interopRequireDefault(require("../number/is"));
13
-
14
10
  var _isNotEmpty3 = _interopRequireDefault(require("../object/isNotEmpty"));
15
-
16
11
  var _round = _interopRequireDefault(require("../number/round"));
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
13
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: !0 }; return { done: !1, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = !0, didErr = !1, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = !0; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
21
-
22
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
-
24
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
-
26
16
  function _default(arr) {
27
17
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
28
18
  if (!(0, _isNotEmpty["default"])(arr)) return '';
@@ -33,14 +23,11 @@ function _default(arr) {
33
23
  valround: !1
34
24
  }, (0, _isNotEmpty3["default"])(options) ? options : {});
35
25
  var filtered = [];
36
-
37
26
  var _iterator = _createForOfIteratorHelper(arr),
38
- _step;
39
-
27
+ _step;
40
28
  try {
41
29
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
42
30
  var el = _step.value;
43
-
44
31
  if ((0, _isNotEmpty2["default"])(el)) {
45
32
  filtered.push(OPTS.valtrim === !0 ? el.trim() : el);
46
33
  } else if ((0, _is["default"])(el)) {
@@ -52,6 +39,5 @@ function _default(arr) {
52
39
  } finally {
53
40
  _iterator.f();
54
41
  }
55
-
56
42
  return OPTS.trim === !0 ? filtered.join(OPTS.delim).trim() : filtered.join(OPTS.delim);
57
43
  }
package/array/mapFn.js CHANGED
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  });
6
6
  exports["default"] = _default;
7
-
8
7
  var _is = _interopRequireDefault(require("../object/is"));
9
-
10
8
  var _isNotEmpty = _interopRequireDefault(require("./isNotEmpty"));
11
-
12
9
  var _is2 = _interopRequireDefault(require("../function/is"));
13
-
14
10
  var _isNotEmpty2 = _interopRequireDefault(require("../string/isNotEmpty"));
15
-
16
11
  var _is3 = _interopRequireDefault(require("../number/is"));
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
13
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: !0 }; return { done: !1, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = !0, didErr = !1, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = !0; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
21
-
22
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
-
24
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
25
-
26
16
  function _default(arr, fn) {
27
17
  var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
28
18
  if (!(0, _isNotEmpty["default"])(arr) || !(0, _is2["default"])(fn)) return {};
@@ -31,17 +21,15 @@ function _default(arr, fn) {
31
21
  }, (0, _is["default"])(opts) ? opts : {});
32
22
  var map = {};
33
23
  var hash = !1;
34
-
35
24
  var _iterator = _createForOfIteratorHelper(arr),
36
- _step;
37
-
25
+ _step;
38
26
  try {
39
27
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
40
28
  var el = _step.value;
41
29
  if (!(0, _is["default"])(el)) continue;
30
+
42
31
  hash = fn(el);
43
32
  if (!(0, _is3["default"])(hash) && !(0, _isNotEmpty2["default"])(hash)) continue;
44
-
45
33
  if (OPTS.merge === !0 && map.hasOwnProperty(hash)) {
46
34
  map[hash] = Object.assign(map[hash], el);
47
35
  } else {
@@ -53,6 +41,5 @@ function _default(arr, fn) {
53
41
  } finally {
54
42
  _iterator.f();
55
43
  }
56
-
57
44
  return map;
58
45
  }
package/array/mapKey.js CHANGED
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  });
6
6
  exports["default"] = _default;
7
-
8
7
  var _is = _interopRequireDefault(require("../object/is"));
9
-
10
8
  var _isNotEmpty = _interopRequireDefault(require("./isNotEmpty"));
11
-
12
9
  var _isNotEmpty2 = _interopRequireDefault(require("../string/isNotEmpty"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
11
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: !0 }; return { done: !1, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = !0, didErr = !1, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = !0; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
17
-
18
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
-
20
13
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
-
22
14
  function _default(arr, key) {
23
15
  var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24
16
  if (!(0, _isNotEmpty["default"])(arr) || !(0, _isNotEmpty2["default"])(key)) return {};
@@ -26,15 +18,12 @@ function _default(arr, key) {
26
18
  merge: !1
27
19
  }, (0, _is["default"])(opts) ? opts : {});
28
20
  var map = {};
29
-
30
21
  var _iterator = _createForOfIteratorHelper(arr),
31
- _step;
32
-
22
+ _step;
33
23
  try {
34
24
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
35
25
  var el = _step.value;
36
26
  if (!(0, _is["default"])(el) || !el.hasOwnProperty(key)) continue;
37
-
38
27
  if (OPTS.merge === !0 && map.hasOwnProperty(el[key])) {
39
28
  map[el[key]] = Object.assign(map[el[key]], el);
40
29
  } else {
@@ -46,6 +35,5 @@ function _default(arr, key) {
46
35
  } finally {
47
36
  _iterator.f();
48
37
  }
49
-
50
38
  return map;
51
39
  }