You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

incstr

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

incstr

Increment string or generate sequential string ids

Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
21K
-7.13%
Maintainers
1
Weekly downloads
 
Created
Source

incstr

Increment string or generate sequential string ids

Install: npm install incstr

Default alphabet is '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', it can be changed by changingincstr.alphabet.

Pass a string to increment using default alphabet:

let i = incstr() //"0"
i = incstr(i) //"1"
//...
i = incstr(i) //"Z"
i = incstr(i) //"00", note not "10"
i = incstr(i) //"01"

Pass a string and alphabet to use:

incstr("a", "ab") //"b"
incstr("b", "ab") //"aa"
incstr("ccc", "abc") //"aaaa"
incstr("cc", "ab") //throws ('c' is not in alphabet 'ab')

Generate ids:

let nextId = incstr.idGenerator({alphabet:'abc'})
nextId() //'a'
nextId() //'b'
nextId() //'c'
nextId() //'aa'

let nextId = incstr.idGenerator({alphabet:'ab', prefix:'id_', suffix:''})
nextId() //'id_a'
nextId() //'id_b'
nextId() //'id_aa'

let nextId = incstr.idGenerator({lastId:'cc', alphabet:'abc'})
nextId() //'aaa'

Keywords

increment

FAQs

Package last updated on 17 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts