incstr
Increment strings or generate sequential string ids in node.js or browser
Usage
incstr
``` nextStr = incstr(str,[alphabet=incstr.alphabet],
[numberlike=incstr.numberlike])
```
str
- string to increment;
alphabet
- alphabet to use (default'A..Za..z0..9'
);
numberlike
-'BA'
after'9'
instead of'AA'
(defaultfalse
);
- default
alphabet
can be set throughincstr.alphabet
;
- default value for
numberlike
can be set throughincstr.numberlike
;
- works with strings of any length.
incstr.idGenerator
``` nextId = incstr.idGenerator(options) id = nextId() // real generator would be too bulky "nextId.next().value" ``` Possible options:options.lastId
;
options.alphabet
;
options.numberlike
;
options.prefix
;
options.suffix
.
lastId
can also be accessed later through nextId.lastId
property.
Note that nextId()
is much faster than incstr()
and safer because it verifies uniqueness of chars in the alphabet.