🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

check-types

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-types

A little library for asserting types and values, with zero dependencies.

11.2.3
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

77

Maintenance

100

License

Version published
Weekly downloads
4.5M
-9.35%
Maintainers
1
Weekly downloads
 
Created

What is check-types?

The check-types npm package provides a collection of functions for asserting types and values in JavaScript. It is designed to help developers enforce type safety and data integrity in their applications by offering a simple and intuitive API for type checking and validation.

What are check-types's main functionalities?

Primitive Type Checking

This feature allows you to check if a value is of a specific primitive type, such as a number, string, or boolean. The code sample demonstrates how to use the package to verify that a value is a number, a string, and a boolean.

const check = require('check-types');

console.log(check.number(42)); // true
console.log(check.string('hello')); // true
console.log(check.boolean(false)); // true

Object and Array Checking

With this feature, you can check if a value is an array or an object. The code sample shows how to validate that a value is an array and an object.

const check = require('check-types');

console.log(check.array([1, 2, 3])); // true
console.log(check.object({ key: 'value' })); // true

Function and Null Checking

This feature enables you to verify if a value is a function or null. The provided code sample illustrates how to check for a function and a null value.

const check = require('check-types');

console.log(check.function(function() {})); // true
console.log(check.null(null)); // true

Other packages similar to check-types

FAQs

Package last updated on 07 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts