Miss any of our Open RFC calls?Watch the recordings here! »

This package has been deprecated

Author message:

THIS PROJECT IS NO LONGER MAINTAINED by clebert

typesystem

5.0.0 • Public • Published

typesystem

Better type checking for JavaScript.

license npm downloads

build coverage code climate dependencies devDependencies

Sauce Test Status

Getting Started

Installation

npm install typesystem --save

Integration

var ts = require('typesystem');

API

Overview

ts.isArguments(value)

ts.isArguments(arguments); // returns true

ts.isArray(value)

ts.isArray([]);          // returns true
ts.isArray(new Array()); // returns true

ts.isBoolean(value)

ts.isBoolean(true);  // returns true
ts.isBoolean(false); // returns true

ts.isBooleanObject(value)

ts.isBooleanObject(new Boolean()); // returns true

ts.isDate(value)

ts.isDate(new Date()); // returns true

ts.isDocument(value)

ts.isDocument(document); // returns true

ts.isElement(value)

ts.isElement(document.createElement('div'));  // returns true
ts.isElement(document.createElement('span')); // returns true

ts.isError(value)

ts.isError(new Error());          // returns true
ts.isError(new EvalError());      // returns true
ts.isError(new RangeError());     // returns true
ts.isError(new ReferenceError()); // returns true
ts.isError(new SyntaxError());    // returns true
ts.isError(new TypeError());      // returns true
ts.isError(new URIError());       // returns true

ts.isFloat(value)

ts.isFloat(1);                 // returns true
ts.isFloat(-1);                // returns true
ts.isFloat(0);                 // returns true
ts.isFloat(-0);                // returns true
ts.isFloat(Number.MAX_VALUE);  // returns true
ts.isFloat(-Number.MAX_VALUE); // returns true
ts.isFloat(Number.MIN_VALUE);  // returns true
ts.isFloat(-Number.MIN_VALUE); // returns true

ts.isFunction(value)

ts.isFunction(function () {}); // returns true
ts.isFunction(new Function()); // returns true

ts.isGlobal(value)

ts.isGlobal(global); // returns true
ts.isGlobal(window); // returns true

ts.isInteger(value)

ts.isInteger(1);                 // returns true
ts.isInteger(-1);                // returns true
ts.isInteger(0);                 // returns true
ts.isInteger(-0);                // returns true
ts.isInteger(Number.MAX_VALUE);  // returns true
ts.isInteger(-Number.MAX_VALUE); // returns true

ts.isNaN(value)

ts.isNaN(NaN); // returns true

ts.isNull(value)

ts.isNull(null); // returns true

ts.isNullOrUndefined(value)

ts.isNullOrUndefined(null);      // returns true
ts.isNullOrUndefined(undefined); // returns true
ts.isNullOrUndefined(void 0);    // returns true

ts.isNumber(value)

ts.isNumber(1);                 // returns true
ts.isNumber(-1);                // returns true
ts.isNumber(0);                 // returns true
ts.isNumber(-0);                // returns true
ts.isNumber(Number.MAX_VALUE);  // returns true
ts.isNumber(-Number.MAX_VALUE); // returns true
ts.isNumber(Number.MIN_VALUE);  // returns true
ts.isNumber(-Number.MIN_VALUE); // returns true
ts.isNumber(Infinity);          // returns true
ts.isNumber(-Infinity);         // returns true
ts.isNumber(NaN);               // returns true

ts.isNumberObject(value)

ts.isNumberObject(new Number()); // returns true

ts.isObject(value)

ts.isObject({});           // returns true
ts.isObject(new Object()); // returns true

ts.isPrimitive(value)

ts.isPrimitive(true);      // returns true
ts.isPrimitive(null);      // returns true
ts.isPrimitive(1);         // returns true
ts.isPrimitive('foo');     // returns true
ts.isPrimitive(Symbol());  // returns true
ts.isPrimitive(undefined); // returns true

ts.isReference(value)

ts.isReference(arguments);                     // returns true
ts.isReference([]);                            // returns true
ts.isReference(new Boolean());                 // returns true
ts.isReference(new Date());                    // returns true
ts.isReference(document);                      // returns true
ts.isReference(document.createElement('div')); // returns true
ts.isReference(new Error());                   // returns true
ts.isReference(function () {});                // returns true
ts.isReference(global);                        // returns true
ts.isReference(new Number());                  // returns true
ts.isReference({});                            // returns true
ts.isReference(/(?:)/);                        // returns true
ts.isReference(new String());                  // returns true

ts.isRegExp(value)

ts.isRegExp(/(?:)/);       // returns true
ts.isRegExp(new RegExp()); // returns true

ts.isString(value)

ts.isString('foo'); // returns true
ts.isString('');    // returns true

ts.isStringObject(value)

ts.isStringObject(new String()); // returns true

ts.isSymbol(value)

ts.isSymbol(Symbol()); // returns true

ts.isUndefined(value)

ts.isUndefined(undefined); // returns true
ts.isUndefined(void 0);    // returns true

Running Tests

To run the test suite first install the development dependencies:

npm install

then run the tests:

npm test

Install

npm i typesystem

DownloadsWeekly Downloads

76

Version

5.0.0

License

none

Last publish

Collaborators

  • avatar