source: trip-planner-front/node_modules/picomatch/lib/constants.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.3 KB
Line 
1'use strict';
2
3const path = require('path');
4const WIN_SLASH = '\\\\/';
5const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
6
7/**
8 * Posix glob regex
9 */
10
11const DOT_LITERAL = '\\.';
12const PLUS_LITERAL = '\\+';
13const QMARK_LITERAL = '\\?';
14const SLASH_LITERAL = '\\/';
15const ONE_CHAR = '(?=.)';
16const QMARK = '[^/]';
17const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
18const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
19const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
20const NO_DOT = `(?!${DOT_LITERAL})`;
21const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
22const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
23const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
24const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
25const STAR = `${QMARK}*?`;
26
27const POSIX_CHARS = {
28 DOT_LITERAL,
29 PLUS_LITERAL,
30 QMARK_LITERAL,
31 SLASH_LITERAL,
32 ONE_CHAR,
33 QMARK,
34 END_ANCHOR,
35 DOTS_SLASH,
36 NO_DOT,
37 NO_DOTS,
38 NO_DOT_SLASH,
39 NO_DOTS_SLASH,
40 QMARK_NO_DOT,
41 STAR,
42 START_ANCHOR
43};
44
45/**
46 * Windows glob regex
47 */
48
49const WINDOWS_CHARS = {
50 ...POSIX_CHARS,
51
52 SLASH_LITERAL: `[${WIN_SLASH}]`,
53 QMARK: WIN_NO_SLASH,
54 STAR: `${WIN_NO_SLASH}*?`,
55 DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
56 NO_DOT: `(?!${DOT_LITERAL})`,
57 NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
58 NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
59 NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
60 QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
61 START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
62 END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
63};
64
65/**
66 * POSIX Bracket Regex
67 */
68
69const POSIX_REGEX_SOURCE = {
70 alnum: 'a-zA-Z0-9',
71 alpha: 'a-zA-Z',
72 ascii: '\\x00-\\x7F',
73 blank: ' \\t',
74 cntrl: '\\x00-\\x1F\\x7F',
75 digit: '0-9',
76 graph: '\\x21-\\x7E',
77 lower: 'a-z',
78 print: '\\x20-\\x7E ',
79 punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
80 space: ' \\t\\r\\n\\v\\f',
81 upper: 'A-Z',
82 word: 'A-Za-z0-9_',
83 xdigit: 'A-Fa-f0-9'
84};
85
86module.exports = {
87 MAX_LENGTH: 1024 * 64,
88 POSIX_REGEX_SOURCE,
89
90 // regular expressions
91 REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
92 REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
93 REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
94 REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
95 REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
96 REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
97
98 // Replace globs with equivalent patterns to reduce parsing time.
99 REPLACEMENTS: {
100 '***': '*',
101 '**/**': '**',
102 '**/**/**': '**'
103 },
104
105 // Digits
106 CHAR_0: 48, /* 0 */
107 CHAR_9: 57, /* 9 */
108
109 // Alphabet chars.
110 CHAR_UPPERCASE_A: 65, /* A */
111 CHAR_LOWERCASE_A: 97, /* a */
112 CHAR_UPPERCASE_Z: 90, /* Z */
113 CHAR_LOWERCASE_Z: 122, /* z */
114
115 CHAR_LEFT_PARENTHESES: 40, /* ( */
116 CHAR_RIGHT_PARENTHESES: 41, /* ) */
117
118 CHAR_ASTERISK: 42, /* * */
119
120 // Non-alphabetic chars.
121 CHAR_AMPERSAND: 38, /* & */
122 CHAR_AT: 64, /* @ */
123 CHAR_BACKWARD_SLASH: 92, /* \ */
124 CHAR_CARRIAGE_RETURN: 13, /* \r */
125 CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
126 CHAR_COLON: 58, /* : */
127 CHAR_COMMA: 44, /* , */
128 CHAR_DOT: 46, /* . */
129 CHAR_DOUBLE_QUOTE: 34, /* " */
130 CHAR_EQUAL: 61, /* = */
131 CHAR_EXCLAMATION_MARK: 33, /* ! */
132 CHAR_FORM_FEED: 12, /* \f */
133 CHAR_FORWARD_SLASH: 47, /* / */
134 CHAR_GRAVE_ACCENT: 96, /* ` */
135 CHAR_HASH: 35, /* # */
136 CHAR_HYPHEN_MINUS: 45, /* - */
137 CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
138 CHAR_LEFT_CURLY_BRACE: 123, /* { */
139 CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
140 CHAR_LINE_FEED: 10, /* \n */
141 CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
142 CHAR_PERCENT: 37, /* % */
143 CHAR_PLUS: 43, /* + */
144 CHAR_QUESTION_MARK: 63, /* ? */
145 CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
146 CHAR_RIGHT_CURLY_BRACE: 125, /* } */
147 CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
148 CHAR_SEMICOLON: 59, /* ; */
149 CHAR_SINGLE_QUOTE: 39, /* ' */
150 CHAR_SPACE: 32, /* */
151 CHAR_TAB: 9, /* \t */
152 CHAR_UNDERSCORE: 95, /* _ */
153 CHAR_VERTICAL_LINE: 124, /* | */
154 CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
155
156 SEP: path.sep,
157
158 /**
159 * Create EXTGLOB_CHARS
160 */
161
162 extglobChars(chars) {
163 return {
164 '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
165 '?': { type: 'qmark', open: '(?:', close: ')?' },
166 '+': { type: 'plus', open: '(?:', close: ')+' },
167 '*': { type: 'star', open: '(?:', close: ')*' },
168 '@': { type: 'at', open: '(?:', close: ')' }
169 };
170 },
171
172 /**
173 * Create GLOB_CHARS
174 */
175
176 globChars(win32) {
177 return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
178 }
179};
Note: See TracBrowser for help on using the repository browser.