Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-check

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-check

type-check allows you to check the types of JavaScript values at runtime with a Haskell like type syntax.

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16M
decreased by-62.68%
Maintainers
1
Weekly downloads
 
Created

What is type-check?

The type-check npm package allows you to check the types of JavaScript values at runtime with a simple and readable syntax. It is useful for validating function arguments, ensuring data integrity, and preventing type-related bugs.

What are type-check's main functionalities?

Basic type checking

This feature allows you to check if a value matches a basic type, such as 'String', 'Number', 'Boolean', etc.

const { typeCheck } = require('type-check');
typeCheck('String', 'a string'); // returns true

Complex type checking

This feature enables checking against more complex types, such as objects with specific properties and types.

const { typeCheck } = require('type-check');
typeCheck('{name: String, age: Number}', {name: 'Alice', age: 30}); // returns true

Custom type definitions

With this feature, you can define custom types and then check values against those custom types.

const { typeCheck, define } = require('type-check');
define('Person', '{name: String, age: Number}');
typeCheck('Person', {name: 'Bob', age: 25}); // returns true

Array type checking

This feature allows you to check if an array contains values of a specific type.

const { typeCheck } = require('type-check');
typeCheck('[Number]', [1, 2, 3]); // returns true

Other packages similar to type-check

Keywords

FAQs

Package last updated on 08 Apr 2014

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc