Skip to content

Reverse character ID is a sequential and predictable ID generator with its specific algorithm.

License

Notifications You must be signed in to change notification settings

arvinall/reverse-char-id

Repository files navigation

Typescript Standard Code Style GitHub

GitHub package.json version npm npm bundle size npm

GitHub issues GitHub closed issues GitHub pull requests GitHub closed pull requests

Reverse Char ID

API Reference

Reverse character ID is a sequential and predictable ID generator with its specific algorithm.

Table of Contents

Examples

char 0 to 9 . char a to z . char z to x
. .
0 1 2 3 . a b c d . z y x zz
4 5 6 7 . e f g h . zy zx yz yy
8 9 00 01 . i j k l . yx xz xy xx
02 03 04 05 . m n o p . zzz zzy zzx zyz
char 9 to 7 . chars 7 > 9 to a > c . char c > a to 9 > 7
. .
9 8 7 99 . 7 8 9 a . c b a 9
98 97 89 88 . b c 77 78 . 8 7 cc cb
87 79 78 77 . 79 7a 7b 7c . ca c9 c8 c7
999 998 997 989 . 87 88 89 8a . bc bb ba b9

Usage

Visit complete API reference

*This package export its API over CommonJS pattern.

Install

$ npm install reverse-char-id

Example

// Import with bundler ...
import {
  REVERSED_PREDEFINED_RANGES,
  PREDEFINED_RANGES,

  ReverseCharID
} from 'reverse-char-id'

// OR

// Import without bundler
const {
  REVERSED_PREDEFINED_RANGES,
  PREDEFINED_RANGES,

  ReverseCharID
} = require('reverse-char-id')
const reverseCharID = new ReverseCharID() // Default character range: 0 to 9

console.log(
  `${reverseCharID}`,
  reverseCharID.toString(),
  reverseCharID.toValue(),
  String(reverseCharID)
) // 0 1 2 3
const reverseCharID = new ReverseCharID({
  ranges: [
    REVERSED_PREDEFINED_RANGES['z to a'],
    PREDEFINED_RANGES['0 to 9']
  ],
  lastID: 'c'
})

console.log(
  `${reverseCharID}`,
  reverseCharID.toString(),
  reverseCharID.toValue(),
  String(reverseCharID)
) // b a 0 1

License

MIT License

Author

Arvin Ladan (arvinall)