massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.unescape.js
1 'use strict';
2 var $ = require('../internals/export');
3 var uncurryThis = require('../internals/function-uncurry-this');
4 var toString = require('../internals/to-string');
5
6 var fromCharCode = String.fromCharCode;
7 var charAt = uncurryThis(''.charAt);
8 var exec = uncurryThis(/./.exec);
9 var stringSlice = uncurryThis(''.slice);
10
11 var hex2 = /^[\da-f]{2}$/i;
12 var hex4 = /^[\da-f]{4}$/i;
13
14 // `unescape` method
15 // https://tc39.es/ecma262/#sec-unescape-string
16 $({ global: true }, {
17   unescape: function unescape(string) {
18     var str = toString(string);
19     var result = '';
20     var length = str.length;
21     var index = 0;
22     var chr, part;
23     while (index < length) {
24       chr = charAt(str, index++);
25       if (chr === '%') {
26         if (charAt(str, index) === 'u') {
27           part = stringSlice(str, index + 1, index + 5);
28           if (exec(hex4, part)) {
29             result += fromCharCode(parseInt(part, 16));
30             index += 5;
31             continue;
32           }
33         } else {
34           part = stringSlice(str, index, index + 2);
35           if (exec(hex2, part)) {
36             result += fromCharCode(parseInt(part, 16));
37             index += 2;
38             continue;
39           }
40         }
41       }
42       result += chr;
43     } return result;
44   }
45 });