Socket
Socket
Sign inDemoInstall

rttc

Package Overview
Dependencies
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rttc

Runtime type-checking for JavaScript.


Version published
Weekly downloads
89K
decreased by-21.95%
Maintainers
2
Weekly downloads
 
Created

What is rttc?

The 'rttc' (Runtime Type Checking) npm package provides utilities for runtime type checking and validation of JavaScript values. It is particularly useful for ensuring that data conforms to expected types and structures, which can help catch errors early in the development process.

What are rttc's main functionalities?

Type Validation

This feature allows you to validate if a value matches a specified type. In this example, the string 'Hello, World!' is validated against the 'string' type.

const rttc = require('rttc');

const isValid = rttc.validate('string', 'Hello, World!');
console.log(isValid); // true

Type Coercion

This feature allows you to coerce a value to a specified type. In this example, the string '42' is coerced to the number 42.

const rttc = require('rttc');

const coercedValue = rttc.coerce('number', '42');
console.log(coercedValue); // 42

Type Inference

This feature allows you to infer the type of a given value. In this example, the type of the string 'Hello, World!' is inferred to be 'string'.

const rttc = require('rttc');

const inferredType = rttc.infer('Hello, World!');
console.log(inferredType); // 'string'

Deep Validation

This feature allows you to validate complex data structures against a schema. In this example, an object with 'name' and 'age' properties is validated against a schema.

const rttc = require('rttc');

const schema = { name: 'string', age: 'number' };
const data = { name: 'Alice', age: 30 };
const isValid = rttc.validate(schema, data);
console.log(isValid); // true

Other packages similar to rttc

Keywords

FAQs

Package last updated on 15 Apr 2019

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