Open jschuur opened 2 years ago
I ended up throwing together a little custom script to do this:
function main(state) {
const lines = state.text.split('\n');
const output = lines
.filter(line => line.trim() !== '')
.map((line) => ` ${(Number.isNaN(Number.parseFloat(line)) ? `'${line}'` : Number.parseFloat(line))}`)
.join(',\n');
state.fullText = `[\n${output}\n]`;
state.postInfo(`${lines.length} array items converted`);
}
This also checks if something is a string or a number and preserves the type too.
Turing a block of text into an array where each line is an element would be useful.
I currently use https://arraythis.com/ for that.