node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…

cynic

Chainable type checking assertions

Cynic

Chainable type checking assertions for JavaScript


if (Cynic.number(x)) performMaths(x);
new Cynic(x)
    .number()
    .greater(10)
    .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