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}')) // ✅