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