• File: index.js
  • Full Path: /home6/laduliya/test.mydthpay.com/node_modules/npm/node_modules/smart-buffer/index.js
  • Date Modified: 10/26/1985 11:45 AM
  • File size: 367 bytes
  • MIME-type: text/plain
  • Charset: utf-8
'use strict'

module.exports = stringifyPackage

const DEFAULT_INDENT = 2
const CRLF = '\r\n'
const LF = '\n'

function stringifyPackage (data, indent, newline) {
  indent = indent || (indent === 0 ? 0 : DEFAULT_INDENT)
  const json = JSON.stringify(data, null, indent)

  if (newline === CRLF) {
    return json.replace(/\n/g, CRLF) + CRLF
  }

  return json + LF
}