fast-json-stringify 7.3.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/projection.js
CHANGED
|
@@ -306,7 +306,7 @@ const projectionHelpers = `
|
|
|
306
306
|
if (v === null) return ''
|
|
307
307
|
if (v instanceof Date) return v.toISOString()
|
|
308
308
|
if (typeof v === 'string') return v
|
|
309
|
-
|
|
309
|
+
throw new Error('The value "' + v + '" cannot be converted to a date-time.')
|
|
310
310
|
}
|
|
311
311
|
const asDateValue = (v) => { const s = serializer.asDate(v); return s.slice(1, -1) }
|
|
312
312
|
const asTimeValue = (v) => { const s = serializer.asTime(v); return s.slice(1, -1) }
|
package/package.json
CHANGED
|
@@ -66,6 +66,10 @@ const inputs = {
|
|
|
66
66
|
'Date in a plain string': { id: 1, name: new Date(0), tags: [new Date(0)] },
|
|
67
67
|
'RegExp in a plain string': { id: 1, name: /a"b/, tags: [/c/g] },
|
|
68
68
|
'date-time given as string': { id: 1, createdAt: '2020-01-01T00:00:00.000Z' },
|
|
69
|
+
'date-time given as a number throws': { id: 1, createdAt: 1700000000000 },
|
|
70
|
+
'date-time given as an object throws': { id: 1, createdAt: { toString () { return 'custom' } } },
|
|
71
|
+
'date given as a number throws': { id: 1, birthday: 1700000000000 },
|
|
72
|
+
'time given as a number throws': { id: 1, at: 1700000000000 },
|
|
69
73
|
'toJSON on root': { id: 1, toJSON () { return { id: 7, name: 'json' } } },
|
|
70
74
|
'toJSON on nested object': { id: 1, address: { toJSON () { return { city: 'Roma' } } } },
|
|
71
75
|
'toJSON on array item': { id: 1, friends: [{ toJSON () { return { id: 9 } } }] },
|