node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »



Chainable type checking assertions for JavaScript


if (Cynic.number(x)) performMaths(x);
new Cynic(x)
    .else(new Error("x must be a number greater than 10"));
var result = new Cynic(x, "or").number().string().result;
//    ^-- true if x is a number or a string 


Cynic is:

  • Compiled to UMD
  • Written in TypeScript
  • Potentially an assertion library


If you want to play with Cynic's source code, VSCode is highly recommended for the purpose. It's a great little cross-platform open-source IDE which integrates with TypeScript nicely.

  • Clone this project, run npm install, and open the project in VSCode
  • Hover your mouse cursor over the TypeScript source and enjoy 'IntelliSense' hints
  • Build with Ctrl-Shift-B
  • Test with Ctrl-Shift-T