mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 15:26:17 +00:00
28 lines
547 B
JavaScript
28 lines
547 B
JavaScript
const through = require('./through');
|
|
const sortBy = require('lodash/sortBy');
|
|
|
|
function sleep (ms) {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
}
|
|
|
|
module.exports = exports = function (iteratees) {
|
|
var files = [];
|
|
|
|
return through(
|
|
async (stream, file) => {
|
|
if (file.isNull()) return;
|
|
|
|
files.push(file);
|
|
},
|
|
async (stream) => {
|
|
const queue = sortBy(files, iteratees);
|
|
files = null;
|
|
|
|
for (const file of queue) {
|
|
stream.push(file);
|
|
await sleep(100);
|
|
}
|
|
}
|
|
);
|
|
};
|