How to use bfj

Comprehensive bfj code examples:

How to use bfj.walk:

14
15
16
17
18
19
20
21
22
23
const fileInputStream = fs.createReadStream(inputFilePath);

let curObject = null;
let curProperty = null;

const emitter = bfj.walk(fileInputStream);

emitter.on(bfj.events.object, () => {
    curObject = {};
});

How to use bfj.read:

41
42
43
44
45
46
47
48
49
50
51
    }
});


ipcMain.handle('fs:readFileJSON', async (event, file) => {
    try {
        return await bfj.read(file);
    } catch (e) {
        console.error(e);
    }
});

How to use bfj.write:

101
102
103
104
105
106
107
108
109
110
return _asyncToGenerator(function* () {
  const statsFilepath = path.resolve(_this.compiler.outputPath, _this.opts.statsFilename);
  mkdir.sync(path.dirname(statsFilepath));

  try {
    yield bfj.write(statsFilepath, stats, {
      space: 2,
      promises: 'ignore',
      buffers: 'ignore',
      maps: 'ignore',