diff --git a/example.html b/example.html index 2fd2b6b..e4e2ed5 100644 --- a/example.html +++ b/example.html @@ -16,6 +16,7 @@ misc: [ ['i am an arrray'], {i:{am:{an:'object'}}}, + new Date(), 'string', 42, true, @@ -25,4 +26,4 @@ }); - \ No newline at end of file + diff --git a/index.js b/index.js index 94fb122..a0be297 100644 --- a/index.js +++ b/index.js @@ -27,6 +27,7 @@ function type (doc) { if (doc === null) return 'null' if (Array.isArray(doc)) return 'array' if (typeof doc === 'string' && /^https?:/.test(doc)) return 'link' + if (typeof doc === 'object' && typeof doc.toISOString === 'function') return 'date' return typeof doc } @@ -63,6 +64,9 @@ module.exports = function (doc, styleFile) { case 'number': return '' + obj + '' + case 'date': + return '"' + escape(obj.toISOString()) + '"' + case 'null': return 'null'