@foxtware/mineral 0.1.34 → 0.1.35
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 +21 -0
- package/package.json +1 -1
package/api/utils.js
CHANGED
|
@@ -1494,6 +1494,26 @@ 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
|
+
};
|
|
1516
|
+
|
|
1497
1517
|
module.exports = {
|
|
1498
1518
|
wait,
|
|
1499
1519
|
timeMs,
|
|
@@ -1539,4 +1559,5 @@ module.exports = {
|
|
|
1539
1559
|
diffObjects,
|
|
1540
1560
|
objectPropsTranslate,
|
|
1541
1561
|
randomArrayItem,
|
|
1562
|
+
oneTrickProcessor,
|
|
1542
1563
|
};
|