Skip to content

Add beforeParse and reviver options #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2018
Merged

Add beforeParse and reviver options #14

merged 1 commit into from
May 6, 2018

Conversation

gakada
Copy link
Contributor

@gakada gakada commented Mar 4, 2018

This adds options parameter with

  • reviver from parse-json / JSON.parse
  • arbitrary functions before and after for initial string and final value
  • prefix for arbitrary prefixes (like the XSSI prevention prefix or a var= prefix).

@sindresorhus
Copy link
Owner

I agree with the reviver option, but the other ones I'm sceptical to.


prefix for arbitrary prefixes (like the XSSI prevention prefix or a var= prefix).

This module loads local JSON files. This doesn't apply here.


arbitrary functions before and after for initial string and final value

after is moot as you can just do it yourself after calling this module. What's the use-case for before?

@gakada
Copy link
Contributor Author

gakada commented Mar 5, 2018

Yes, I added after and before just for generality, after can be done on the result, while before generalizes prefix (so, e.g., for #7 it would be {before: stripJsonComments}). Specifically I want prefix (or before) as it so happens that my local JSON files (those are logged HTTP responses) have a prefix. If it is outside of the scope, I can re-push just for reviver parameter.

@sindresorhus
Copy link
Owner

Alright. I'm willing to add the before option so you can handle the prefix stripping yourself, but the prefix option is out of scope.

@sindresorhus
Copy link
Owner

I would call it beforeParse instead of before to be clear.

@gakada
Copy link
Contributor Author

gakada commented Mar 6, 2018

Thanks. I updated to options with just beforeParse and reviver.

@sindresorhus sindresorhus changed the title Add options for pre/post processing Add beforeParse and reviver options May 4, 2018
@sindresorhus sindresorhus merged commit f824f80 into sindresorhus:master May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants