An extension of type-enforcer with Math related data types and enforcer functions
Utility functions for checking if something is a particular data type. Includes all the checks from type-enforcer.
Example
import { is } from 'type-enforcer-math';
// Or import individual functions
import { isBoolean, isString } from 'type-enforcer-math';
- is :
object
- .point(value, [coerce]) ⇒
boolean
- .vector(value, [coerce]) ⇒
boolean
- .point(value, [coerce]) ⇒
Check if a value is a Point
Alias: isPoint
Param | Type | Default | Description |
---|---|---|---|
value | unknown |
||
[coerce] | boolean |
false |
If true then see if the value can be coerced into a Point |
Example
import { isPoint } from 'type-enforcer-math';
isPoint(new Point());
// => true
isPoint('1,2');
// => false
isPoint('1,2', true);
// => true
Check if a value is a Vector
Alias: isVector
Param | Type | Default | Description |
---|---|---|---|
value | unknown |
||
[coerce] | boolean |
false |
If true then see if the value can be coerced into a Vector |
Example
import { isVector } from 'type-enforcer-math';
isVector(new Vector());
// => true
isVector('[[1,2],[3,4]]');
// => false
isVector('[[1,2],[3,4]]', true);
// => true