type-enforcer-math

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

Usage no npm install needed!

<script type="module">
  import typeEnforcerMath from 'https://cdn.skypack.dev/type-enforcer-math';
</script>

README

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.int

Gets the number of the position of the first digit.

fractionDigits(value)number.int

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

integerDigits(value)number.int

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

pow10(n)number.int

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

round(value, [fractionDigits], [precision])number.int

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