Skip to content

Generate various pseudo-random codes or dependency-based codes more easily.

Notifications You must be signed in to change notification settings

eduhund/keycrafter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Key Crafter

Small, zero-dependency library for quick generation of some kind of keys.

Support & Donation

Our team creates fully open-source tools and solutions for developers, designers, and those who teach these subjects. You can help us: share this tool, contribute to it, or donate to us to support future work.

Donate

Install

Just add the NPM package to your program:

npm i keycrafter

Use

Import necessary functions to your module. Supports CommonJS "require" & ESM "import" For example:

const { generateKey } = require("keycrafter")

or

import { generateKey } from "keycrafter"

Then call the function:

const key = generateKey()

Functions

generateKey

Receive no arguments or option object with several parameters

type

Now library can generate two types of codes: digit (default) and string.

length

Only positive integers are supported. The max value for the digit is 16, for the string – 32.

Default options

Function cat receives no arguments. In this way, the key will be generated with the parameters:

  • type: "digit" (only digit symbols will be presented)
  • length: 4. For example, 0000

If any of the options parameters won't be presented in options, the default one will be passed.

Return

The function returns a string (regardless of type) with the new key.

Error handling

The module provides an error, when something goes wrong. You can catch this error in handling the pattern you choose in the project.

About

Generate various pseudo-random codes or dependency-based codes more easily.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published