6df7add03726a8528cbc261258a4b133da7267ba082a8ce83fe23a646fb7d68e1ae4e1709025673914b6dbc2355ed486129039a993089f250a1801a7a93b3f 498 B

1234567891011121314
  1. function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
  2. const EOF = finalEOL ? EOL : ''
  3. const str = JSON.stringify(obj, replacer, spaces)
  4. return str.replace(/\n/g, EOL) + EOF
  5. }
  6. function stripBom (content) {
  7. // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
  8. if (Buffer.isBuffer(content)) content = content.toString('utf8')
  9. return content.replace(/^\uFEFF/, '')
  10. }
  11. module.exports = { stringify, stripBom }