mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:51:35 +00:00

PR-URL: https://github.com/nodejs/node/pull/22591 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
18 lines
328 B
JavaScript
18 lines
328 B
JavaScript
'use strict'
|
|
|
|
module.exports = stringifyPackage
|
|
|
|
const DEFAULT_INDENT = 2
|
|
const CRLF = '\r\n'
|
|
const LF = '\n'
|
|
|
|
function stringifyPackage (data, indent, newline) {
|
|
const json = JSON.stringify(data, null, indent || DEFAULT_INDENT)
|
|
|
|
if (newline === CRLF) {
|
|
return json.replace(/\n/g, CRLF) + CRLF
|
|
}
|
|
|
|
return json + LF
|
|
}
|