Urara-Blog/node_modules/.pnpm-store/v3/files/dd/6df7add03726a8528cbc261258a4b133da7267ba082a8ce83fe23a646fb7d68e1ae4e1709025673914b6dbc2355ed486129039a993089f250a1801a7a93b3f
2022-08-14 01:14:53 +08:00

14 lines
498 B
Text

function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
const EOF = finalEOL ? EOL : ''
const str = JSON.stringify(obj, replacer, spaces)
return str.replace(/\n/g, EOL) + EOF
}
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 }