abcq

Generates character combinations from numbers: `a b c ... aa ab ac ... foo fop foq`

MIT 13 个版本
安装
npm install abcq
yarn add abcq
pnpm add abcq
bun add abcq
README

abcq

Generates character combinations from numbers: a b c ... aa ab ac ... foo fop foq

npm

  • Convert numbers to character combinations.
  • Count by character combination
  • Create unique ids
  • Create simple hashes
npm i abcq
## or
yarn add abcq

Basic usage

import Abcq from "abcq";
const shortid = new Abcq();

shortid.generate();
// -> a
shortid.generate();
// -> b
shortid.encode(1234567890);
// -> clRjXk
shortid.decode("clRjXk");
// -> 1234567890

When unicorns make love

Use an Array for chars if it contains special characters. Set the counter to modify the start point

import Abcq from "abcq";

const unicornLove = new Abcq({
	chars: ["🦄", "💖"],
	counter: 42
});

unicornLove.generate();
// -> 🦄💖💖🦄💖
unicornLove.encode(8);
// -> 🦄💖🦄

Options

chars

  • type: { string[] | string }
  • default: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

counter

  • type: { number }
  • default: -1

Methods

generate

import Abcq from "abcq";
const abc = new AbcQ();
abc.generate();
// -> a
abc.generate();
// -> b

encode

import Abcq from "abcq";
const abc = new AbcQ();
abc.encode(1234567890);
// -> clRjXk

decode

import Abcq from "abcq";
const abc = new AbcQ();
abc.decode("clRjXk");
// -> 1234567890
版本列表
1.0.2 2018-09-24
1.0.1 2018-09-24
1.0.0 2018-09-24
0.2.2 2016-09-22
0.2.1 2016-09-15
0.2.0 2016-09-10
0.1.7 2016-09-09
0.1.6 2016-09-09
0.1.5 2016-09-09
0.1.4 2016-09-09
0.1.2 2016-09-09
0.1.1 2016-09-09
0.1.0 2016-09-09