web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
498 B

  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 }