inline chunk.js
This commit is contained in:
@@ -22,14 +22,14 @@ exports = module.exports = {
|
||||
|
||||
// Used to mock AWS
|
||||
_mockInject: mockInject,
|
||||
_mockRestore: mockRestore
|
||||
_mockRestore: mockRestore,
|
||||
_chunk: chunk
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
async = require('async'),
|
||||
AwsSdk = require('aws-sdk'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
chunk = require('../chunk.js'),
|
||||
constants = require('../constants.js'),
|
||||
DataLayout = require('../datalayout.js'),
|
||||
debug = require('debug')('box:storage/s3'),
|
||||
@@ -406,6 +406,21 @@ async function remove(apiConfig, filename) {
|
||||
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unable to remove ${deleteParams.Key}. error: ${error.message}`);
|
||||
}
|
||||
|
||||
function chunk(array, size) {
|
||||
assert(Array.isArray(array));
|
||||
assert.strictEqual(typeof size, 'number');
|
||||
|
||||
const length = array.length;
|
||||
if (!length) return [];
|
||||
let index = 0, resIndex = 0, result = Array(Math.ceil(length / size));
|
||||
|
||||
for (; index < length; index += size) {
|
||||
result[resIndex++] = array.slice(index, index+size);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function removeDir(apiConfig, pathPrefix, progressCallback) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert.strictEqual(typeof pathPrefix, 'string');
|
||||
|
||||
Reference in New Issue
Block a user