number-sequence
v1.0.2
Published
Allows simple incrementing for arbitrary sequences e.g. AA=>AB or 09=>10
Downloads
220
Readme
Incrementer
A simple library that lets you define your own number sequence using arbitrary characters.
Installation
Usage
let incrementer = require('number-sequence');
let numsys = "0ABCDEF";
let padChar = "0";
let length = 2;
let result = incrementer.increment(numsys, incrementer.padNumberToLength("E",length,padChar); // 0E => 0F
// OR:
result = incrementer.padAndIncrement(numsys, "E", length, padChar); // 0E => 0F
let scope = incrementer.calculateNumberOfValues(numsys,2); // number of possible values === 7^2 => 49
Examples
Number system: "0123456789", length: 2, pad with: "0"
00 => 01 99 => 00
Number system: "ABCD", length: 2
AA => AB AD => BA
Number system: "0123456789ABCDEF", length: 2, pad with: "0"
0F => 10 0E => 0F 99 => 9A
Number system: "@%&*", length: 2, pad with "@"
@@ => @% &* => %@ ** => @@
Number system: "ABCD", length: 2
AA => AB AD => BA
API
See API.md