jsesc icon indicating copy to clipboard operation
jsesc copied to clipboard

support Date objects

Open skeggse opened this issue 4 years ago • 1 comments

Currently, jsesc produces unsupported code when passed a Date object:

jsesc({ value: new Date() })
// => '{\'value\':Tue Mar 31 2020 18:06:06 GMT-0700 (Pacific Daylight Time)}'

Ideally, this would produce a constructor for that date/time. I'm happy to implement - I'm thinking it'd just use the valueOf unless there's a good argument for using the ISO 8601 format.

skeggse avatar Apr 01 '20 01:04 skeggse

Sounds good. The only reason I haven't added support for this is because I haven't had the need. Happy to review a patch!

mathiasbynens avatar Apr 03 '20 06:04 mathiasbynens