iteration-typeguards0.1.1 • Public • Published
Install with npm
npm install iteration-typeguards
This module consists of two typeguard functions,
isIterator that accept
value is a
Iterable or an
Iterator in the ES6 sense, respectively.
Usage with Typescript
A typescript compiler
--target argument of
es6 should be used. Both of the functions
isIterator are defined as typescript typeguards for the built-in
;isIterable5; // falseisIterable"oh hai"; // trueisIterablenull; // falseisIterable; // trueisIterablenew Map; // trueisIterable; // true
;isIterator5; // falseisIterator"oh hai"; // falseisIterator"oh hai";// trueisIteratornull; // falseisIterator; // falseisIterator; // trueisIterator; // true
Usage without Typescript
Usage without typescript in nodejs is very similar to the typescript examples above without the type annotations. Since an ES6 environment is assumed, the import statements above should work. The more traditional nodejs require statements shown below also work.
var itGuards = ;itGuards // trueitGuards // true
If you come across a case in which these typeguards do not perform as expected, please submit an issue (outlining the case) or a pull request (again, outlining the case and a possible solution).
MIT --- open source