You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Produces a unique value that sorts between two other given values.
background
This module makes it easy to select a unique value between any two bisecting
numbers, where there are always unique values between any two such numbers. Read
more about bisecting numbers
here.
This module is inspired by Dominic Tarr's
between module. This module aims to
offer an equivalent API with the same key property of being commutative (i.e.
inserting between two items does not change the positions of nodes later in a
created list).
between is great, but the length of the identifier in the case of consecutive appends
and prepends is very expensive, growing linearly:
V
zy
zzzs
zzzzzV
zzzzzzy
zzzzzzzzs
zzzzzzzzzzV
zzzzzzzzzzzy
zzzzzzzzzzzzzs
zzzzzzzzzzzzzzzV
bisecting-between optimizes for minimizing the growth of string
length in the append and prepend cases, growing logarithmically:
0
A
K
U
e
o
y
18
1I
1S
This trade-off makes random insertions more growth expensive instead. In
certain applications (like text editors), long appends and prepends are far more
common.
Returns a function (that generates values between two other values) across the
given string alphabet (where alphabet.charAt(0) is the zero value, the next
is 1, etc). If not provided, the alphabet is the string
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
between(lo, hi)
Returns a bisecting number that
is between two other bisecting numbers that will always sort as between lo and
hi.
between.lo, between.hi
Fixed values that symbolize the absolute lowest and highest, respectively.