mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 10:56:36 +00:00
27 lines
392 B
JavaScript
27 lines
392 B
JavaScript
'use strict';
|
|
|
|
const pMap = require('p-map');
|
|
const { curry } = require('lodash/fp');
|
|
|
|
function pipeAsync(...methods) {
|
|
return async (data) => {
|
|
let res = data;
|
|
|
|
for (const method of methods) {
|
|
res = await method(res);
|
|
}
|
|
|
|
return res;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @type { import('./async').MapAsync }
|
|
*/
|
|
const mapAsync = curry(pMap);
|
|
|
|
module.exports = {
|
|
mapAsync,
|
|
pipeAsync,
|
|
};
|