Closed kevbook closed 8 years ago
I would accept a PR to perform a preprocess option. e.g. something like:
function preprocess (text, done) {
// do something
var newText = ...
done(newText)
}
fs.readFile('/some/file.json', { preprocess: preprocess }, callback)
Then if preprocess.length
is 2
(it has done
) it's async, if it's 1
, it's expected to be sync.
@jprichardson stripping comments is a fundamental feature for JSON operations.
preprocess
option does not make too much sense. What would you pre-process a JSON file for? except for stripping out comments. A stripComments:boolean
option instead would save devs from installing/using an extra module.
Actually this feature is the only thing missing in the (excellent) fs-extra
module.
stripping comments is a fundamental feature for JSON operations.
How do you figure? Comments aren't part of the JSON standard.
does not make too much sense. What would you pre-process a JSON file for?
Strip comments? 😛 Change encoding. Do some sort of processing that JSON.parse reviver can't handle.
:) I didn't mean it's in the standard. But check how devs need and use it.
Check out https://github.com/sindresorhus/strip-json-comments