massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.escape.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 charAt = uncurryThis(''.charAt);
7 var charCodeAt = uncurryThis(''.charCodeAt);
8 var exec = uncurryThis(/./.exec);
9 var numberToString = uncurryThis(1.0.toString);
10 var toUpperCase = uncurryThis(''.toUpperCase);
11
12 var raw = /[\w*+\-./@]/;
13
14 var hex = function (code, length) {
15   var result = numberToString(code, 16);
16   while (result.length < length) result = '0' + result;
17   return result;
18 };
19
20 // `escape` method
21 // https://tc39.es/ecma262/#sec-escape-string
22 $({ global: true }, {
23   escape: function escape(string) {
24     var str = toString(string);
25     var result = '';
26     var length = str.length;
27     var index = 0;
28     var chr, code;
29     while (index < length) {
30       chr = charAt(str, index++);
31       if (exec(raw, chr)) {
32         result += chr;
33       } else {
34         code = charCodeAt(chr, 0);
35         if (code < 256) {
36           result += '%' + hex(code, 2);
37         } else {
38           result += '%u' + toUpperCase(hex(code, 4));
39         }
40       }
41     } return result;
42   }
43 });