• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2
3module.exports = stringifyPackage
4
5const DEFAULT_INDENT = 2
6const CRLF = '\r\n'
7const LF = '\n'
8
9function stringifyPackage (data, indent, newline) {
10  indent = indent || (indent === 0 ? 0 : DEFAULT_INDENT)
11  const json = JSON.stringify(data, null, indent)
12
13  if (newline === CRLF) {
14    return json.replace(/\n/g, CRLF) + CRLF
15  }
16
17  return json + LF
18}
19