Open ziir opened 5 years ago
Please make the changes in /src/jsesc.js
. /jsesc.js
is generated from it when you run the build script.
@mathiasbynens I have made the changes in the source, ran the build script and updated the README. I'm not sure why the Travis build is failing though. Please advise.
I just came across another case of different behavior between jsesc(..., { json: true })
(this PR's version) and JSON.stringify()
:
> require('jsesc')({ foo: () => {} }, { json: true })
'{"foo":null}'
> JSON.stringify({ foo: () => {} })
'{}'
> require('serialize-javascript')({ foo: () => {} }, { isJSON: true })
'{}'
I believe this falls in the scope of #17.
I will address it in the fork of jsesc
I'm currently using for my project, and suggest a patch here.
Hello, many thanks for this awesome package.
Similarily to
JSON.stringify
,jsesc(obj, { json:true })
should skipundefined
properties withinobj
.Side-note: Following discussions on Twitter, I was experimenting moving away from serialize-javascript to
jsesc
to serialize Redux SSR's initial state for GANDI apps such as https://shop.gandi.net when I encounteredjsesc
's behavior regardingundefined
object properties, which differs fromserialize-javascript
's behavior.Awaiting feedback before making final changes.
Fixes #17 Continuation of #18
Thank you for any response.