This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

randts
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

:package: randts

📦 randts

Random number generator and utilities

Issues GitHub pull requests GitHub Downloads GitHub Total Downloads

Report Bug Request Feature

> Demo in NPM runkit

With this package, you can create Random Numbers and Timestamp Based Random Numbers with low probability of collision using strong randomized bytes as seeds. You can specify the min and max lengths (which will generate a random length between this values) or configure a specific length.

Installation

With npm:

npm install randts --save

With yarn:

yarn add randts

With pnpm:

pnpm add randts --save

With Git HTTPS:

git clone https://github.com/hebertcisco/randts.git

With Github Cli:

gh repo clone hebertcisco/randts

randts

How to use

To use the package just do as in the script below:

Configuring the random number generation

CJS

const { Configuration } = require('randts');
const randts = require('randts');

const NumberConfig = new Configuration();
NumberConfig.setMinLength(4);
NumberConfig.setMaxLength(randts.NumberLength.getMaxSafeLength());

Generates a random number

const { Generator, Configuration } = require('randts');

const NumberConfig = new Configuration();
const RandomNumber = new Generator(NumberConfig);
console.log('Random Number:');
console.log(RandomNumber.getNumber());
console.log('\n');
console.log('Random Number Value:', RandomNumber.getNumber().getValue());
console.log('\n');

Reconfiguring the random number generation

const randts = require('randts');
const { Configuration } = require('randts');

const NumberConfig = new Configuration();

NumberConfig.reset();
NumberConfig.timestampBased();
NumberConfig.setMinLength(15);
NumberConfig.setMaxLength(randts.NumberLength.getMaxSafeLength());

Generates a random number timestamp based

const randts = require('randts');
const { NumberConfig, Generator } = require('randts');

const RandomNumberTimestampBased = new Generator(NumberConfig);
console.log('Random Number timestamp based:');
console.log(RandomNumberTimestampBased.getNumber());

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Open in Gitpod

Show your support

Give a ⭐️ if this project helped you!

Or buy me a coffee 🙌🏾

📝 License

Copyright © 2022 Hebert F Barros.
This project is MIT licensed.

Package Sidebar

Install

npm i randts

Weekly Downloads

153

Version

0.1.1

License

MIT

Unpacked Size

20.8 kB

Total Files

15

Last publish

Collaborators

  • tecnobert