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
|
Line | |
---|
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 |
|
---|
5 | return str.replace(/\n/g, EOL) + EOF
|
---|
6 | }
|
---|
7 |
|
---|
8 | function 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 |
|
---|
14 | module.exports = { stringify, stripBom }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.