
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
checkt is a small library for safe (chainable) type checks written in CoffeeScript and usable in any JavaScript environment.
Currently supported are:
The checkt library exposes the checkt function. (An alias is the check object, which has exactly the same functionality.)
Browser
Embed js/checkt.js
in your HTML file for development purposes and
js/checkt.min.js
for production use.
Node.js
Either use npm with
npm install checkt
or add checkt
to to the package.json of your project.
JavaScript
// Method chaining examples
check('test').not.string(function() {
console.log('not a string');
}).otherwise(function() {
console.log('Logically, should be a string');
}).number(function(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: function() {
console.log('Is an object');
},
number: function() {
console.log('Is a number');
}
});
// Multiple keys seperated by a comma also work, just make sure the key is
// written as a string
check('test', {
'string, number': function() {
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 string
check 'test',
'string, number': -> console.log 'Either string or number'
checkt is public domain. See UNLICENSE.md for more information.
FAQs
Safe (chainable) type checks
We found that checkt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.