INNER CODE UNIT · TypeScript
normalizeArpOrder
scribbletune/scribbletune · src/cli.ts:113
const normalizeArpOrder = (order: string): string => {
if (!/^\d+$/.test(order)) {
throw new TypeError('Invalid value for --order');
}
// Backward-compatible: if user already uses zero-based (contains 0), keep as is.
if (order.includes('0')) {
return order;
}
// One-based shorthand (e.g. 1234, 2143) mapped to arp()'s zero-based indices.
return order
.split('')
.map(ch => {
const n = Number(ch);
if (n < 1) {
throw new TypeError('Invalid value for --order');
}