between2
is fork ofbetween
$ npm install --save between2
const between = require('between');
const tween = between('a', 'b');
//tween is a string that will sort between 'a' and 'b'.
a
and b
can be any string that does not end in the lowest character.
this is like how there is only one number between 0 and 1 that ends in a "0".
NOTE: By default, the following characters are used to generate the string:
!0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
Generate string that sorts between a
and between.hi
.
Generate string that sorts between between.lo
and a
.
Trim between.lo
characters to the right of a
.
Compares two strings, a
and b
, lexicographically. Returns 0
if a == b
; -1
if a
is lexicographically less than b
; 1
if a
is lexicographically greater than b
.
Generate random string with length len
using chars
. Expects len >= 0
.
NOTE: The string's last character will never be either the between.lo
character or the between.hi
character for chars
of size greater than two. This is intended so that this string, a
, may be used as a reference point to generate strings that will be able to sort between a
and any other string distinct from a
. For chars
of size 2, the between.hi
character will be used.
Create instance of between
using characters from chars
.
NOTE: It's expected that chars
is at least 2 distinct characters long.
the top most string possible, and the lowest string possible. You must not be used as positions for items, because it will not be possible to insert items after or before them. These values represent the space infront of the first item, and the space between the last item.
Cheers to @dominictarr who created the original between
module.
MIT