Last active
November 29, 2021 22:48
-
-
Save AkimaLunar/7b5d4a29d94786e9f2cdf2a6fe699b5c to your computer and use it in GitHub Desktop.
Large array generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const createArray = ({ length }) => Array.from({ length }, (_, i) => i + 1); // [1, 2, 3, ...] | |
const createLargeArray = (length = 100) => ( | |
Array.from(Array(length)).map(() => Math.random() * 10) | |
) | |
const string = `module.exports = [${[...createLargeArray(), 122]}]` | |
fs.writeFile('largeArray.js', string, (error => { | |
if (error) throw error | |
console.log('Created a large array!') | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment