magic-increment
v0.1.0
Published
Incrementation and decrementation for strings.
Downloads
22
Maintainers
Readme
magic-increment
Incrementation and decrementation for strings.
Installation
In Browser:
<script src="magic-increment.js"></script>
or
<script src="magic-increment.min.js"></script>
Object MagicIncrement will defined in the global scope.
In Node.js:
npm install magic-increment
var MagicIncrement = require('magic-increment');
bower:
bower install magic-increment
inc
- {string} MagicIncrement.inc ( value )
Increment the argument value.
This incrementation uses alphabets [a-z] + [A-Z] and digits [0-9].
@param {string} value The value to increment.
@return {string} Return the incremented value.
console.log(MagicIncrement.inc('99')); // '100'
console.log(MagicIncrement.inc('zz')); // 'aaa'
console.log(MagicIncrement.inc('a0')); // 'a1'
console.log(MagicIncrement.inc('Az')); // 'Ba'
var s = 'X';
for (var i = 0; i < 10; i++) {
s = MagicIncrement.inc(s);
console.log(s);
}
// Y
// Z
// AA
// AB
// AC
// AD
// AE
// AF
// AG
// AH
dec
- {string} MagicIncrement.dec ( value )
Decrement the argument value.
This decrementation uses alphabets [a-z] + [A-Z] and digits [0-9].
@param {string} value The value to decrement.
@return {string} Return the decremented value.
console.log(MagicIncrement.dec('100')); // '99'
console.log(MagicIncrement.dec('aaa')); // 'zz'
console.log(MagicIncrement.dec('a1')); // 'a0'
console.log(MagicIncrement.dec('Ba')); // 'Az'
var s = 'AC';
for (var i = 0; i < 10; i++) {
s = MagicIncrement.dec(s);
console.log(s);
}
// AB
// AA
// Z
// Y
// X
// W
// V
// U
// T
// S
Demo
Test for Magic Increment (Demo)
License
MIT