source: frontend/node_modules/jsonfile/utils.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 613 bytes
Line 
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 if (str === undefined) {
6 throw new TypeError(`Converting ${typeof obj} value to JSON is not supported`)
7 }
8
9 return str.replace(/\n/g, EOL) + EOF
10}
11
12function stripBom (content) {
13 // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
14 if (Buffer.isBuffer(content)) content = content.toString('utf8')
15 return content.replace(/^\uFEFF/, '')
16}
17
18module.exports = { stringify, stripBom }
Note: See TracBrowser for help on using the repository browser.