Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weihongyu12/think-hashids
Generate a short unique ID from the integer for ThinkJS
https://github.com/weihongyu12/think-hashids
Last synced: 3 months ago
JSON representation
Generate a short unique ID from the integer for ThinkJS
- Host: GitHub
- URL: https://github.com/weihongyu12/think-hashids
- Owner: weihongyu12
- License: mit
- Created: 2017-10-15T15:39:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:35:06.000Z (almost 2 years ago)
- Last Synced: 2024-07-07T01:02:26.519Z (4 months ago)
- Language: JavaScript
- Size: 1.42 MB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-hashids
README
# think-hashids
[![npm](https://img.shields.io/npm/v/think-hashids.svg)](https://www.npmjs.com/package/think-hashids)
[![Build Status](https://travis-ci.org/weihongyu12/think-hashids.svg?branch=master)](https://travis-ci.org/weihongyu12/think-hashids)
[![Coverage Status](https://coveralls.io/repos/github/weihongyu12/think-hashids/badge.svg?branch=master)](https://coveralls.io/github/weihongyu12/think-hashids?branch=master)Generate a short unique ID from the integer for ThinkJS base on [hashids](http://hashids.org/)
## How to use
### Install
```bash
npm install think-hashids --save
```### Configure extends.js
```javascript
const hashids = require('think-hashids')module.exports = [
hashids({
salt: 'this is salt',
minLength: 10,
alphabet: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
})
];
```## Config
-salt
: Participate in the calculated salt. Default:''
-minLength
: The minimum length of the resulting result. Default:0
-alphabet
: Generates the resulting character set .Default:'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
## Method
-
this.encode(id)
: Encode ID
-this.decode(id)
: Decode ID
-this.encodeHex(id)
: Encode hex instead of numbers
-this.decodeHex(id)
: Decode hex instead of numbers