https://github.com/polygonplanet/magic-increment
Incrementation and decrementation for strings.
https://github.com/polygonplanet/magic-increment
Last synced: 4 months ago
JSON representation
Incrementation and decrementation for strings.
- Host: GitHub
- URL: https://github.com/polygonplanet/magic-increment
- Owner: polygonplanet
- License: mit
- Created: 2015-03-21T12:51:02.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-21T13:26:46.000Z (over 11 years ago)
- Last Synced: 2026-01-23T12:33:05.305Z (5 months ago)
- Language: JavaScript
- Size: 168 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
magic-increment
===============
[](https://travis-ci.org/polygonplanet/magic-increment)
Incrementation and decrementation for strings.
### Installation
#### In Browser:
```html
```
or
```html
```
Object **MagicIncrement** will defined in the global scope.
#### In Node.js:
```bash
npm install magic-increment
```
```javascript
var MagicIncrement = require('magic-increment');
```
#### bower:
```bash
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.
```javascript
console.log(MagicIncrement.inc('99')); // '100'
console.log(MagicIncrement.inc('zz')); // 'aaa'
console.log(MagicIncrement.inc('a0')); // 'a1'
console.log(MagicIncrement.inc('Az')); // 'Ba'
```
```javascript
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.
```javascript
console.log(MagicIncrement.dec('100')); // '99'
console.log(MagicIncrement.dec('aaa')); // 'zz'
console.log(MagicIncrement.dec('a1')); // 'a0'
console.log(MagicIncrement.dec('Ba')); // 'Az'
```
```javascript
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)](http://polygonplanet.github.io/magic-increment/tests/magic-increment-test.html)
### License
MIT