MCPcopy Create free account
hub / github.com/azat-co/practicalnode / readJSON

Function readJSON

code/ch14/generators/readJSON.js:4–16  ·  view source on GitHub ↗
(filename, enc='utf8')

Source from the content-addressed store, hash-verified

2
3
4function* readJSON(filename, enc='utf8'){
5 const caller = yield
6 fs.readFile(filename, enc, function (err, res){
7 if (err) caller.failure(err)
8 else {
9 try {
10 caller.success(JSON.parse(res))
11 } catch (ex) {
12 caller.failure(ex)
13 }
14 }
15 })
16}
17
18const gen = readJSON('./package.json')
19

Callers 1

readJSON.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected