Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.
/ incrementr Public archive

Increments an identifier string. (Abandoned)

License

Notifications You must be signed in to change notification settings

xyfir/incrementr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Increment identifier strings.

If all character ranges are allowed, identifier strings are incremented in the following order: 0 through 9 to A through Z to a through z and back to 0. When all characters in the string are z, all the characters are reset to 0 and another 0 is added to the end of the string. If a certain character range is not allowed, then that range is skipped. For example Z will go to 0 if lowercase letters are not allowed and z will go to a if only lowercase letters are allowed.

Usage

const increment = require('incrementr');

increment();
// '1'
increment('ABZ');
// 'ABa'
increment('ABz');
// 'AC0'
increment('TEST9');
// 'TESTA'
increment('HELLO');
// 'HELLP'
increment('zzz');
// '0000'

increment('9', { characters: { numbers: true, lowercase: true } });
// 'a'
increment('Z', { characters: { uppercase: true } });
// 'AA'

increment('!');
increment('ABC9', { characters: { lowercase: true } });
increment('a99', { characters: { uppercase: true, numbers: true } });
// All throw errors because identifier does not match pattern

Releases

No releases published

Packages

No packages published