1.0.5 • Published 2 years ago

@alg-mapper/string-tools v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@alg-mapper/string-tools

@alg-mapper/string-tools is a package that provides easy-to-use string tools, such as generating unique IDs and random strings.

Installation

To install the package, run the following command:

npm install @alg-mapper/string-tools

Usage

Here's an example of how to use it..

const { string } = require('@alg-mapper/string-tools');
const tools = string();

// generate a unique string with numbers.

console.log(tools.generateUniqueString(10)); // { value: 'dP9HD4Wg7V' }

// generate a random id with options

let options = { 
numbers: true, 
special: false 
};

console.log(tools.generateRandomID(10, options)); // { value: 'U1mm3PgK30' }

// generate a random string

console.log(tools.generateRandomString(10, { from:"zxcvbnmasdfghjklqwertyuui" })); // { value: 'rzcuseewmi' }

Options and functions

FunctionOptionTypeDefaultDescription
generateUniqueString()capsbooleantrueIf true, the generated ID may contain capital letters.
generateUniqueString()ignoreLengthErrorbooleanfalseIf true, it will ignore the length error.
generateRandomID()numbersbooleanfalseIf true, the generated ID will include numbers.
generateRandomID()specialbooleantrueIf true, the generated ID will include special characters like !@#$%.
generateRandomID()strongbooleanfalseIf true, the generated ID will be made stronger with some random numbers from timestamp.
generateRandomID()capsbooleantrueIf true, the generated ID may contain capital letters.
generateRandomString()fromstring"abcdefghijklmnopqrstuvwxyz"generate random string from the given value
generateRandomString()ignoreLengthErrorbooleanfalseIf true, it will ignore the length error.
šŸš€ More helpful functions are on the way! 
šŸŽ‰ This package was originally created for personal use, but I decided to share it with the world. 
🌟 Stay tuned for more awesome new functions!
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago