Options
All
  • Public
  • Public/Protected
  • All
Menu

@thermopylae/lib.utils

@thermopylae/lib.utils

Version Node Version Documentation License: MIT

Utility functions.

Install

npm install @thermopylae/lib.utils

Description

This package contains a collection of utility functions grouped into different categories, such as chrono, string, token, array etc.

Usage

Bellow is a simple example of how this module can be used:

import { array, number, chrono, string } from '@thermopylae/lib.utils';

const randomOffsets = array.filledWith(10, () => {
    return number.randomInt(0, 10);
});

const timestamps = randomOffsets.map((offset) => {
    return chrono.unixTime() + offset;
});

const randomUniqueStrings = array.filledWith(10, () => {
    return string.random({ allowedCharRegex: /[a-z0-9]/ });
}, { noDuplicates: true });

API Reference

API documentation is available here.

It can also be generated by issuing the following commands:

git clone git@github.com:marinrusu1997/thermopylae.git
cd thermopylae
yarn install
yarn workspace @thermopylae/lib.utils run doc

Run tests

In the cloned repository run the following command:

yarn workspace @thermopylae/lib.utils run test

Author

👤 Rusu Marin

📝 License

Copyright © 2021 Rusu Marin.
This project is MIT licensed.