# check-types.js [![Build status](https://gitlab.com/philbooth/check-types.js/badges/master/pipeline.svg)](https://gitlab.com/philbooth/check-types.js/pipelines) [![Package status](https://img.shields.io/npm/v/check-types.svg)](https://www.npmjs.com/package/check-types) [![Downloads](https://img.shields.io/npm/dm/check-types.svg)](https://www.npmjs.com/package/check-types) [![License](https://img.shields.io/npm/l/check-types.svg)](https://opensource.org/licenses/MIT) A little JavaScript library for asserting types and values. * [Why would I want that?](#why-would-i-want-that) * [How little is it?](#how-little-is-it) * [How do I install it?](#how-do-i-install-it) * [How do I use it?](#how-do-i-use-it) * [Loading the library](#loading-the-library) * [Calling the exported functions](#calling-the-exported-functions) * [General predicates](#general-predicates) * [String predicates](#string-predicates) * [Number predicates](#number-predicates) * [Boolean predicates](#boolean-predicates) * [Object predicates](#object-predicates) * [Array predicates](#array-predicates) * [Date predicates](#date-predicates) * [Function predicates](#function-predicates) * [Modifiers](#modifiers) * [Batch operations](#batch-operations) * [Some examples](#some-examples) * [Are there TypeScript definitions?](#are-there-typescript-definitions) * [Where can I use it?](#where-can-i-use-it) * [What changed from 7.x to 8.x?](#what-changed-from-7x-to-8x) * [What changed from 6.x to 7.x?](#what-changed-from-6x-to-7x) * [What changed from 5.x to 6.x?](#what-changed-from-5x-to-6x) * [What changed from 4.x to 5.x?](#what-changed-from-4x-to-5x) * [What changed from 3.x to 4.x?](#what-changed-from-3x-to-4x) * [What changed from 2.x to 3.x?](#what-changed-from-2x-to-3x) * [What changed from 1.x to 2.x?](#what-changed-from-1x-to-2x) * [What changed from 0.x to 1.x?](#what-changed-from-0x-to-1x) * [How do I set up the build environment?](#how-do-i-set-up-the-build-environment) * [What license is it released under?](#what-license-is-it-released-under) ## Why would I want that? Writing explicit conditions in your functions to check arguments and throw exceptions is a task that swiftly becomes tiresome and adds complexity to your codebase. The purpose of check-types.js is to remove this burden from JavaScript application developers in an efficient and robust manner, abstracted by a simple API. ## How little is it? 20 kb unminified with comments, 5.7 kb minified, 2.1 kb minified + gzipped. ## How do I install it? Via npm: ``` npm i check-types --save ``` Or if you just want the git repo: ``` git clone git@gitlab.com:philbooth/check-types.js.git ``` If you're into other package managers, it is also available from Bower, Component and Jam. ## How do I use it? ### Loading the library If you are running in Node.js, Browserify or another CommonJS-style environment, you can `require` check-types like so: ```javascript var check = require('check-types'); ``` It also the supports the AMD-style format preferred by Require.js. If you are including check-types.js with an HTML `