Skip to content

Instantly share code, notes, and snippets.

@AkimaLunar
Last active November 29, 2021 22:48
Show Gist options
  • Save AkimaLunar/7b5d4a29d94786e9f2cdf2a6fe699b5c to your computer and use it in GitHub Desktop.
Save AkimaLunar/7b5d4a29d94786e9f2cdf2a6fe699b5c to your computer and use it in GitHub Desktop.
Large array generator
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