@foxtware/mineral 0.1.34 → 0.1.36
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/api/utils.js +22 -0
- package/package.json +1 -1
package/api/utils.js
CHANGED
|
@@ -1494,6 +1494,27 @@ const randomArrayItem = (array) => {
|
|
|
1494
1494
|
return array[Math.floor(Math.random() * array.length)];
|
|
1495
1495
|
};
|
|
1496
1496
|
|
|
1497
|
+
const oneTrickProcessor = (
|
|
1498
|
+
func,
|
|
1499
|
+
pile,
|
|
1500
|
+
{
|
|
1501
|
+
responseHandler,
|
|
1502
|
+
...processorOptions
|
|
1503
|
+
} = {},
|
|
1504
|
+
) => {
|
|
1505
|
+
// Runs a single function, going through a pile that is args as an array
|
|
1506
|
+
const processor = new Processor(
|
|
1507
|
+
pile,
|
|
1508
|
+
async (pile) => {
|
|
1509
|
+
const args = pile.shift();
|
|
1510
|
+
const response = await func(...args);
|
|
1511
|
+
return responseHandler ? await responseHandler(response) : response;
|
|
1512
|
+
},
|
|
1513
|
+
processorOptions,
|
|
1514
|
+
);
|
|
1515
|
+
return processor;
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1497
1518
|
module.exports = {
|
|
1498
1519
|
wait,
|
|
1499
1520
|
timeMs,
|
|
@@ -1539,4 +1560,5 @@ module.exports = {
|
|
|
1539
1560
|
diffObjects,
|
|
1540
1561
|
objectPropsTranslate,
|
|
1541
1562
|
randomArrayItem,
|
|
1563
|
+
oneTrickProcessor,
|
|
1542
1564
|
};
|