type-enforcer-math

An extension of type-enforcer with Math related data types and enforcer functions


Keywords
type, enforce, method
License
MIT
Install
npm install type-enforcer-math@1.3.3

Documentation

Type Enforcer Math

An extension of type-enforcer with Math related data types and enforcer functions

npm build coverage deps size vulnerabilities license


Installation

npm install type-enforcer-math

Requires Babel 7.2+


About

type-enforcer-math re-exports everything from type-enforcer, along with:


Objects

is : object

Utility functions for checking if something is a particular data type. Includes all the checks from type-enforcer.

enforce : object

Utility functions for enforcing data types. Includes all the enforcers from type-enforcer.

method : object

Enforce data types and remove common boilerplate code on class methods. Includes all the methods from type-enforcer.


Classes

Point

Point model with helper methods

Vector

A Euclidean Vector model.


Functions

abbrNumber(value, [settings]) ⇒ string

Abbreviates a number in a human readable format.

firstDigit(value) ⇒ number

Gets the number of the position of the first digit.

fractionDigits(value) ⇒ number

Gets the number of digits to the right of the decimal point.

integerDigits(value) ⇒ number

Gets the number of digits to the left of the decimal point.

pow10(n) ⇒ number

Performance optimized version of Math.pow(10, n) for integers (up to 2x improvement for certain values).

round(value, [fractionDigits], [precision]) ⇒ number

Rounds a number to a specified number of fraction digits and/or precision.