https://github.com/pixelass/abcq
https://github.com/pixelass/abcq
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/pixelass/abcq
- Owner: pixelass
- License: mit
- Created: 2019-06-28T12:35:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-06T08:00:01.000Z (almost 5 years ago)
- Last Synced: 2025-04-08T17:52:36.901Z (over 1 year ago)
- Language: TypeScript
- Size: 605 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# abcq
Generates character combinations from numbers: `a b c ... aa ab ac ... foo fop foq`
[](https://www.npmjs.com/package/abcq)
- Convert numbers to character combinations.
- Count by character combination
- Create unique ids
- Create simple hashes
```shell
npm i abcq
## or
yarn add abcq
```
## Basic usage
```js
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
```js
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`
```js
import Abcq from "abcq";
const abc = new AbcQ();
abc.generate();
// -> a
abc.generate();
// -> b
```
### `encode`
```js
import Abcq from "abcq";
const abc = new AbcQ();
abc.encode(1234567890);
// -> clRjXk
```
### `decode`
```js
import Abcq from "abcq";
const abc = new AbcQ();
abc.decode("clRjXk");
// -> 1234567890
```