fast-key-generator
Simple utils library for API calls.
Instalation
fast-key-generator
- you can use npm
or yarn
package manager.
To install npm install fast-key-generator --save
yarn add fast-key-generator
Documentation
The fast-key-generator
library includes only one function generateKey
.
Below you can find the documentation for this function.
generateKey
function
The The simple method for key generation.
generateKey
function takes only one parameter, which is an object.
The options
parameter may includes the following fields:
The Name | Type | Default value | Description |
---|---|---|---|
size | number | 16 | Key size (without prefix). |
prefix | string | "" | Key prefix. |
chartype | string | "alpha" | Can be one of "alpha", "numeric", "alphanum", "symbols". |
chartset | string | "" | If you provide charset , then the generator will use the characters from this charset & ignore the chartype. |
transform | string or function | "none" | Can be one of "none", "lower", "upper" or custom function that takes a key as the first argument & should return formatted key. |
validate | function | empty function | If the function returns true, the generation process will be completed. If false, the generation process will start again until the function returns true. |
exclude | array of strings | [] | An array of strings that should not be keys. |
Examples
; const key = ;// The key will be a string with a length of 16
; const key = ; // The key will be "key_9"
; const key = ; // The key will be "key_2"