ghaction-github-pages/node_modules/jsonfile/utils.js

16 lines
483 B
JavaScript
Raw Normal View History

2020-03-23 17:00:06 +08:00
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 }