Skip to content

Latest commit

 

History

History
99 lines (72 loc) · 3.2 KB

is.md

File metadata and controls

99 lines (72 loc) · 3.2 KB

Type Enforcer Math

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

npm build coverage deps size vulnerabilities license


is : object

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.point(value, [coerce]) ⇒ boolean

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


is.vector(value, [coerce]) ⇒ boolean

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