|
|
|
|
@ -126,6 +126,29 @@ var download = {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getBundles(array, keymapper, size = 50) {
|
|
|
|
|
let byKey = array.reduce((result, item) => {
|
|
|
|
|
let key = keymapper(item),
|
|
|
|
|
items = result[key];
|
|
|
|
|
if (!items)
|
|
|
|
|
result[key] = items = [];
|
|
|
|
|
items.push(item);
|
|
|
|
|
return result;
|
|
|
|
|
}, {}),
|
|
|
|
|
bundle = [];
|
|
|
|
|
bundles = [];
|
|
|
|
|
for (let items of Object.values(byKey)) {
|
|
|
|
|
bundle = bundle.concat(items);
|
|
|
|
|
if (bundle.length < size) continue;
|
|
|
|
|
|
|
|
|
|
bundles.push([].concat(bundle));
|
|
|
|
|
bundle.splice(0);
|
|
|
|
|
}
|
|
|
|
|
if (bundle.length > 0)
|
|
|
|
|
bundles.push(bundle);
|
|
|
|
|
return bundles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function upload(options) {
|
|
|
|
|
options.enctype = "multipart/form-data";
|
|
|
|
|
options.processData = options.contentType = false;
|
|
|
|
|
|