Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Display date value #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/json-tree/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const KNOWN = {
String: 'string',
Symbol: 'symbol',
Function: 'function',
Iterable: 'iterable'
Iterable: 'iterable',
Date: 'date',
};

export function getTypeOf(object: any) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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];
Expand Down