Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

utils.js 498B

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 }