-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson5.js
43 lines (43 loc) · 1.29 KB
/
json5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Json5 = void 0;
function Json5(jsonic, _options) {
jsonic.options({
text: {
modify: (val) => {
let out = 'string' === typeof val ?
val.replace(/\\u[0-9a-fA-F]{4}/g, (m) => String.fromCodePoint(parseInt(m.substring(2), 16))) :
val;
return out;
}
},
value: {
map: {
'Infinity': { val: Infinity },
'+Infinity': { val: Infinity },
'-Infinity': { val: -Infinity },
'+NaN': { val: NaN },
'-NaN': { val: -NaN },
}
},
space: {
chars: '\t\v\f \u00A0\uFEFF\n\r\u2028\u2029\u2003'
},
string: {
escape: {
'0': '\0',
'\r': '',
'\n': '',
'\u2028': '',
'\u2029': '',
},
// This is a hackish (ie. accepts a superset) way to support '"\\\r\n"' escapes.
// A "proper" solution would use a custom StringMatcher.
replace: {
'\n': '',
}
},
});
}
exports.Json5 = Json5;
//# sourceMappingURL=json5.js.map