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

check-more-types

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-more-types

Large collection of predicates.

  • 2.24.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.6M
increased by9.14%
Maintainers
3
Weekly downloads
 
Created

What is check-more-types?

The check-more-types npm package provides a variety of type checking and assertion functions that enhance JavaScript's type testing capabilities. It offers a wide range of predicates for more precise type validation, making it easier to enforce type safety in JavaScript applications.

What are check-more-types's main functionalities?

Primitive type checks

This feature allows for checking JavaScript's primitive types such as strings, numbers, and booleans. It's useful for basic type validation.

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

// checks if a value is a string
check.string('hello'); // true

// checks if a value is a number
check.number(42); // true

Complex type checks

This feature extends the library's capabilities to more complex types, such as arrays of specific types or objects matching a schema. It's particularly useful for validating data structures.

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

// checks if a value is an array of strings
check.arrayOfStrings(['hello', 'world']); // true

// checks if a value is an object with specific properties
check.schema({
  name: check.string,
  age: check.number
})({ name: 'John', age: 30 }); // true

Custom predicates

check-more-types allows for the creation of custom predicates, enhancing its flexibility and allowing users to define their own specific type checks.

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

// defines a custom predicate for checking if a number is even
check.mixin({
  even: function (n) { return check.number(n) && n % 2 === 0; }
});

// uses the custom predicate
check.even(42); // true

Other packages similar to check-more-types

Keywords

FAQs

Package last updated on 20 Mar 2017

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