source: node_modules/jsonfile/utils.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 498 bytes
RevLine 
[d24f17c]1function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
2 const EOF = finalEOL ? EOL : ''
3 const str = JSON.stringify(obj, replacer, spaces)
4
5 return str.replace(/\n/g, EOL) + EOF
6}
7
8function stripBom (content) {
9 // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
10 if (Buffer.isBuffer(content)) content = content.toString('utf8')
11 return content.replace(/^\uFEFF/, '')
12}
13
14module.exports = { stringify, stripBom }
Note: See TracBrowser for help on using the repository browser.