Skip to content

Node module for incrementing alphanumeric strings.

License

Notifications You must be signed in to change notification settings

ltegman/alpha-inc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alphanumeric Increment (alpha-inc)

Alphanumeric Increment is a simple node module for incrementing alphanumeric strings (ie. 'a0B' => 'a0C'). Useful for things like URL shorteners or anything else that could make use of incrementing strings. The incrementation order is 0-9 then a-z then A-Z. It will automatically add a new character if required. There is an optional second argument that is an array of blacklisted strings it must skip.

Usage

const alpha = require('alpha-inc');

alpha.next('1lg');
// returns: '1lh'

alpha.next('ZZ');
// returns: '000'

// Bad input
alpha.next('f*b');
// returns: null

// with blacklist
alpha.next('a', ['b', 'c']);
// returns: 'd'

alpha.next('abous', ['about']);
// returns: 'abouu'

Contributors

Want to add decrementing or fix something? I welcome PRs! Please just add tape tests for any new features you add in test/alpha-inc.spec.js

Running tests

Run tests with npm run test.

License

Licensed under the terms of the MIT license.

About

Node module for incrementing alphanumeric strings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published