Sequid
A tiny tool to produce sequential numeric IDs.
;; ; assert.strictEqualseq.next.value, 1;assert.strictEqualseq.next.value, 2;assert.strictEqualseq.next.value, 3; ; assert.strictEqualseq2.next.value, Number.MAX_SAFE_INTEGER - 2;assert.strictEqualseq2.next.value, Number.MAX_SAFE_INTEGER - 1;assert.strictEqualseq2.next.value, Number.MAX_SAFE_INTEGER;assert.strictEqualseq2.next.value, undefined; ; assert.strictEqualseq3.next.value, Number.MAX_SAFE_INTEGER - 2;assert.strictEqualseq3.next.value, Number.MAX_SAFE_INTEGER - 1;assert.strictEqualseq3.next.value, Number.MAX_SAFE_INTEGER;assert.strictEqualseq3.next.value, Number.MAX_SAFE_INTEGER - 2; console.log"#### OK ####";
API
If offset
is provided, the sequence will produce the first id started from the
next number of the offset. If the id reaches Number.MAX_SAFE_INTEGER
, judging
by the loop
argument, the iterator may restart from the very offset, or break
the sequence and quit iterating.