1.0.4 • Published 5 months ago

keycrafter v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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.

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago