New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

checkt

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

checkt

Safe (chainable) type checks

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

checkt

What is it?

checkt is a small library for safe (chainable) type checks written in CoffeeScript and usable in any JavaScript environment.

Currently supported are:

  • Browser
  • CommonJS environments (Node.js)

The checkt library exposes the checkt function. (An alias is the check object, which has exactly the same functionality.)

Usage

JavaScript

// Method chaining examples
check('test').not.string(function() {
  return console.log('not a string');
})["else"](function() {
  return console.log('Logically, should be a string');
}).number(function(v) {
  return console.log("its a number with value: " + v);
});

// Instead of using method chaing, you can also use
// a plain object with the type as the key and the value is the callback function
check({}, {
  object: function() {
    return console.log('Is an object');
  },
  number: function() {
    return console.log('Is a number');
  }
});

// Multiple keys seperated by a comma also work, just make sure the key is
// written as a key
check('test', {
  'string, number': function() {
    return console.log('Either string or number');
  }
});

CoffeeScript

# Method chaining examples
check('test')
  .not.string(-> console.log 'not a string')
  .else(-> console.log 'Logically, should be a string')
  .number((v) -> console.log("its a number with value: #{v}"))

# Instead of using method chaing, you can also use
# a plain object with the type as the key and the value is the callback function
check {},
  object: -> console.log 'Is an object'
  number: -> console.log 'Is a number'

# Multiple keys seperated by a comma also work, just make sure the key is
# written as a key
check 'test',
  'string, number': -> console.log 'Either string or number'

License

checkt is practically public domain. See UNLICENSE.md for more information.

Keywords

FAQs

Package last updated on 05 Mar 2013

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