letters
v0.0.2
Published
A sequential letter handler
Downloads
8
Maintainers
Readme
letters
Iterate through sequences that include letters.
Installation
npm install --save letters
Usage
var Letters = require('letters');
var letters = new Letters(/*options*/)
console.log(letters.next()); // "a"
console.log(letters.next()); // "b"
// . . .
console.log(letters.next()); // "z"
console.log(letters.next()); // "aa"
Options
Some things are configurable via the options object.
useNumbers
Include numbers in the sequence (default is false). By default, when this option is provided, numbers are included after the letters.
var Letters = require('letters');
var letters = new Letters({ useNumbers: true })
console.log(letters.next()); // "a"
console.log(letters.next()); // "b"
// . . .
console.log(letters.next()); // "z"
console.log(letters.next()); // "0"
numbersFirst
Include numbers and place them before letters. useNumbers
is implied by specifying this option, so you don't need both.
var Letters = require('letters');
var letters = new Letters({ numbersFirst: true })
console.log(letters.next()); // "0"
console.log(letters.next()); // "1"
// . . .
console.log(letters.next()); // "9"
console.log(letters.next()); // "a"
// . . .
console.log(letters.next()); // "z"
console.log(letters.next()); // "00"
startAt
By default, the sequence begins with the first character ("a" normally, or "0" with numbersFirst
), but you can force the sequence to begin at any point, even at a multi-letter sequence.
var Letters = require('letters');
var letters = new Letters({ startAt: 'abc' })
console.log(letters.next()); // "abc"
console.log(letters.next()); // "abd"
Contributing
I'll be happy to merge any pull request that adds value and has passing tests. Tests are run with grunt
.