UNPKG

393 BJavaScriptView Raw
1var escapable, filter;
2
3escapable = /[\x00-\x1f\ud800-\udfff\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufff0-\uffff]/g;
4
5filter = function(quoted) {
6 escapable.lastIndex = 0;
7 if (!escapable.test(quoted)) {
8 return quoted;
9 }
10 return quoted.replace(escapable, function(a) {
11 return "";
12 });
13};
14
15module.exports = {
16 json: function(obj) {
17 return filter(JSON.stringify(obj));
18 }
19};