export function range(...args) { let start, end, step; if (args.length === 1) { start = 0; end = args[0]; step = 1; } else if (args.length === 2) { [start, end] = args; step = 1; } else { [start, end, step] = args; } // Return a list of numbers in the range [start, end) const list = []; for (let i = start; i < end; i += step) { list.push(i); } return list; } export function argsort(list) { return list.map((_, i) => i).sort((a, b) => list[a] - list[b]); } export function offerFile(filename, content, type = 'text/plain') { const a = document.createElement('a'); a.href = URL.createObjectURL(new Blob([content], { type: type })); a.download = filename; a.click(); } const Utils = { range, offerFile, argsort }; export default Utils;