@valkyriestudios/utils 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/42fb4596-cca6-4b5f-9d84-4dfa81222f86.json +1 -0
- package/.nyc_output/e5760d4f-f98f-4742-ab93-9fe7645e0319.json +1 -0
- package/.nyc_output/processinfo/42fb4596-cca6-4b5f-9d84-4dfa81222f86.json +1 -0
- package/.nyc_output/processinfo/e5760d4f-f98f-4742-ab93-9fe7645e0319.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +57 -51
- package/array/dedupe.js +3 -4
- package/array/is.js +0 -1
- package/array/isNotEmpty.js +0 -3
- package/array/join.js +1 -15
- package/array/mapFn.js +2 -15
- package/array/mapKey.js +1 -13
- package/array/mapPrimitive.js +1 -14
- package/array/shuffle.js +17 -0
- package/boolean/is.js +0 -1
- package/caching/memoize.js +14 -10
- package/coverage/lcov-report/index.html +17 -17
- package/coverage/lcov-report/src/array/dedupe.js.html +1 -1
- package/coverage/lcov-report/src/array/index.html +21 -6
- package/coverage/lcov-report/src/array/is.js.html +2 -2
- package/coverage/lcov-report/src/array/isNotEmpty.js.html +3 -3
- package/coverage/lcov-report/src/array/join.js.html +1 -1
- package/coverage/lcov-report/src/array/mapFn.js.html +1 -1
- package/coverage/lcov-report/src/array/mapKey.js.html +1 -1
- package/coverage/lcov-report/src/array/mapPrimitive.js.html +1 -1
- package/coverage/lcov-report/src/array/shuffle.js.html +133 -0
- package/coverage/lcov-report/src/boolean/index.html +1 -1
- package/coverage/lcov-report/src/boolean/is.js.html +1 -1
- package/coverage/lcov-report/src/caching/index.html +7 -7
- package/coverage/lcov-report/src/caching/memoize.js.html +39 -21
- package/coverage/lcov-report/src/date/index.html +1 -1
- package/coverage/lcov-report/src/date/is.js.html +1 -1
- package/coverage/lcov-report/src/deep/define.js.html +1 -1
- package/coverage/lcov-report/src/deep/freeze.js.html +1 -1
- package/coverage/lcov-report/src/deep/get.js.html +1 -1
- package/coverage/lcov-report/src/deep/index.html +1 -1
- package/coverage/lcov-report/src/deep/seal.js.html +1 -1
- package/coverage/lcov-report/src/deep/set.js.html +1 -1
- package/coverage/lcov-report/src/equal.js.html +1 -1
- package/coverage/lcov-report/src/function/index.html +1 -1
- package/coverage/lcov-report/src/function/is.js.html +2 -2
- package/coverage/lcov-report/src/function/noop.js.html +1 -1
- package/coverage/lcov-report/src/function/noopresolve.js.html +1 -1
- package/coverage/lcov-report/src/function/noopreturn.js.html +1 -1
- package/coverage/lcov-report/src/function/sleep.js.html +1 -1
- package/coverage/lcov-report/src/hash/fnv1A.js.html +13 -13
- package/coverage/lcov-report/src/hash/guid.js.html +1 -1
- package/coverage/lcov-report/src/hash/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/is.js.html +1 -1
- package/coverage/lcov-report/src/number/index.html +1 -1
- package/coverage/lcov-report/src/number/is.js.html +1 -1
- package/coverage/lcov-report/src/number/isAbove.js.html +1 -1
- package/coverage/lcov-report/src/number/isBelow.js.html +1 -1
- package/coverage/lcov-report/src/number/isBetween.js.html +1 -1
- package/coverage/lcov-report/src/number/isInteger.js.html +1 -1
- package/coverage/lcov-report/src/number/isIntegerAbove.js.html +1 -1
- package/coverage/lcov-report/src/number/isIntegerBelow.js.html +1 -1
- package/coverage/lcov-report/src/number/isIntegerBetween.js.html +1 -1
- package/coverage/lcov-report/src/number/isNumericalNaN.js.html +1 -1
- package/coverage/lcov-report/src/number/randomBetween.js.html +1 -1
- package/coverage/lcov-report/src/number/round.js.html +1 -1
- package/coverage/lcov-report/src/number/toPercentage.js.html +1 -1
- package/coverage/lcov-report/src/object/define.js.html +1 -1
- package/coverage/lcov-report/src/object/defineFrozen.js.html +1 -1
- package/coverage/lcov-report/src/object/defineSealed.js.html +1 -1
- package/coverage/lcov-report/src/object/forValues.js.html +1 -1
- package/coverage/lcov-report/src/object/index.html +1 -1
- package/coverage/lcov-report/src/object/is.js.html +1 -1
- package/coverage/lcov-report/src/object/isNotEmpty.js.html +1 -1
- package/coverage/lcov-report/src/object/merge.js.html +1 -1
- package/coverage/lcov-report/src/object/pick.js.html +1 -1
- package/coverage/lcov-report/src/object/zip.js.html +1 -1
- package/coverage/lcov-report/src/regexp/index.html +1 -1
- package/coverage/lcov-report/src/regexp/is.js.html +1 -1
- package/coverage/lcov-report/src/string/index.html +1 -1
- package/coverage/lcov-report/src/string/is.js.html +2 -2
- package/coverage/lcov-report/src/string/isBetween.js.html +1 -1
- package/coverage/lcov-report/src/string/isNotEmpty.js.html +1 -1
- package/coverage/lcov-report/src/string/shorten.js.html +1 -1
- package/coverage/lcov.info +84 -55
- package/date/is.js +0 -1
- package/deep/define.js +0 -3
- package/deep/freeze.js +0 -5
- package/deep/get.js +2 -12
- package/deep/seal.js +0 -5
- package/deep/set.js +2 -12
- package/equal.js +0 -13
- package/function/is.js +0 -1
- package/function/noop.js +2 -2
- package/function/noopresolve.js +0 -1
- package/function/noopreturn.js +0 -1
- package/function/sleep.js +0 -1
- package/hash/fnv1A.js +1 -10
- package/hash/guid.js +2 -2
- package/is.js +0 -21
- package/number/is.js +0 -3
- package/number/isAbove.js +0 -3
- package/number/isBelow.js +0 -3
- package/number/isBetween.js +0 -3
- package/number/isInteger.js +0 -3
- package/number/isIntegerAbove.js +0 -4
- package/number/isIntegerBelow.js +0 -4
- package/number/isIntegerBetween.js +0 -4
- package/number/randomBetween.js +0 -3
- package/number/round.js +1 -4
- package/number/toPercentage.js +0 -4
- package/object/define.js +0 -5
- package/object/defineFrozen.js +0 -3
- package/object/defineSealed.js +0 -3
- package/object/forValues.js +0 -7
- package/object/is.js +0 -1
- package/object/isNotEmpty.js +0 -3
- package/object/merge.js +0 -8
- package/object/pick.js +0 -9
- package/object/zip.js +0 -6
- package/package.json +6 -6
- package/regexp/is.js +0 -1
- package/string/is.js +0 -1
- package/string/isBetween.js +0 -4
- package/string/isNotEmpty.js +0 -3
- package/string/shorten.js +0 -5
- package/.nyc_output/58f73d7a-e507-4792-bfca-ebfb34732639.json +0 -1
- package/.nyc_output/86a24097-14b3-4c83-9aaf-69614f599a22.json +0 -1
- package/.nyc_output/processinfo/58f73d7a-e507-4792-bfca-ebfb34732639.json +0 -1
- 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'
|
|
@@ -149,7 +149,7 @@ join([' a', 1], {delim: '', valtrim: false, trim: false}); // ' a1'
|
|
|
149
149
|
### boolean
|
|
150
150
|
- **isBoolean(val:any)**
|
|
151
151
|
Check if a variable is of type Boolean
|
|
152
|
-
```
|
|
152
|
+
```js
|
|
153
153
|
isBoolean(null); // FALSE
|
|
154
154
|
isBoolean(false); // TRUE
|
|
155
155
|
isBoolean(true); // TRUE
|
|
@@ -158,7 +158,7 @@ isBoolean(true); // TRUE
|
|
|
158
158
|
### caching
|
|
159
159
|
- **memoize(fn:Function)**
|
|
160
160
|
memoize the output of a specific function to allow for the creation of an internal cache using the fnv 1A hash algorithm
|
|
161
|
-
```
|
|
161
|
+
```js
|
|
162
162
|
const memoized_function = memoize((a, b) => {
|
|
163
163
|
return a + b;
|
|
164
164
|
});
|
|
@@ -167,7 +167,7 @@ const memoized_function = memoize((a, b) => {
|
|
|
167
167
|
### date
|
|
168
168
|
- **isDate(val:any)**
|
|
169
169
|
Check if a variable is of type Date
|
|
170
|
-
```
|
|
170
|
+
```js
|
|
171
171
|
isDate(new Date('December 17, 1995 03:24:00'); // TRUE
|
|
172
172
|
isDate('December 17, 1995 03:24:00'); // FALSE
|
|
173
173
|
```
|
|
@@ -175,7 +175,7 @@ isDate('December 17, 1995 03:24:00'); // FALSE
|
|
|
175
175
|
### deep
|
|
176
176
|
- **deepFreeze(val:Object)**
|
|
177
177
|
Recursively freezes all properties of an object
|
|
178
|
-
```
|
|
178
|
+
```js
|
|
179
179
|
const myObj = deepFreeze({
|
|
180
180
|
a: 2,
|
|
181
181
|
b: {
|
|
@@ -192,7 +192,7 @@ Object.isFrozen(myObj.b.d); // TRUE
|
|
|
192
192
|
|
|
193
193
|
- **deepSeal(val:Object)**
|
|
194
194
|
Recursively freezes all properties of an object
|
|
195
|
-
```
|
|
195
|
+
```js
|
|
196
196
|
const myObj = deepSeal({
|
|
197
197
|
a: 2,
|
|
198
198
|
b: {
|
|
@@ -210,14 +210,15 @@ Object.isFrozen(myObj.b.d); // FALSE
|
|
|
210
210
|
|
|
211
211
|
- **deepSet(obj:Object, path:string, value:any=null, define:boolean=false)**
|
|
212
212
|
Sets a property and its value deep in the structure of an object
|
|
213
|
-
```
|
|
213
|
+
```js
|
|
214
214
|
const myObj = {
|
|
215
215
|
a: 2,
|
|
216
216
|
});
|
|
217
217
|
deepSet(myObj, 'b.c.d.e', 4);
|
|
218
218
|
myObj.b.c.d.e; // 4
|
|
219
219
|
```
|
|
220
|
-
|
|
220
|
+
|
|
221
|
+
```js
|
|
221
222
|
const myObj = {
|
|
222
223
|
a: 2,
|
|
223
224
|
b: [
|
|
@@ -230,7 +231,8 @@ deepSet(myObj, 'b[1].price', 500);
|
|
|
230
231
|
myObj.b[0].price; // 100
|
|
231
232
|
myObj.b[1].price; // 500
|
|
232
233
|
```
|
|
233
|
-
|
|
234
|
+
|
|
235
|
+
```js
|
|
234
236
|
const myObj = {
|
|
235
237
|
a: 2,
|
|
236
238
|
});
|
|
@@ -240,7 +242,7 @@ myObj.b.c; // Function
|
|
|
240
242
|
|
|
241
243
|
- **deepGet(obj:Object, path:string, get_parent:boolean=false)**
|
|
242
244
|
Retrieves a value based on a path in a deeply nested object
|
|
243
|
-
```
|
|
245
|
+
```js
|
|
244
246
|
const myObj = {
|
|
245
247
|
a: 2,
|
|
246
248
|
b: [
|
|
@@ -250,7 +252,8 @@ const myObj = {
|
|
|
250
252
|
});
|
|
251
253
|
deepGet(myObj, 'b[0].price', true); // [{price: 2}, {price: 4}]
|
|
252
254
|
```
|
|
253
|
-
|
|
255
|
+
|
|
256
|
+
```js
|
|
254
257
|
const myObj = {
|
|
255
258
|
a: 2,
|
|
256
259
|
b: [
|
|
@@ -264,7 +267,7 @@ deepGet(myObj, 'b[0].price'); // 2
|
|
|
264
267
|
### equal
|
|
265
268
|
- **equal(a:any, b:any)**
|
|
266
269
|
Check if a variable is equal to another one
|
|
267
|
-
```
|
|
270
|
+
```js
|
|
268
271
|
equal(5, 6); // FALSE
|
|
269
272
|
equal(1, 1); // TRUE
|
|
270
273
|
equal([0, 1, 2], [1, 2]); // FALSE
|
|
@@ -294,13 +297,13 @@ An empty function that returns a promise that will resolve after X milliseconds,
|
|
|
294
297
|
### hash
|
|
295
298
|
- **guid()**
|
|
296
299
|
Generate a unique identifier (guid) according to RFC4122
|
|
297
|
-
```
|
|
300
|
+
```js
|
|
298
301
|
guid(); // 245caf1a-86af-11e7-bb31-be2e44b06b34
|
|
299
302
|
```
|
|
300
303
|
|
|
301
304
|
- **fnv1A(val:any)**
|
|
302
305
|
Generate a fnv1A hash from an object, using a 32-bit prime/offset
|
|
303
|
-
```
|
|
306
|
+
```js
|
|
304
307
|
fnv1A('hello world'); // -2023343616
|
|
305
308
|
fnv1A({a:1,b:2}); // 361168128
|
|
306
309
|
fnv1A(4); // 1630425728
|
|
@@ -311,7 +314,7 @@ fnv1A(new Date('2012-02-02')); // 1655579136
|
|
|
311
314
|
### number
|
|
312
315
|
- **isNumber(val:any)**
|
|
313
316
|
Check if a variable is a number
|
|
314
|
-
```
|
|
317
|
+
```js
|
|
315
318
|
isNumber('foo'); // FALSE
|
|
316
319
|
isNumber(4); // TRUE
|
|
317
320
|
isNumber(0.5); // TRUE
|
|
@@ -319,7 +322,7 @@ isNumber(0.5); // TRUE
|
|
|
319
322
|
|
|
320
323
|
- **isNumberAbove(val:number, comp:number)**
|
|
321
324
|
Check if a variable is above a certain bound
|
|
322
|
-
```
|
|
325
|
+
```js
|
|
323
326
|
isNumberAbove(5, 0); // TRUE
|
|
324
327
|
isNumberAbove(.1, 0); // TRUE
|
|
325
328
|
isNumberAbove(-1, -1); // FALSE
|
|
@@ -328,7 +331,7 @@ isNumberAbove(-10, -9); // FALSE
|
|
|
328
331
|
|
|
329
332
|
- **isNumberBelow(val:number, comp:number)**
|
|
330
333
|
Check if a variable is below a certain bound
|
|
331
|
-
```
|
|
334
|
+
```js
|
|
332
335
|
isNumberBelow(0, 5); // TRUE
|
|
333
336
|
isNumberBelow(0, .1); // TRUE
|
|
334
337
|
isNumberBelow(-1, -1); // FALSE
|
|
@@ -337,7 +340,7 @@ isNumberBelow(-9, -10); // FALSE
|
|
|
337
340
|
|
|
338
341
|
- **isNumberBetween(val:number, min:number, max:number)**
|
|
339
342
|
Check if a variable is between a range of numbers
|
|
340
|
-
```
|
|
343
|
+
```js
|
|
341
344
|
isNumberBetween(5, 0, 10); // TRUE
|
|
342
345
|
isNumberBetween(.1, 0, 1); // TRUE
|
|
343
346
|
isNumberBetween(-.1, -1, 0); // TRUE
|
|
@@ -347,7 +350,7 @@ isNumberBetween(-1, 0, 1); // FALSE
|
|
|
347
350
|
|
|
348
351
|
- **isInteger(val:any)**
|
|
349
352
|
Check if a variable is an integer
|
|
350
|
-
```
|
|
353
|
+
```js
|
|
351
354
|
isInteger('foo'); // FALSE
|
|
352
355
|
isInteger(4); // TRUE
|
|
353
356
|
isInteger(0.5); // FALSE
|
|
@@ -355,7 +358,7 @@ isInteger(0.5); // FALSE
|
|
|
355
358
|
|
|
356
359
|
- **isIntegerAbove(val:number, comp:number)**
|
|
357
360
|
Check if a variable is an integer above a certain bound
|
|
358
|
-
```
|
|
361
|
+
```js
|
|
359
362
|
isIntegerAbove(5, 0); // TRUE
|
|
360
363
|
isIntegerAbove(.1, 0); // FALSE
|
|
361
364
|
isIntegerAbove(-1, -1); // FALSE
|
|
@@ -364,7 +367,7 @@ isIntegerAbove(-10, -9); // FALSE
|
|
|
364
367
|
|
|
365
368
|
- **isIntegerBelow(val:number, comp:number)**
|
|
366
369
|
Check if a variable is an integer below a certain bound
|
|
367
|
-
```
|
|
370
|
+
```js
|
|
368
371
|
isIntegerBelow(0, 5); // TRUE
|
|
369
372
|
isIntegerBelow(0, .1); // TRUE
|
|
370
373
|
isIntegerBelow(.4, 5); // FALsE
|
|
@@ -374,7 +377,7 @@ isIntegerBelow(-9, -10); // FALSE
|
|
|
374
377
|
|
|
375
378
|
- **isIntegerBetween(val:number, min:number, max:number)**
|
|
376
379
|
Check if a variable is an integer between a range of numbers
|
|
377
|
-
```
|
|
380
|
+
```js
|
|
378
381
|
isIntegerBetween(5, 0, 10); // TRUE
|
|
379
382
|
isIntegerBetween(.1, 0, 1); // FALSE
|
|
380
383
|
isIntegerBetween(-.1, -1, 0); // FALSE
|
|
@@ -384,14 +387,14 @@ isIntegerBetween(-1, 0, 1); // FALSE
|
|
|
384
387
|
|
|
385
388
|
- **isNumericalNaN(val:any)**
|
|
386
389
|
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
|
-
```
|
|
390
|
+
```js
|
|
388
391
|
isNumericalNaN('foo'); // FALSE
|
|
389
392
|
isNumericalNaN(NaN); // TRUE
|
|
390
393
|
```
|
|
391
394
|
|
|
392
395
|
- **toPercentage(val:Number,precision:Number=0,min:Number=0,max:Number=1)**
|
|
393
396
|
Calculate the percentage of a specific value in a range
|
|
394
|
-
```
|
|
397
|
+
```js
|
|
395
398
|
toPercentage(0.50106579, 5); // 50.11658
|
|
396
399
|
toPercentage(-356, 0, -1000, 1000); // 32
|
|
397
400
|
toPercentage(0.5); // 50
|
|
@@ -399,7 +402,7 @@ toPercentage(0.5); // 50
|
|
|
399
402
|
|
|
400
403
|
- **round(val:Number,precision:Number=0)**
|
|
401
404
|
Round a numeric value to a specific amount of decimals
|
|
402
|
-
```
|
|
405
|
+
```js
|
|
403
406
|
round(5.123456789, 0); // 5
|
|
404
407
|
round(5.123456789, 2); // 5.12
|
|
405
408
|
round(5.123456789, 5); // 5.12346
|
|
@@ -407,7 +410,7 @@ round(5.123456789, 5); // 5.12346
|
|
|
407
410
|
|
|
408
411
|
- **randomBetween(min:Number=0,max:Number=10)**
|
|
409
412
|
Generate a random numeric value between a min and max range
|
|
410
|
-
```
|
|
413
|
+
```js
|
|
411
414
|
randomBetween(); // Will generate a random between 0 and 10
|
|
412
415
|
randomBetween(25, 100); // Will generate a random between 25 and 100
|
|
413
416
|
```
|
|
@@ -415,21 +418,21 @@ randomBetween(25, 100); // Will generate a random between 25 and 100
|
|
|
415
418
|
### object
|
|
416
419
|
- **forValues(obj:Object={}, cb:Function=noopreturn)**
|
|
417
420
|
Iterate over the keys of the object and apply the callback function to their values
|
|
418
|
-
```
|
|
421
|
+
```js
|
|
419
422
|
const obj = {a: 1, b: 2, c: 3};
|
|
420
423
|
forValues(obj, (key, value, index) => value + 1); // {a: 2, b:3, c:4}
|
|
421
424
|
```
|
|
422
425
|
|
|
423
426
|
- **isObject(val:any)**
|
|
424
427
|
Check if a variable is of type Object
|
|
425
|
-
```
|
|
428
|
+
```js
|
|
426
429
|
isObject({a: 1}); // TRUE
|
|
427
430
|
isObject(1); // FALSE
|
|
428
431
|
```
|
|
429
432
|
|
|
430
433
|
- **isNotEmptyObject(val:any)**
|
|
431
434
|
Check if a variable a non-empty object
|
|
432
|
-
```
|
|
435
|
+
```js
|
|
433
436
|
isNotEmptyObject({a:1}); // TRUE
|
|
434
437
|
isNotEmptyObject({}); // FALSE
|
|
435
438
|
isNotEmptyObject('Hi'); // FALSE
|
|
@@ -438,31 +441,33 @@ isNotEmptyObject('Hi'); // FALSE
|
|
|
438
441
|
- **pick(obj:Object={}, keys:Array[string]=[])**
|
|
439
442
|
Copies the keys passed in the 'keys' array from the passed object to a new object and returns that object.**
|
|
440
443
|
<small>If a key wasn't found it will be set as undefined</small>
|
|
441
|
-
```
|
|
444
|
+
```js
|
|
442
445
|
pick({a: 1, b: 2, c: 3}, ['a','b']); // {a: 1, b: 2}
|
|
443
446
|
```
|
|
444
447
|
|
|
445
448
|
- **merge(target:Object={},obj:Object={})**
|
|
446
449
|
Merges two objects together, with the preference over the second object.
|
|
447
|
-
```
|
|
450
|
+
```js
|
|
448
451
|
merge({a: 1, b: false}, {a: 900, c: 50}); // {a: 900, b: false, c: 50}
|
|
449
452
|
```
|
|
450
453
|
|
|
451
454
|
- **zip(keys:Array[string]=[], values:Array[string]=[], default_to:any=null)**
|
|
452
455
|
Creates an object from a keys and a values array. Mapping them together.
|
|
453
|
-
```
|
|
456
|
+
```js
|
|
454
457
|
zip(['a', 'b'], [100, 200]); // {a: 100, b: 200}
|
|
455
458
|
```
|
|
456
|
-
|
|
459
|
+
|
|
460
|
+
```js
|
|
457
461
|
zip(['a','b']); // {a: null, b: null}
|
|
458
462
|
```
|
|
459
|
-
|
|
463
|
+
|
|
464
|
+
```js
|
|
460
465
|
zip(['a','b', false, 9999]); // {a: 9999, b: 9999}
|
|
461
466
|
```
|
|
462
467
|
|
|
463
468
|
- **define(props:Object, obj:Object={})**
|
|
464
469
|
Creates an object with the passed accessors set on it
|
|
465
|
-
```
|
|
470
|
+
```js
|
|
466
471
|
define(
|
|
467
472
|
{
|
|
468
473
|
a: {
|
|
@@ -474,7 +479,8 @@ define(
|
|
|
474
479
|
);
|
|
475
480
|
// { a : () => ..., b: 2 }
|
|
476
481
|
```
|
|
477
|
-
|
|
482
|
+
|
|
483
|
+
```js
|
|
478
484
|
define({
|
|
479
485
|
a : {
|
|
480
486
|
enumerable: false,
|
|
@@ -485,7 +491,7 @@ define({
|
|
|
485
491
|
|
|
486
492
|
- **defineFrozen(props:Object, obj:Object={})**
|
|
487
493
|
Creates an object with the passed accessors set on it, and returns it as a frozen object
|
|
488
|
-
```
|
|
494
|
+
```js
|
|
489
495
|
const myObject = defineFrozen({
|
|
490
496
|
a : {
|
|
491
497
|
enumerable: false,
|
|
@@ -498,7 +504,7 @@ Object.isFrozen(myObject); // TRUE
|
|
|
498
504
|
|
|
499
505
|
- **defineSealed(props:Object, obj:Object={})**
|
|
500
506
|
Creates an object with the passed accessors set on it, and returns it as a sealed object
|
|
501
|
-
```
|
|
507
|
+
```js
|
|
502
508
|
const myObject = defineSealed({
|
|
503
509
|
a : {
|
|
504
510
|
enumerable: false,
|
|
@@ -512,7 +518,7 @@ Object.isSealed(myObject); // TRUE
|
|
|
512
518
|
### regexp
|
|
513
519
|
- **isRegExp(val:any)**
|
|
514
520
|
Check if a variable is an instance of RegExp
|
|
515
|
-
```
|
|
521
|
+
```js
|
|
516
522
|
isRegExp('foo'); // FALSE
|
|
517
523
|
isRegExp(new RegExp('ab+c', 'i')); // TRUE
|
|
518
524
|
isRegExp(new RegExp(/ab+c/, 'i')); // TRUE
|
|
@@ -522,14 +528,14 @@ isRegExp(/ab+c/i); // FALSE
|
|
|
522
528
|
### string
|
|
523
529
|
- **isString(val:any)**
|
|
524
530
|
Check if a variable is a string
|
|
525
|
-
```
|
|
531
|
+
```js
|
|
526
532
|
isString('foo'); // TRUE
|
|
527
533
|
isString(4); // FALSE
|
|
528
534
|
```
|
|
529
535
|
|
|
530
536
|
- **isStringBetween(val:string, min:number, max:number, trimmed:boolean=true)**
|
|
531
537
|
Check if a variable is between a range of numbers
|
|
532
|
-
```
|
|
538
|
+
```js
|
|
533
539
|
isStringBetween('Peter', 4, 10); // TRUE
|
|
534
540
|
isStringBetween('Jeff', 4, 10); // TRUE
|
|
535
541
|
isStringBetween('Moe', 4, 10); // FALSE
|
|
@@ -540,7 +546,7 @@ isStringBetween(' Joe', 1, 3, false); // FALSE
|
|
|
540
546
|
|
|
541
547
|
- **isNotEmptyString(val:any, trimmed:boolean=true)**
|
|
542
548
|
Check if a variable a non-empty string
|
|
543
|
-
```
|
|
549
|
+
```js
|
|
544
550
|
isNotEmptyString({a:1}); // FALSE
|
|
545
551
|
isNotEmptyString(''); // FALSE
|
|
546
552
|
isNotEmptyString(' '); // FALSE
|
|
@@ -550,7 +556,7 @@ isNotEmptyString('Hi'); // TRUE
|
|
|
550
556
|
|
|
551
557
|
- **shorten(val:any, length:integer, postfix:string=...)**
|
|
552
558
|
Shorten a string and add a postfix if string went over length
|
|
553
|
-
```
|
|
559
|
+
```js
|
|
554
560
|
shorten('To the moon and beyond', 11, '..'); // 'To the moon..'
|
|
555
561
|
shorten('Hi', 250); // 'Hi'
|
|
556
562
|
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
package/array/isNotEmpty.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/array/mapPrimitive.js
CHANGED
|
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = _default;
|
|
7
|
-
|
|
8
7
|
var _is = _interopRequireDefault(require("../number/is"));
|
|
9
|
-
|
|
10
8
|
var _isNotEmpty = _interopRequireDefault(require("../string/isNotEmpty"));
|
|
11
|
-
|
|
12
9
|
var _isNotEmpty2 = _interopRequireDefault(require("./isNotEmpty"));
|
|
13
|
-
|
|
14
10
|
var _isNotEmpty3 = _interopRequireDefault(require("../object/isNotEmpty"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
12
|
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; } } }; }
|
|
19
|
-
|
|
20
13
|
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); }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
function _default(arr) {
|
|
25
16
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
17
|
if (!(0, _isNotEmpty2["default"])(arr)) return {};
|
|
@@ -31,14 +22,11 @@ function _default(arr) {
|
|
|
31
22
|
valround: !1
|
|
32
23
|
}, (0, _isNotEmpty3["default"])(opts) ? opts : {});
|
|
33
24
|
var map = {};
|
|
34
|
-
|
|
35
25
|
var _iterator = _createForOfIteratorHelper(arr),
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
_step;
|
|
38
27
|
try {
|
|
39
28
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
40
29
|
var el = _step.value;
|
|
41
|
-
|
|
42
30
|
if ((0, _is["default"])(el)) {
|
|
43
31
|
if (OPTS.keyround === !0) {
|
|
44
32
|
map[Math.round(el)] = OPTS.valround ? Math.round(el) : el;
|
|
@@ -58,6 +46,5 @@ function _default(arr) {
|
|
|
58
46
|
} finally {
|
|
59
47
|
_iterator.f();
|
|
60
48
|
}
|
|
61
|
-
|
|
62
49
|
return map;
|
|
63
50
|
}
|