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

notmytype

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notmytype

Type-check your function inputs with syntax like T(s, T.string, buf, Buffer, strings, T.list(T.string))

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

notmytype

NPM version Build status

notmytype provides a type-asserting function that handles multiple arguments and uses the type asserter from flowcheck.

Install

In your project, run:

npm install notmytype --save

or install from the GitHub repo:

npm install ludios/notmytype --save

Examples

notmytype requires io.js 2.0.0+/node 4.0.0+ running with --harmony-rest-parameters.

const T = require('notmytype');

All of these examples type-check without error:

T(3, T.number);
T(3, T.number, "hello", T.string);
T(3, T.number, true, T.boolean);
T([true, false, true], T.list(T.boolean));
T([true, 3, true], T.list(T.union([T.boolean, T.number])));
T(undefined, T.optional(T.number));
T(3, T.optional(T.number));
T(null, T.maybe(T.number));
T(3, T.maybe(T.number));
T(new Buffer("hi"), Buffer);
T([3, "hi"], T.tuple([T.number, T.string]));
T({"hello": 3}, T.dict(T.string, T.number));
T(undefined, T.void);
T({"hello": 3}, T.shape({"hello": T.number}));
T({"hello": 3, "extra": "s"}, T.shape({"hello": T.number}));
T(Symbol('a'), T.symbol);

T() raises TypeError if given an object of the wrong type:

> T([3, "s"], T.list(T.number))
TypeError: First object: Expected an instance of number; got "s", context: Array<number> / 1

See assert.js and test/assert.js for details.

Keywords

FAQs

Package last updated on 25 Sep 2015

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