ghaction-github-pages/node_modules/jsonfile/utils.js
2020-03-23 09:00:06 +00:00

16 lines
483 B
JavaScript

function stringify (obj, options = {}) {
const EOL = options.EOL || '\n'
const str = JSON.stringify(obj, options ? options.replacer : null, options.spaces)
return str.replace(/\n/g, EOL) + EOL
}
function stripBom (content) {
// we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
if (Buffer.isBuffer(content)) content = content.toString('utf8')
return content.replace(/^\uFEFF/, '')
}
module.exports = { stringify, stripBom }