class VL {
constructor(len) {
if (!Number.isSafeInteger(len)) throw 0
this.len = len
Object.freeze(this)
}
get length() { return this.len }
toString() { return ' '.repeat(this.len) }
slice(x, y) {
if (!((x == null || x >= 0) &&
(y == null || y >= 0))) {
throw new RangeError('Negative slices are unimplemented')
}
if (x == null) return this
if (y == null || y > this.len) return VL.of(Math.max(0, this.len - x))
return VL.of(y - x)
}
static interned = {}
static {
for (let i = 0; i < 16; i++) {
this.interned[i] = new VL(i)
}
}
static of(len) {
if (len < 0) {
throw new RangeError('Negative lengths are disallowed')
}
if (len < 16) { return VL.interned[len] }
return new VL(len)
}
}