source: trip-planner-front/node_modules/core-js/modules/es.json.stringify.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1var $ = require('../internals/export');
2var getBuiltIn = require('../internals/get-built-in');
3var fails = require('../internals/fails');
4
5var $stringify = getBuiltIn('JSON', 'stringify');
6var re = /[\uD800-\uDFFF]/g;
7var low = /^[\uD800-\uDBFF]$/;
8var hi = /^[\uDC00-\uDFFF]$/;
9
10var fix = function (match, offset, string) {
11 var prev = string.charAt(offset - 1);
12 var next = string.charAt(offset + 1);
13 if ((low.test(match) && !hi.test(next)) || (hi.test(match) && !low.test(prev))) {
14 return '\\u' + match.charCodeAt(0).toString(16);
15 } return match;
16};
17
18var FORCED = fails(function () {
19 return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"'
20 || $stringify('\uDEAD') !== '"\\udead"';
21});
22
23if ($stringify) {
24 // `JSON.stringify` method
25 // https://tc39.es/ecma262/#sec-json.stringify
26 // https://github.com/tc39/proposal-well-formed-stringify
27 $({ target: 'JSON', stat: true, forced: FORCED }, {
28 // eslint-disable-next-line no-unused-vars -- required for `.length`
29 stringify: function stringify(it, replacer, space) {
30 var result = $stringify.apply(null, arguments);
31 return typeof result == 'string' ? result.replace(re, fix) : result;
32 }
33 });
34}
Note: See TracBrowser for help on using the repository browser.