Module @distributedlab/tools

@distributedlab/tools

These packages aim to provide developers with a set of commonly used functions and features for building web applications, such as handling big numbers, date manipulation, subscribing to and receiving notifications when certain events occur with EventEmitter, and more.

version (scoped package) types tree-shaking checks

Getting Started

Installing

yarn add @distributedlab/tools

Work with big numbers

BN uses 26 (yoctoNEAR + 2 (percent precision)) maximum precision by default. You can change it by BN.setConfig method.

import { BN } from '@distributedlab/tools';

const amountA = BN.fromRaw(2, 18)
const amountB = BN.fromRaw(3, 18)

console.log(amountA.add(amountB).format({
decimals: 18,
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3,
}))

Work with dates

import { time } from '@distributedlab/tools';

const currentDate = time()

console.log(currentDate.format('YYYY-MM-DD'))

Running the tests

yarn test

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Index

Enumerations

Classes

Type Aliases

Functions

Generated using TypeDoc