Server IP : 85.214.239.14 / Your IP : 3.144.26.99 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/anymatch/ |
Upload File : |
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); const picomatch = require('picomatch'); const normalizePath = require('normalize-path'); /** * @typedef {(testString: string) => boolean} AnymatchFn * @typedef {string|RegExp|AnymatchFn} AnymatchPattern * @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher */ const BANG = '!'; const DEFAULT_OPTIONS = {returnIndex: false}; const arrify = (item) => Array.isArray(item) ? item : [item]; /** * @param {AnymatchPattern} matcher * @param {object} options * @returns {AnymatchFn} */ const createPattern = (matcher, options) => { if (typeof matcher === 'function') { return matcher; } if (typeof matcher === 'string') { const glob = picomatch(matcher, options); return (string) => matcher === string || glob(string); } if (matcher instanceof RegExp) { return (string) => matcher.test(string); } return (string) => false; }; /** * @param {Array<Function>} patterns * @param {Array<Function>} negPatterns * @param {String|Array} args * @param {Boolean} returnIndex * @returns {boolean|number} */ const matchPatterns = (patterns, negPatterns, args, returnIndex) => { const isList = Array.isArray(args); const _path = isList ? args[0] : args; if (!isList && typeof _path !== 'string') { throw new TypeError('anymatch: second argument must be a string: got ' + Object.prototype.toString.call(_path)) } const path = normalizePath(_path, false); for (let index = 0; index < negPatterns.length; index++) { const nglob = negPatterns[index]; if (nglob(path)) { return returnIndex ? -1 : false; } } const applied = isList && [path].concat(args.slice(1)); for (let index = 0; index < patterns.length; index++) { const pattern = patterns[index]; if (isList ? pattern(...applied) : pattern(path)) { return returnIndex ? index : true; } } return returnIndex ? -1 : false; }; /** * @param {AnymatchMatcher} matchers * @param {Array|string} testString * @param {object} options * @returns {boolean|number|Function} */ const anymatch = (matchers, testString, options = DEFAULT_OPTIONS) => { if (matchers == null) { throw new TypeError('anymatch: specify first argument'); } const opts = typeof options === 'boolean' ? {returnIndex: options} : options; const returnIndex = opts.returnIndex || false; // Early cache for matchers. const mtchers = arrify(matchers); const negatedGlobs = mtchers .filter(item => typeof item === 'string' && item.charAt(0) === BANG) .map(item => item.slice(1)) .map(item => picomatch(item, opts)); const patterns = mtchers .filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG)) .map(matcher => createPattern(matcher, opts)); if (testString == null) { return (testString, ri = false) => { const returnIndex = typeof ri === 'boolean' ? ri : false; return matchPatterns(patterns, negatedGlobs, testString, returnIndex); } } return matchPatterns(patterns, negatedGlobs, testString, returnIndex); }; anymatch.default = anymatch; module.exports = anymatch;