55[ ![ deno doc] ( https://doc.deno.land/badge.svg )] ( https://doc.deno.land/https/deno.land/x/unknownutil/mod.ts )
66[ ![ Test] ( https://github.com/lambdalisue/deno-unknownutil/workflows/Test/badge.svg )] ( https://github.com/lambdalisue/deno-unknownutil/actions?query=workflow%3ATest )
77[ ![ npm version] ( https://badge.fury.io/js/unknownutil.svg )] ( https://badge.fury.io/js/unknownutil )
8+ [ ![ codecov] ( https://codecov.io/github/lambdalisue/deno-unknownutil/graph/badge.svg?token=pfbLRGU5AM )] ( https://codecov.io/github/lambdalisue/deno-unknownutil )
89
910A utility pack for handling ` unknown ` type.
1011
@@ -15,7 +16,7 @@ A utility pack for handling `unknown` type.
1516It provides ` is ` module for type predicate functions and ` assert ` , ` ensure ` , and
1617` maybe ` helper functions.
1718
18- ### is*
19+ ### is\ *
1920
2021Type predicate function is a function which returns ` true ` if a given value is
2122expected type. For example, ` isString ` (or ` is.String ` ) returns ` true ` if a
@@ -39,24 +40,23 @@ import { is, PredicateType } from "./mod.ts";
3940const isArticle = is .ObjectOf ({
4041 title: is .String ,
4142 body: is .String ,
42- refs: is .ArrayOf (is .OneOf ([
43- is .String ,
44- is .ObjectOf ({
45- name: is .String ,
46- url: is .String ,
47- }),
48- ])),
43+ refs: is .ArrayOf (
44+ is .OneOf ([
45+ is .String ,
46+ is .ObjectOf ({
47+ name: is .String ,
48+ url: is .String ,
49+ }),
50+ ])
51+ ),
4952});
5053
5154type Article = PredicateType <typeof isArticle >;
5255
5356const a: unknown = {
5457 title: " Awesome article" ,
5558 body: " This is an awesome article" ,
56- refs: [
57- { name: " Deno" , url: " https://deno.land/" },
58- " https://github.com" ,
59- ],
59+ refs: [{ name: " Deno" , url: " https://deno.land/" }, " https://github.com" ],
6060};
6161if (isArticle (a )) {
6262 // a is narrowed to the type of `isArticle`
0 commit comments