UNPKG

665 BJavaScriptView Raw
1var specials = [
2 '-',
3 '[',
4 ']',
5 '/',
6 '{',
7 '}',
8 '(',
9 ')',
10 '*',
11 '+',
12 '?',
13 '.',
14 '\\',
15 '^',
16 '$',
17 '|',
18];
19var regex = RegExp('[' + specials.join('\\') + ']', 'g');
20export function escapeForRegExp(str) {
21 return str.replace(regex, '\\$&');
22}
23export function unifyPath(path) {
24 return path ? path.replace(/\\/g, '/') : path;
25}
26export function hashCode(text) {
27 var i, chr, len;
28 var hash = 0;
29 for (i = 0, len = text.length; i < len; i++) {
30 chr = text.charCodeAt(i);
31 hash = (hash << 5) - hash + chr;
32 hash |= 0;
33 }
34 return hash;
35}
36//# sourceMappingURL=utils.js.map
\No newline at end of file