From 17fbbc9b51b0da4ac105ca705c102303161a6fb5 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 12 May 2017 22:07:50 +0200 Subject: [PATCH] Display date value --- src/json-tree/types.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/json-tree/types.ts b/src/json-tree/types.ts index e8a4d23..17f2bac 100644 --- a/src/json-tree/types.ts +++ b/src/json-tree/types.ts @@ -11,7 +11,8 @@ export const KNOWN = { String: 'string', Symbol: 'symbol', Function: 'function', - Iterable: 'iterable' + Iterable: 'iterable', + Date: 'date', }; export function getTypeOf(object: any) { @@ -21,6 +22,9 @@ export function getTypeOf(object: any) { if (Array.isArray(object)) { return KNOWN.Array; } + if(object instanceof Date){ + return KNOWN.Date; + } if (object === null) { return KNOWN.Null; } @@ -50,7 +54,8 @@ const labelFactoriesForTypes = { [KNOWN.String]: withQuotes, [KNOWN.Symbol]: compose(withQuotes, toString), [KNOWN.Function]: typeIdentity(KNOWN.Function), - [KNOWN.Iterable]: compose(typeIndicator('()'), lengthLabel('entry', 'entries'), arrayLength, iterableToArray) + [KNOWN.Iterable]: compose(typeIndicator('()'), lengthLabel('entry', 'entries'), arrayLength, iterableToArray), + [KNOWN.Date]: toString, }; const lookupLabelForType = (type: string) => labelFactoriesForTypes[type];