source: node_modules/core-js-pure/modules/esnext.regexp.escape.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 774 bytes
Line 
1'use strict';
2var $ = require('../internals/export');
3var uncurryThis = require('../internals/function-uncurry-this');
4var toString = require('../internals/to-string');
5var WHITESPACES = require('../internals/whitespaces');
6
7var charCodeAt = uncurryThis(''.charCodeAt);
8var replace = uncurryThis(''.replace);
9var NEED_ESCAPING = RegExp('[!"#$%&\'()*+,\\-./:;<=>?@[\\\\\\]^`{|}~' + WHITESPACES + ']', 'g');
10
11// `RegExp.escape` method
12// https://github.com/tc39/proposal-regex-escaping
13$({ target: 'RegExp', stat: true, forced: true }, {
14 escape: function escape(S) {
15 var str = toString(S);
16 var firstCode = charCodeAt(str, 0);
17 // escape first DecimalDigit
18 return (firstCode > 47 && firstCode < 58 ? '\\x3' : '') + replace(str, NEED_ESCAPING, '\\$&');
19 }
20});
Note: See TracBrowser for help on using the repository browser.