@lanetix/type-visitor
Advanced tools
Comparing version 2.0.0 to 2.2.0
@@ -14,2 +14,3 @@ /* eslint-disable no-new-wrappers */ | ||
decimal: new String('decimal'), | ||
date: new String('date'), | ||
list: new String('list'), | ||
@@ -52,2 +53,5 @@ option: new String('option'), | ||
}, | ||
date: function date(acc, ctx) { | ||
return prim(acc, { fun: tyfun.date, ctx: ctx }); | ||
}, | ||
list: function list(down, acc, _ref2) { | ||
@@ -83,2 +87,3 @@ var arg = _ref2.arg; | ||
var decimal = _ref6.decimal; | ||
var date = _ref6.date; | ||
var list = _ref6.list; | ||
@@ -186,2 +191,4 @@ var option = _ref6.option; | ||
return check_primitive(decimal); | ||
case tyfun.date: | ||
return check_primitive(date); | ||
case tyfun.list: | ||
@@ -229,2 +236,5 @@ return check_unop({ tag: visitContext.listChild, check: list }); | ||
}, | ||
date: function date(exp) { | ||
return typeof exp === 'string' && !isNaN(Date.parse(exp)); | ||
}, | ||
list: function list(down, exp) { | ||
@@ -288,2 +298,4 @@ return exp !== null && typeof exp === 'object' && Array.isArray(exp) && exp.every(function (e) { | ||
return builtin('decimal'); | ||
case tyfun.date: | ||
return builtin('date'); | ||
case tyfun.list: | ||
@@ -321,2 +333,4 @@ return builtin('list'); | ||
return tyfun.decimal; | ||
case 'date': | ||
return tyfun.date; | ||
case 'list': | ||
@@ -323,0 +337,0 @@ return tyfun.list; |
{ | ||
"name": "@lanetix/type-visitor", | ||
"version": "2.0.0", | ||
"version": "2.2.0", | ||
"description": "visit your types", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -116,2 +116,3 @@ @lanetix/type-visitor | ||
```javascript | ||
const tyfunToJson = fun => { | ||
@@ -171,2 +172,3 @@ const builtin = name => ({ namespace: 'builtin', name }) | ||
} | ||
``` | ||
@@ -179,4 +181,4 @@ ### `toJson` | ||
### `intoTy` | ||
Takes a JSON structure reated by toJson and parses it into a type tree. It | ||
Takes a JSON structure created by toJson and parses it into a type tree. It | ||
should only be used on JSON that was previously formed through toJson; | ||
constructing the JSON directly isn't guaranteed to work. |
19198
376
182