Skip to content
bhsd edited this page Mar 19, 2024 · 2 revisions

This is an internal document. For visitors, you can now go back to the home page.

// Ranges (main)
var {Range, Ranges} = require('../lib/ranges');
var ranges, target;
assert.deepStrictEqual([...new Ranges(2)], [2]);
assert.deepStrictEqual([...new Ranges(' ')], []);
assert.deepStrictEqual([...new Ranges('2')], [2]);
assert.deepStrictEqual([...new Ranges(1.5)], []);
assert.deepStrictEqual([...new Ranges('1.5')], []);
assert.deepStrictEqual([...new Ranges('1:2')], [new Range('1:2')]);
assert.deepStrictEqual([...new Ranges('-n+3')], [new Range('-n+3')]);
ranges = new Ranges([-100, ' ', '-2', 1.5, '1.5', '8:9', '-n+3']);
target = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert.deepStrictEqual(
	[...ranges],
	[-100, -2, new Range('8:9'), new Range('-n+3')],
);
assert.deepStrictEqual(ranges.applyTo(target), [0, 1, 2, 3, 8]);
Clone this wiki locally