npm install safe-trim
import safeTrim from 'safe-trim'
safeTrim(' aβββββ―βb ')
let str = ' "a":1 a \r\n\r\tΒ αα ββββββ
ββββββ―βγb '
let ret = safeTrim(str)
expect(ret).toEqual('"a":1 a\n\nb')
a\r\n\r\nb => 'a\n\nb'
a\r\rb => 'a\n\nb'
a\r\r\nb => 'a\n\nb'
JSON.parse('ο»Ώ{"a":1}') // βοΈError because BOM
JSON.parse(safeTrim('ο»Ώ{"a":1}')) // β