How to use the buffer-json.stringify 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 dcloudio / uni-app / packages / vue-cli-plugin-uni / lib / cache-loader.js View on Github external
function write (key, data, callback) {
  const dirname = path.dirname(key)
  // template,缓存 mp template
  if (
    data.remainingRequest.indexOf('vue&type=template') !== -1 &&
    process.UNI_CACHE_TEMPLATES
  ) {
    data['mpTemplates'] = process.UNI_CACHE_TEMPLATES
    delete process.UNI_CACHE_TEMPLATES
  }

  const content = BJSON.stringify(data)

  if (directories.has(dirname)) {
    // for performance skip creating directory
    fs.writeFile(key, content, 'utf-8', callback)
  } else {
    mkdirp(dirname, (mkdirErr) => {
      if (mkdirErr) {
        callback(mkdirErr)
        return
      }

      directories.add(dirname)

      fs.writeFile(key, content, 'utf-8', callback)
    })
  }

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