Skip to content

A node.js library that allows simple incrementing for arbitrary sequences e.g. AA=>AB or 09=>10

Notifications You must be signed in to change notification settings

AppWorkshop/incrementer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Incrementer

Build Status

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

  1. Number system: "0123456789", length: 2, pad with: "0"

    00 => 01
    99 => 00
    
  2. Number system: "ABCD", length: 2

    AA => AB
    AD => BA
    
  3. Number system: "0123456789ABCDEF", length: 2, pad with: "0"

    0F => 10
    0E => 0F
    99 => 9A
    
  4. Number system: "@%&*", length: 2, pad with "@"

    @@ => @%
    &* => %@
    ** => @@
    
  5. Number system: "ABCD", length: 2

    AA => AB
    AD => BA
    

API

See API.md

About

A node.js library that allows simple incrementing for arbitrary sequences e.g. AA=>AB or 09=>10

Resources

Stars

Watchers

Forks

Packages

No packages published