1 | var specials = [
|
2 | '-',
|
3 | '[',
|
4 | ']',
|
5 | '/',
|
6 | '{',
|
7 | '}',
|
8 | '(',
|
9 | ')',
|
10 | '*',
|
11 | '+',
|
12 | '?',
|
13 | '.',
|
14 | '\\',
|
15 | '^',
|
16 | '$',
|
17 | '|',
|
18 | ];
|
19 | var regex = RegExp('[' + specials.join('\\') + ']', 'g');
|
20 | export function escapeForRegExp(str) {
|
21 | return str.replace(regex, '\\$&');
|
22 | }
|
23 | export function unifyPath(path) {
|
24 | return path ? path.replace(/\\/g, '/') : path;
|
25 | }
|
26 | export 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 |
|
\ | No newline at end of file |