20 lines
596 B
JavaScript
20 lines
596 B
JavaScript
const fs = require('fs');
|
|
|
|
function batchAccounts(accounts, batchSize) {
|
|
const sortedDir = '../accounts/sorted';
|
|
if (!fs.existsSync(sortedDir)) {
|
|
fs.mkdirSync(sortedDir);
|
|
}
|
|
|
|
for (let i = 0; i < accounts.length; i += batchSize) {
|
|
const batch = accounts.slice(i, i + batchSize);
|
|
const batchNumber = Math.ceil((i + 1) / batchSize);
|
|
const batchFilename = `${sortedDir}/batch${batchNumber}.json`;
|
|
fs.writeFileSync(batchFilename, JSON.stringify(batch, null, 2));
|
|
}
|
|
}
|
|
|
|
const accounts = require('../accounts/accounts.json');
|
|
batchAccounts(accounts, 6);
|
|
|
|
module.exports = { batchAccounts }; |