How to use the buffer-json.replacer function in buffer-json

To help you get started, we’ve selected a few buffer-json examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jprichardson / electron-ipc-stream / src / main.js View on Github external
MainIPCStream.prototype._write = function (data, enc, next) {
  if (typeof data === 'string') {
    data = JSON.stringify(data)
  }
  if (Buffer.isBuffer(data)) {
    data = JSON.stringify(data, null, bufferJson.replacer)
  }
  if (!this.browserWindow) return console.warn('MainIPCStream: trying to write when no browserWindow is set.')
  this.browserWindow.webContents.send(this.channel, data)
  next()
}
github jprichardson / electron-ipc-stream / src / rend.js View on Github external
RendIPCStream.prototype._write = function (data, enc, next) {
  if (typeof data === 'string') {
    data = JSON.stringify(data)
  }
  if (Buffer.isBuffer(data)) {
    data = JSON.stringify(data, null, bufferJson.replacer)
  }

  ipcRenderer.send(this.channel, data)
  next()
}

buffer-json

JSON.stringify & JSON.parse which can encode/decode buffers.

MIT
Latest version published 6 years ago

Package Health Score

62 / 100
Full package analysis