2.0.0 • Published 10 years ago

notmytype v2.0.0

Weekly downloads
19
License
ISC
Repository
github
Last release
10 years ago

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.

2.0.0

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago