question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Would be nice if this had 0 dependencies:

import {readFileSync} from 'node:fs';
import {readFile} from 'node:fs/promises';

const parse = (uint8, options = {}) => {
  // unlike buf.toString('utf8') or or readFile(path, 'utf8'), TextDecoder will remove BOM
  let data = new TextDecoder().decode(uint8);

  if (typeof options.beforeParse === 'function') {
    data = options.beforeParse(data);
  }

  return JSON.parse(data, options.reviver);
};

export const loadJsonFile = (filePath, options) =>
  readFile(filePath).then(data => parse(data, options));

export const loadJsonFileSync = (filePath, options) =>
  parse(readFileSync(filePath), options);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Aug 30, 2021

I ended up dropping parse-json. Not worth the bloat.

https://github.com/sindresorhus/load-json-file/releases/tag/v7.0.0

0reactions
jimmywartingcommented, Aug 30, 2021

Thx

Read more comments on GitHub >

github_iconTop Results From Across the Web

Suggestion Definition & Meaning - Merriam-Webster
a · the act or process of suggesting ; b · something (as a thought or plan) that is suggested.
Read more >
SUGGESTION | definition in the Cambridge English Dictionary
an idea, possible plan, or action that is mentioned for other people to consider: [ C ] She made some helpful suggestions on...
Read more >
Suggestion - Definition, Meaning & Synonyms - Vocabulary.com
A suggestion is an idea someone proposes. You can accept or reject a suggestion. When someone gives an order — like in the...
Read more >
Suggestion Definition & Meaning - Dictionary.com
A suggestion is a proposal, piece of advice, or idea for consideration. Suggestion is the noun form the verb suggest. Suggestion is often...
Read more >
Suggestion - Wikipedia
Suggestion is the psychological process by which a person guides their own or another person's desired thoughts, feelings, and behaviors by presenting ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found