cafe-utility 1.40.0 → 1.41.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/index.js +16 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1364,6 +1364,20 @@ const countUnique = (array, mapper, plain, sort, reverse) => {
|
|
|
1364
1364
|
|
|
1365
1365
|
const sortObjectValues = (object, compareFn) => Object.fromEntries(Object.entries(object).sort(compareFn))
|
|
1366
1366
|
|
|
1367
|
+
const transformToArray = objectOfArrays => {
|
|
1368
|
+
const array = []
|
|
1369
|
+
const keys = Object.keys(objectOfArrays)
|
|
1370
|
+
const length = objectOfArrays[keys[0]].length
|
|
1371
|
+
for (let i = 0; i < length; i++) {
|
|
1372
|
+
const object = {}
|
|
1373
|
+
for (const key of keys) {
|
|
1374
|
+
object[key] = objectOfArrays[key][i]
|
|
1375
|
+
}
|
|
1376
|
+
array.push(object)
|
|
1377
|
+
}
|
|
1378
|
+
return array
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1367
1381
|
module.exports = {
|
|
1368
1382
|
Random: {
|
|
1369
1383
|
inclusiveInt: randomIntInclusive,
|
|
@@ -1471,7 +1485,8 @@ module.exports = {
|
|
|
1471
1485
|
setSomeOnObject,
|
|
1472
1486
|
flip,
|
|
1473
1487
|
crossJoin,
|
|
1474
|
-
countTruthyValues
|
|
1488
|
+
countTruthyValues,
|
|
1489
|
+
transformToArray
|
|
1475
1490
|
},
|
|
1476
1491
|
Pagination: {
|
|
1477
1492
|
asPageNumber,
|