r exp = 0; var res; var parts = str.split('{,}'); if (opts.nodupes) { return fn(parts.join(''), opts); } exp = parts.length - 1; res = fn(parts.join(esc), opts); var len = res.length; var arr = []; var i = 0; while (len--) { var ele = res[i++]; var idx = ele.indexOf(esc); if (idx === -1) { arr.push(ele); } else { ele = ele.split('__ESC_EXP__').join(''); if (!!ele && opts.nodupes !== false) { arr.push(ele); } else { var num = Math.pow(2, exp); arr.push.apply(arr, repeatElement(ele, num)); } } } return arr; } /** * Wrap a value with parens, brackets or braces, * based on the given character/separator. * * @param {String|Array} `val` * @param {String} `ch` * @return {String} */ function wrap$1(val, ch) { if (ch === '|') { return '(' + val.join(ch) + ')'; } if (ch === ',') { return '{' + val.join(ch) + '}'; } if (ch === '-') { return '[' + val.join(ch) + ']'; } if (ch === '\\') { return '\\{' + val + '\\}'; } } /** * Handle empty braces: `{}` */ function emptyBraces(str, arr, opts) { return braces(str.split('{}').join('\\{\\}'), arr, opts); } /** * Filter out empty-ish values */ function filterEmpty(ele) { return !!ele && ele !== '\\'; } /** * Handle patterns with whitespace */ function splitWhitespace(str) { var segs = str.split(' '); var len = segs.length; var res = []; var i = 0; while (len--) { res.push.apply(res, braces(segs[i++])); } return res; } /** * Handle escaped braces: `\\{foo,bar}` */ function escapeBraces(str, arr, opts) { if (!/\{[^{]+\{/.test(str)) { return arr.concat(str.split('\\').join('')); } else { str = str.split('\\{').join('__LT_BRACE__'); str = str.split('\\}').join('__RT_BRACE__'); return map$3(braces(str, arr, opts), function(ele) { ele = ele.split('__LT_BRACE__').join('{'); return ele.split('__RT_BRACE__').join('}'); }); } } /** * Handle escaped dots: `{1\\.2}` */ function escapeDots(str, arr, opts) { if (!/[^\\]\..+\\\./.test(str)) { return arr.concat(str.split('\\').join('')); } else { str = str.split('\\.').join('__ESC_DOT__'); return map$3(braces(str, arr, opts), function(ele) { return ele.split('__ESC_DOT__').join('.'); }); } } /** * Handle escaped dots: `{1\\.2}` */ function escapePaths(str, arr, opts) { str = str.split('\/.').join('__ESC_PATH__'); return map$3(braces(str, arr, opts), function(ele) { return ele.split('__ESC_PATH__').join('\/.'); }); } /** * Handle escaped commas: `{a\\,b}` */ function escapeCommas(str, arr, opts) { if (!/\w,/.test(str)) { return arr.concat(str.split('\\').join('')); } else { str = str.split('\\,').join('__ESC_COMMA__'); return map$3(braces(str, arr, opts), function(ele) { return ele.split('__ESC_COMMA__').join(','); }); } } /** * Regex for common patterns */ function patternRegex() { return /\${|( (?=[{,}])|(?=[{,}]) )|{}|{,}|\\,(?=.*[{}])|\/\.(?=.*[{}])|\\\.(?={)|\\{|\\}/; } /** * Braces regex. */ function braceRegex() { return /.*(\\?\{([^}]+)\})/; } /** * es6 delimiter regex. */ function es6Regex() { return /\$\{([^}]+)\}/; } var braceRe; var patternRe; /** * Faster alternative to `String.replace()` when the * index of the token to be replaces can't be supplied */ function splice(str, token, replacement) { var i = str.indexOf(token); return str.substr(0, i) + replacement + str.substr(i + token.length); } /** * Fast array map */ function map$3(arr, fn) { if (arr == null) { return []; } var len = arr.length; var res = new Array(len); var i = -1; while (++i < len) { res[i] = fn(arr[i], i, arr); } return res; } /** * Fast array filter */ function filter$2(arr, cb) { if (arr == null) return []; if (typeof cb !== 'function') { throw new TypeError('braces: filter expects a callback function.'); } var len = arr.length; var res = arr.slice(); var i = 0; while (len--) { if (!cb(arr[len], i++)) { res.splice(len, 1); } } return res; } /*! * is-posix-bracket <https://github.com/jonschlinkert/is-posix-bracket> * * Copyright (c) 2015-2016, Jon Schlinkert. * Licensed under the MIT License. */ var isPosixBracket = function isPosixBracket(str) { return typeof str === 'string' && /\[([:.=+])(?:[^\[\]]|)+\1\]/.test(str); }; /** * POSIX character classes */ var POSIX = { alnum: 'a-zA-Z0-9', alpha: 'a-zA-Z', blank: ' \\t', cntrl: '\\x00-\\x1F\\x7F', digit: '0-9', graph: '\\x21-\\x7E', lower: 'a-z', print: '\\x20-\\x7E', punct: '-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~', space: ' \\t\\r\\n\\v\\f', upper: 'A-Z', word: 'A-Za-z0-9_', xdigit: 'A-Fa-f0-9', }; /** * Expose `brackets` */ var expandBrackets = brackets; function brackets(str) { if (!isPosixBracket(str)) { return str; } var negated = false; if (str.indexOf('[^') !== -1) { negated = true; str = str.split('[^').join('['); } if (str.indexOf('[!') !== -1) { negated = true; str = str.split('[!').join('['); } var a = str.split('['); var b = str.split(']'); var imbalanced = a.length !== b.length; var parts = str.split(/(?::\]\[:|\[?\[:|:\]\]?)/); var len = parts.length, i = 0; var end = '', beg = ''; var res = []; // start at the end (innermost) first while (len--) { var inner = parts[i++]; if (inner === '^[!' || inner === '[!') { inner = ''; negated = true; } var prefix = negated ? '^' : ''; var ch = POSIX[inner]; if (ch) { res.push('[' + prefix + ch + ']'); } else if (inner) { if (/^\[?\w-\w\]?$/.test(inner)) { if (i === parts.length) { res.push('[' + prefix + inner); } else if (i === 1) { res.push(prefix + inner + ']'); } else { res.push(prefix + inner); } } else { if (i === 1) { beg += inner; } else if (i === parts.length) { end += inner; } else { res.push('[' + prefix + inner + ']'); } } } } var result = res.join('|'); var rlen = res.length || 1; if (rlen > 1) { result = '(?:' + result + ')'; rlen = 1; } if (beg) { rlen++; if (beg.charAt(0) === '[') { if (imbalanced) { beg = '\\[' + beg.slice(1); } else { beg += ']'; } } result = beg + result; } if (end) { rlen++; if (end.slice(-1) === ']') { if (imbalanced) { end = end.slice(0, end.length - 1) + '\\]'; } else { end = '[' + end; } } result += end; } if (rlen > 1) { result = result.split('][').join(']|['); if (result.indexOf('|') !== -1 && !/\(\?/.test(result)) { result = '(?:' + result + ')'; } } result = result.replace(/\[+=|=\]+/g, '\\b'); return result; } brackets.makeRe = function(pattern) { try { return new RegExp(brackets(pattern)); } catch (err) {} }; brackets.isMatch = function(str, pattern) { try { return brackets.makeRe(pattern).test(str); } catch (err) { return false; } }; brackets.match = function(arr, pattern) { var len = arr.length, i = 0; var res = arr.slice(); var re = brackets.makeRe(pattern); while (i < len) { var ele = arr[i++]; if (!re.test(ele)) { continue; } res.splice(i, 1); } return res; }; /*! * is-extglob <https://github.com/jonschlinkert/is-extglob> * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ var isExtglob = function isExtglob(str) { return typeof str === 'string' && /[@?!+*]\(/.test(str); }; /** * Module dependencies */ var re; var cache$2 = {}; /** * Expose `extglob` */ var extglob_1 = extglob; /** * Convert the given extglob `string` to a regex-compatible * string. * * ```js * var extglob = require('extglob'); * extglob('!(a?(b))'); * //=> '(?!a(?:b)?)[^/]*?' * ``` * * @param {String} `str` The string to convert. * @param {Object} `options` * @option {Boolean} [options] `esc` If `false` special characters will not be escaped. Defaults to `true`. * @option {Boolean} [options] `regex` If `true` a regular expression is returned instead of a string. * @return {String} * @api public */ function extglob(str, opts) { opts = opts || {}; var o = {}, i = 0; // fix common character reversals // '*!(.js)' => '*.!(js)' str = str.replace(/!\(([^\w*()])/g, '$1!('); // support file extension negation str = str.replace(/([*\/])\.!\([*]\)/g, function (m, ch) { if (ch === '/') { return escape('\\/[^.]+'); } return escape('[^.]+'); }); // create a unique key for caching by // combining the string and options var key = str + String(!!opts.regex) + String(!!opts.contains) + String(!!opts.escape); if (cache$2.hasOwnProperty(key)) { return cache$2[key]; } if (!(re instanceof RegExp)) { re = regex(); } opts.negate = false; var m; while (m = re.exec(str)) { var prefix = m[1]; var inner = m[3]; if (prefix === '!') { opts.negate = true; } var id = '__EXTGLOB_' + (i++) + '__'; // use the prefix of the _last_ (outtermost) pattern o[id] = wrap$3(inner, prefix, opts.escape); str = str.split(m[0]).join(id); } var keys = Object.keys(o); var len = keys.length; // we have to loop again to allow us to convert // patterns in reverse order (starting with the // innermost/last pattern first) while (len--) { var prop = keys[len]; str = str.split(prop).join(o[prop]); } var result = opts.regex ? toRegex$1(str, opts.contains, opts.negate) : str; result = result.split('.').join('\\.'); // cache the result and return it return (cache$2[key] = result); } /** * Convert `string` to a regex string. * * @param {String} `str` * @param {String} `prefix` Character that determines how to wrap the string. * @param {Boolean} `esc` If `false` special characters will not be escaped. Defaults to `true`. * @return {String} */ function wrap$3(inner, prefix, esc) { if (esc) inner = escape(inner); switch (prefix) { case '!': return '(?!' + inner + ')[^/]' + (esc ? '%%%~' : '*?'); case '@': return '(?:' + inner + ')'; case '+': return '(?:' + inner + ')+'; case '*': return '(?:' + inner + ')' + (esc ? '%%' : '*') case '?': return '(?:' + inner + '|)'; default: return inner; } } function escape(str) { str = str.split('*').join('[^/]%%%~'); str = str.split('.').join('\\.'); return str; } /** * extglob regex. */ function regex() { return /(\\?[@?!+*$]\\?)(\(([^()]*?)\))/; } /** * Negation regex */ function negate(str) { return '(?!^' + str + ').*$'; } /** * Create the regex to do the matching. If * the leading character in the `pattern` is `!` * a negation regex is returned. * * @param {String} `pattern` * @param {Boolean} `contains` Allow loose matching. * @param {Boolean} `isNegated` True if the pattern is a negation pattern. */ function toRegex$1(pattern, contains, isNegated) { var prefix = contains ? '^' : ''; var after = contains ? '$' : ''; pattern = ('(?:' + pattern + ')' + after); if (isNegated) { pattern = prefix + negate(pattern); } return new RegExp(prefix + pattern); } /*! * is-glob <https://github.com/jonschlinkert/is-glob> * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ var isGlob = function isGlob(str) { return typeof str === 'string' && (/[*!?{}(|)[\]]/.test(str) || isExtglob(str)); }; var isWin = process$3.platform === 'win32'; var removeTrailingSeparator = function (str) { var i = str.length - 1; if (i < 2) { return str; } while (isSeparator(str, i)) { i--; } return str.substr(0, i + 1); }; function isSeparator(str, i) { var char = str[i]; return i > 0 && (char === '/' || (isWin && char === '\\')); } /*! * normalize-path <https://github.com/jonschlinkert/normalize-path> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ var normalizePath = function normalizePath(str, stripTrailing) { if (typeof str !== 'string') { throw new TypeError('expected a string'); } str = str.replace(/[\\\/]+/g, '/'); if (stripTrailing !== false) { str = removeTrailingSeparator(str); } return str; }; /*! * is-extendable <https://github.com/jonschlinkert/is-extendable> * * Copyright (c) 2015, Jon Schlinkert. * Licensed under the MIT License. */ var isExtendable = function isExtendable(val) { return typeof val !== 'undefined' && val !== null && (typeof val === 'object' || typeof val === 'function'); }; /*! * for-in <https://github.com/jonschlinkert/for-in> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ var forIn = function forIn(obj, fn, thisArg) { for (var key in obj) { if (fn.call(thisArg, obj[key], key, obj) === false) { break; } } }; var hasOwn = Object.prototype.hasOwnProperty; var forOwn = function forOwn(obj, fn, thisArg) { forIn(obj, function(val, key) { if (hasOwn.call(obj, key)) { return fn.call(thisArg, obj[key], key, obj); } }); }; var object_omit = function omit(obj, keys) { if (!isExtendable(obj)) return {}; keys = [].concat.apply([], [].slice.call(arguments, 1)); var last = keys[keys.length - 1]; var res = {}, fn; if (typeof last === 'function') { fn = keys.pop(); } var isFunction = typeof fn === 'function'; if (!keys.length && !isFunction) { return obj; } forOwn(obj, function(value, key) { if (keys.indexOf(key) === -1) { if (!isFunction) { res[key] = value; } else if (fn(value, key, obj)) { res[key] = value; } } }); return res; }; var globParent = function globParent(str) { str += 'a'; // preserves full path in case of trailing path separator do {str = path$2.dirname(str);} while (isGlob(str)); return str; }; var globBase = function globBase(pattern) { if (typeof pattern !== 'string') { throw new TypeError('glob-base expects a string.'); } var res = {}; res.base = globParent(pattern); res.isGlob = isGlob(pattern); if (res.base !== '.') { res.glob = pattern.substr(res.base.length); if (res.glob.charAt(0) === '/') { res.glob = res.glob.substr(1); } } else { res.glob = pattern; } if (!res.isGlob) { res.base = dirname$1(pattern); res.glob = res.base !== '.' ? pattern.substr(res.base.length) : pattern; } if (res.glob.substr(0, 2) === './') { res.glob = res.glob.substr(2); } if (res.glob.charAt(0) === '/') { res.glob = res.glob.substr(1); } return res; }; function dirname$1(glob) { if (glob.slice(-1) === '/') return glob; return path$2.dirname(glob); } /*! * is-dotfile <https://github.com/jonschlinkert/is-dotfile> * * Copyright (c) 2015-2017, Jon Schlinkert. * Released under the MIT License. */ var isDotfile = function(str) { if (str.charCodeAt(0) === 46 /* . */ && str.indexOf('/', 1) === -1) { return true; } var slash = str.lastIndexOf('/'); return slash !== -1 ? str.charCodeAt(slash + 1) === 46 /* . */ : false; }; var parseGlob = createCommonjsModule(function (module) { /*! * parse-glob <https://github.com/jonschlinkert/parse-glob> * * Copyright (c) 2015, Jon Schlinkert. * Licensed under the MIT License. */ var cache = module.exports.cache = {}; /** * Parse a glob pattern into tokens. * * When no paths or '**' are in the glob, we use a * different strategy for parsing the filename, since * file names can contain braces and other difficult * patterns. such as: * * - `*.{a,b}` * - `(**|*.js)` */ module.exports = function parseGlob(glob) { if (cache.hasOwnProperty(glob)) { return cache[glob]; } var tok = {}; tok.orig = glob; tok.is = {}; // unescape dots and slashes in braces/brackets glob = escape(glob); var parsed = globBase(glob); tok.is.glob = parsed.isGlob; tok.glob = parsed.glob; tok.base = parsed.base; var segs = /([^\/]*)$/.exec(glob); tok.path = {}; tok.path.dirname = ''; tok.path.basename = segs[1] || ''; tok.path.dirname = glob.split(tok.path.basename).join('') || ''; var basename = (tok.path.basename || '').split('.') || ''; tok.path.filename = basename[0] || ''; tok.path.extname = basename.slice(1).join('.') || ''; tok.path.ext = ''; if (isGlob(tok.path.dirname) && !tok.path.basename) { if (!/\/$/.test(tok.glob)) { tok.path.basename = tok.glob; } tok.path.dirname = tok.base; } if (glob.indexOf('/') === -1 && !tok.is.globstar) { tok.path.dirname = ''; tok.path.basename = tok.orig; } var dot = tok.path.basename.indexOf('.'); if (dot !== -1) { tok.path.filename = tok.path.basename.slice(0, dot); tok.path.extname = tok.path.basename.slice(dot); } if (tok.path.extname.charAt(0) === '.') { var exts = tok.path.extname.split('.'); tok.path.ext = exts[exts.length - 1]; } // unescape dots and slashes in braces/brackets tok.glob = unescape(tok.glob); tok.path.dirname = unescape(tok.path.dirname); tok.path.basename = unescape(tok.path.basename); tok.path.filename = unescape(tok.path.filename); tok.path.extname = unescape(tok.path.extname); // Booleans var is = (glob && tok.is.glob); tok.is.negated = glob && glob.charAt(0) === '!'; tok.is.extglob = glob && isExtglob(glob); tok.is.braces = has(is, glob, '{'); tok.is.brackets = has(is, glob, '[:'); tok.is.globstar = has(is, glob, '**'); tok.is.dotfile = isDotfile(tok.path.basename) || isDotfile(tok.path.filename); tok.is.dotdir = dotdir(tok.path.dirname); return (cache[glob] = tok); }; /** * Returns true if the glob matches dot-directories. * * @param {Object} `tok` The tokens object * @param {Object} `path` The path object * @return {Object} */ function dotdir(base) { if (base.indexOf('/.') !== -1) { return true; } if (base.charAt(0) === '.' && base.charAt(1) !== '/') { return true; } return false; } /** * Returns true if the pattern has the given `ch`aracter(s) * * @param {Object} `glob` The glob pattern. * @param {Object} `ch` The character to test for * @return {Object} */ function has(is, glob, ch) { return is && glob.indexOf(ch) !== -1; } /** * Escape/unescape utils */ function escape(str) { var re = /\{([^{}]*?)}|\(([^()]*?)\)|\[([^\[\]]*?)\]/g; return str.replace(re, function (outter, braces, parens, brackets) { var inner = braces || parens || brackets; if (!inner) { return outter; } return outter.split(inner).join(esc(inner)); }); } function esc(str) { str = str.split('/').join('__SLASH__'); str = str.split('.').join('__DOT__'); return str; } function unescape(str) { str = str.split('__SLASH__').join('/'); str = str.split('__DOT__').join('.'); return str; } }); var parseGlob_1 = parseGlob.cache; /*! * is-primitive <https://github.com/jonschlinkert/is-primitive> * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ // see http://jsperf.com/testing-value-is-primitive/7 var isPrimitive = function isPrimitive(value) { return value == null || (typeof value !== 'function' && typeof value !== 'object'); }; var isEqualShallow = function isEqual(a, b) { if (!a && !b) { return true; } if (!a && b || a && !b) { return false; } var numKeysA = 0, numKeysB = 0, key; for (key in b) { numKeysB++; if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) { return false; } } for (key in a) { numKeysA++; } return numKeysA === numKeysB; }; var basic = {}; var cache$3 = {}; /** * Expose `regexCache` */ var regexCache_1 = regexCache; /** * Memoize the results of a call to the new RegExp constructor. * * @param {Function} fn [description] * @param {String} str [description] * @param {Options} options [description] * @param {Boolean} nocompare [description] * @return {RegExp} */ function regexCache(fn, str, opts) { var key = '_default_', regex, cached; if (!str && !opts) { if (typeof fn !== 'function') { return fn; } return basic[key] || (basic[key] = fn(str)); } var isString = typeof str === 'string'; if (isString) { if (!opts) { return basic[str] || (basic[str] = fn(str)); } key = str; } else { opts = str; } cached = cache$3[key]; if (cached && isEqualShallow(cached.opts, opts)) { return cached.regex; } memo(key, opts, (regex = fn(str, opts))); return regex; } function memo(key, opts, regex) { cache$3[key] = {regex: regex, opts: opts}; } /** * Expose `cache` */ var cache_1 = cache$3; var basic_1 = basic; regexCache_1.cache = cache_1; regexCache_1.basic = basic_1; var utils_1 = createCommonjsModule(function (module) { var win32 = process$3 && process$3.platform === 'win32'; var utils = module.exports; /** * Module dependencies */ utils.diff = arrDiff; utils.unique = arrayUnique; utils.braces = braces_1; utils.brackets = expandBrackets; utils.extglob = extglob_1; utils.isExtglob = isExtglob; utils.isGlob = isGlob; utils.typeOf = kindOf; utils.normalize = normalizePath; utils.omit = object_omit; utils.parseGlob = parseGlob; utils.cache = regexCache_1; /** * Get the filename of a filepath * * @param {String} `string` * @return {String} */ utils.filename = function filename(fp) { var seg = fp.match(filenameRegex()); return seg && seg[0]; }; /** * Returns a function that returns true if the given * pattern is the same as a given `filepath` * * @param {String} `pattern` * @return {Function} */ utils.isPath = function isPath(pattern, opts) { opts = opts || {}; return function(fp) { var unixified = utils.unixify(fp, opts); if(opts.nocase){ return pattern.toLowerCase() === unixified.toLowerCase(); } return pattern === unixified; }; }; /** * Returns a function that returns true if the given * pattern contains a `filepath` * * @param {String} `pattern` * @return {Function} */ utils.hasPath = function hasPath(pattern, opts) { return function(fp) { return utils.unixify(pattern, opts).indexOf(fp) !== -1; }; }; /** * Returns a function that returns true if the given * pattern matches or contains a `filepath` * * @param {String} `pattern` * @return {Function} */ utils.matchPath = function matchPath(pattern, opts) { var fn = (opts && opts.contains) ? utils.hasPath(pattern, opts) : utils.isPath(pattern, opts); return fn; }; /** * Returns a function that returns true if the given * regex matches the `filename` of a file path. * * @param {RegExp} `re` * @return {Boolean} */ utils.hasFilename = function hasFilename(re) { return function(fp) { var name = utils.filename(fp); return name && re.test(name); }; }; /** * Coerce `val` to an array * * @param {*} val * @return {Array} */ utils.arrayify = function arrayify(val) { return !Array.isArray(val) ? [val] : val; }; /** * Normalize all slashes in a file path or glob pattern to * forward slashes. */ utils.unixify = function unixify(fp, opts) { if (opts && opts.unixify === false) return fp; if (opts && opts.unixify === true || win32 || path$2.sep === '\\') { return utils.normalize(fp, false); } if (opts && opts.unescape === true) { return fp ? fp.toString().replace(/\\(\w)/g, '$1') : ''; } return fp; }; /** * Escape/unescape utils */ utils.escapePath = function escapePath(fp) { return fp.replace(/[\\.]/g, '\\$&'); }; utils.unescapeGlob = function unescapeGlob(fp) { return fp.replace(/[\\"']/g, ''); }; utils.escapeRe = function escapeRe(str) { return str.replace(/[-[\\$*+?.#^\s{}(|)\]]/g, '\\$&'); }; /** * Expose `utils` */ module.exports = utils; }); var chars = {}; var unesc; var temp; function reverse(object, prepender) { return Object.keys(object).reduce(function(reversed, key) { var newKey = prepender ? prepender + key : key; // Optionally prepend a string to key. reversed[object[key]] = newKey; // Swap key and value. return reversed; // Return the result. }, {}); } /** * Regex for common characters */ chars.escapeRegex = { '?': /\?/g, '@': /\@/g, '!': /\!/g, '+': /\+/g, '*': /\*/g, '(': /\(/g, ')': /\)/g, '[': /\[/g, ']': /\]/g }; /** * Escape characters */ chars.ESC = { '?': '__UNESC_QMRK__', '@': '__UNESC_AMPE__', '!': '__UNESC_EXCL__', '+': '__UNESC_PLUS__', '*': '__UNESC_STAR__', ',': '__UNESC_COMMA__', '(': '__UNESC_LTPAREN__', ')': '__UNESC_RTPAREN__', '[': '__UNESC_LTBRACK__', ']': '__UNESC_RTBRACK__' }; /** * Unescape characters */ chars.UNESC = unesc || (unesc = reverse(chars.ESC, '\\')); chars.ESC_TEMP = { '?': '__TEMP_QMRK__', '@': '__TEMP_AMPE__', '!': '__TEMP_EXCL__', '*': '__TEMP_STAR__', '+': '__TEMP_PLUS__', ',': '__TEMP_COMMA__', '(': '__TEMP_LTPAREN__', ')': '__TEMP_RTPAREN__', '[': '__TEMP_LTBRACK__', ']': '__TEMP_RTBRACK__' }; chars.TEMP = temp || (temp = reverse(chars.ESC_TEMP)); var chars_1 = chars; var glob = createCommonjsModule(function (module) { var Glob = module.exports = function Glob(pattern, options) { if (!(this instanceof Glob)) { return new Glob(pattern, options); } this.options = options || {}; this.pattern = pattern; this.history = []; this.tokens = {}; this.init(pattern); }; /** * Initialize defaults */ Glob.prototype.init = function(pattern) { this.orig = pattern; this.negated = this.isNegated(); this.options.track = this.options.track || false; this.options.makeRe = true; }; /** * Push a change into `glob.history`. Useful * for debugging. */ Glob.prototype.track = function(msg) { if (this.options.track) { this.history.push({msg: msg, pattern: this.pattern}); } }; /** * Return true if `glob.pattern` was negated * with `!`, also remove the `!` from the pattern. * * @return {Boolean} */ Glob.prototype.isNegated = function() { if (this.pattern.charCodeAt(0) === 33 /* '!' */) { this.pattern = this.pattern.slice(1); return true; } return false; }; /** * Expand braces in the given glob pattern. * * We only need to use the [braces] lib when * patterns are nested. */ Glob.prototype.braces = function() { if (this.options.nobraces !== true && this.options.nobrace !== true) { // naive/fast check for imbalanced characters var a = this.pattern.match(/[\{\(\[]/g); var b = this.pattern.match(/[\}\)\]]/g); // if imbalanced, don't optimize the pattern if (a && b && (a.length !== b.length)) { this.options.makeRe = false; } // expand brace patterns and join the resulting array var expanded = utils_1.braces(this.pattern, this.options); this.pattern = expanded.join('|'); } }; /** * Expand bracket expressions in `glob.pattern` */ Glob.prototype.brackets = function() { if (this.options.nobrackets !== true) { this.pattern = utils_1.brackets(this.pattern); } }; /** * Expand bracket expressions in `glob.pattern` */ Glob.prototype.extglob = function() { if (this.options.noextglob === true) return; if (utils_1.isExtglob(this.pattern)) { this.pattern = utils_1.extglob(this.pattern, {escape: true}); } }; /** * Parse the given pattern */ Glob.prototype.parse = function(pattern) { this.tokens = utils_1.parseGlob(pattern || this.pattern, true); return this.tokens; }; /** * Replace `a` with `b`. Also tracks the change before and * after each replacement. This is disabled by default, but * can be enabled by setting `options.track` to true. * * Also, when the pattern is a string, `.split()` is used, * because it's much faster than replace. * * @param {RegExp|String} `a` * @param {String} `b` * @param {Boolean} `escape` When `true`, escapes `*` and `?` in the replacement. * @return {String} */ Glob.prototype._replace = function(a, b, escape) { this.track('before (find): "' + a + '" (replace with): "' + b + '"'); if (escape) b = esc(b); if (a && b && typeof a === 'string') { this.pattern = this.pattern.split(a).join(b); } else { this.pattern = this.pattern.replace(a, b); } this.track('after'); }; /** * Escape special characters in the given string. * * @param {String} `str` Glob pattern * @return {String} */ Glob.prototype.escape = function(str) { this.track('before escape: '); var re = /["\\](['"]?[^"'\\]['"]?)/g; this.pattern = str.replace(re, function($0, $1) { var o = chars_1.ESC; var ch = o && o[$1]; if (ch) { return ch; } if (/[a-z]/i.test($0)) { return $0.split('\\').join(''); } return $0; }); this.track('after escape: '); }; /** * Unescape special characters in the given string. * * @param {String} `str` * @return {String} */ Glob.prototype.unescape = function(str) { var re = /__([A-Z]+)_([A-Z]+)__/g; this.pattern = str.replace(re, function($0, $1) { return chars_1[$1][$0]; }); this.pattern = unesc(this.pattern); }; /** * Escape/unescape utils */ function esc(str) { str = str.split('?').join('%~'); str = str.split('*').join('%%'); return str; } function unesc(str) { str = str.split('%~').join('?'); str = str.split('%%').join('*'); return str; } }); /** * Expose `expand` */ var expand_1 = expand; /** * Expand a glob pattern to resolve braces and * similar patterns before converting to regex. * * @param {String|Array} `pattern` * @param {Array} `files` * @param {Options} `opts` * @return {Array} */ function expand(pattern, options) { if (typeof pattern !== 'string') { throw new TypeError('micromatch.expand(): argument should be a string.'); } var glob$$1 = new glob(pattern, options || {}); var opts = glob$$1.options; if (!utils_1.isGlob(pattern)) { glob$$1.pattern = glob$$1.pattern.replace(/([\/.])/g, '\\$1'); return glob$$1; } glob$$1.pattern = glob$$1.pattern.replace(/(\+)(?!\()/g, '\\$1'); glob$$1.pattern = glob$$1.pattern.split('$').join('\\$'); if (typeof opts.braces !== 'boolean' && typeof opts.nobraces !== 'boolean') { opts.braces = true; } if (glob$$1.pattern === '.*') { return { pattern: '\\.' + star, tokens: tok, options: opts }; } if (glob$$1.pattern === '*') { return { pattern: oneStar(opts.dot), tokens: tok, options: opts }; } // parse the glob pattern into tokens glob$$1.parse(); var tok = glob$$1.tokens; tok.is.negated = opts.negated; // dotfile handling if ((opts.dotfiles === true || tok.is.dotfile) && opts.dot !== false) { opts.dotfiles = true; opts.dot = true; } if ((opts.dotdirs === true || tok.is.dotdir) && opts.dot !== false) { opts.dotdirs = true; opts.dot = true; } // check for braces with a dotfile pattern if (/[{,]\./.test(glob$$1.pattern)) { opts.makeRe = false; opts.dot = true; } if (opts.nonegate !== true) { opts.negated = glob$$1.negated; } // if the leading character is a dot or a slash, escape it if (glob$$1.pattern.charAt(0) === '.' && glob$$1.pattern.charAt(1) !== '/') { glob$$1.pattern = '\\' + glob$$1.pattern; } /** * Extended globs */ // expand braces, e.g `{1..5}` glob$$1.track('before braces'); if (tok.is.braces) { glob$$1.braces(); } glob$$1.track('after braces'); // expand extglobs, e.g `foo/!(a|b)` glob$$1.track('before extglob'); if (tok.is.extglob) { glob$$1.extglob(); } glob$$1.track('after extglob'); // expand brackets, e.g `[[:alpha:]]` glob$$1.track('before brackets'); if (tok.is.brackets) { glob$$1.brackets(); } glob$$1.track('after brackets'); // special patterns glob$$1._replace('[!', '[^'); glob$$1._replace('(?', '(%~'); glob$$1._replace(/\[\]/, '\\[\\]'); glob$$1._replace('/[', '/' + (opts.dot ? dotfiles : nodot) + '[', true); glob$$1._replace('/?', '/' + (opts.dot ? dotfiles : nodot) + '[^/]', true); glob$$1._replace('/.', '/(?=.)\\.', true); // windows drives glob$$1._replace(/^(\w):([\\\/]+?)/gi, '(?=.)$1:$2', true); // negate slashes in exclusion ranges if (glob$$1.pattern.indexOf('[^') !== -1) { glob$$1.pattern = negateSlash(glob$$1.pattern); } if (opts.globstar !== false && glob$$1.pattern === '**') { glob$$1.pattern = globstar(opts.dot); } else { glob$$1.pattern = balance(glob$$1.pattern, '[', ']'); glob$$1.escape(glob$$1.pattern); // if the pattern has `**` if (tok.is.globstar) { glob$$1.pattern = collapse(glob$$1.pattern, '/**'); glob$$1.pattern = collapse(glob$$1.pattern, '**/'); glob$$1._replace('/**/', '(?:/' + globstar(opts.dot) + '/|/)', true); glob$$1._replace(/\*{2,}/g, '**'); // 'foo/*' glob$$1._replace(/(\w+)\*(?!\/)/g, '$1[^/]*?', true); glob$$1._replace(/\*\*\/\*(\w)/g, globstar(opts.dot) + '\\/' + (opts.dot ? dotfiles : nodot) + '[^/]*?$1', true); if (opts.dot !== true) { glob$$1._replace(/\*\*\/(.)/g, '(?:**\\/|)$1'); } // 'foo/**' or '{**,*}', but not 'foo**' if (tok.path.dirname !== '' || /,\*\*|\*\*,/.test(glob$$1.orig)) { glob$$1._replace('**', globstar(opts.dot), true); } } // ends with /* glob$$1._replace(/\/\*$/, '\\/' + oneStar(opts.dot), true); // ends with *, no slashes glob$$1._replace(/(?!\/)\*$/, star, true); // has 'n*.' (partial wildcard w/ file extension) glob$$1._replace(/([^\/]+)\*/, '$1' + oneStar(true), true); // has '*' glob$$1._replace('*', oneStar(opts.dot), true); glob$$1._replace('?.', '?\\.', true); glob$$1._replace('?:', '?:', true); glob$$1._replace(/\?+/g, function(match) { var len = match.length; if (len === 1) { return qmark; } return qmark + '{' + len + '}'; }); // escape '.abc' => '\\.abc' glob$$1._replace(/\.([*\w]+)/g, '\\.$1'); // fix '[^\\\\/]' glob$$1._replace(/\[\^[\\\/]+\]/g, qmark); // '///' => '\/' glob$$1._replace(/\/+/g, '\\/'); // '\\\\\\' => '\\' glob$$1._replace(/\\{2,}/g, '\\'); } // unescape previously escaped patterns glob$$1.unescape(glob$$1.pattern); glob$$1._replace('__UNESC_STAR__', '*'); // escape dots that follow qmarks glob$$1._replace('?.', '?\\.'); // remove unnecessary slashes in character classes glob$$1._replace('[^\\/]', qmark); if (glob$$1.pattern.length > 1) { if (/^[\[?*]/.test(glob$$1.pattern)) { // only prepend the string if we don't want to match dotfiles glob$$1.pattern = (opts.dot ? dotfiles : nodot) + glob$$1.pattern; } } return glob$$1; } /** * Collapse repeated character sequences. * * ```js * collapse('a/../../../b', '../'); * //=> 'a/../b' * ``` * * @param {String} `str` * @param {String} `ch` Character sequence to collapse * @return {String} */ function collapse(str, ch) { var res = str.split(ch); var isFirst = res[0] === ''; var isLast = res[res.length - 1] === ''; res = res.filter(Boolean); if (isFirst) res.unshift(''); if (isLast) res.push(''); return res.join(ch); } /** * Negate slashes in exclusion ranges, per glob spec: * * ```js * negateSlash('[^foo]'); * //=> '[^\\/foo]' * ``` * * @param {String} `str` glob pattern * @return {String} */ function negateSlash(str) { return str.replace(/\[\^([^\]]*?)\]/g, function(match, inner) { if (inner.indexOf('/') === -1) { inner = '\\/' + inner; } return '[^' + inner + ']'; }); } /** * Escape imbalanced braces/bracket. This is a very * basic, naive implementation that only does enough * to serve the purpose. */ function balance(str, a, b) { var aarr = str.split(a); var alen = aarr.join('').length; var blen = str.split(b).join('').length; if (alen !== blen) { str = aarr.join('\\' + a); return str.split(b).join('\\' + b); } return str; } /** * Special patterns to be converted to regex. * Heuristics are used to simplify patterns * and speed up processing. */ /* eslint no-multi-spaces: 0 */ var qmark = '[^/]'; var star = qmark + '*?'; var nodot = '(?!\\.)(?=.)'; var dotfileGlob = '(?:\\/|^)\\.{1,2}($|\\/)'; var dotfiles = '(?!' + dotfileGlob + ')(?=.)'; var twoStarDot = '(?:(?!' + dotfileGlob + ').)*?'; /** * Create a regex for `*`. * * If `dot` is true, or the pattern does not begin with * a leading star, then return the simpler regex. */ function oneStar(dotfile) { return dotfile ? '(?!' + dotfileGlob + ')(?=.)' + star : (nodot + star); } function globstar(dotfile) { if (dotfile) { return twoStarDot; } return '(?:(?!(?:\\/|^)\\.).)*?'; } /** * The main function. Pass an array of filepaths, * and a string or array of glob patterns * * @param {Array|String} `files` * @param {Array|String} `patterns` * @param {Object} `opts` * @return {Array} Array of matches */ function micromatch(files, patterns, opts) { if (!files || !patterns) return []; opts = opts || {}; if (typeof opts.cache === 'undefined') { opts.cache = true; } if (!Array.isArray(patterns)) { return match(files, patterns, opts); } var len = patterns.length, i = 0; var omit = [], keep = []; while (len--) { var glob = patterns[i++]; if (typeof glob === 'string' && glob.charCodeAt(0) === 33 /* ! */) { omit.push.apply(omit, match(files, glob.slice(1), opts)); } else { keep.push.apply(keep, match(files, glob, opts)); } } return utils_1.diff(keep, omit); } /** * Return an array of files that match the given glob pattern. * * This function is called by the main `micromatch` function If you only * need to pass a single pattern you might get very minor speed improvements * using this function. * * @param {Array} `files` * @param {String} `pattern` * @param {Object} `options` * @return {Array} */ function match(files, pattern, opts) { if (utils_1.typeOf(files) !== 'string' && !Array.isArray(files)) { throw new Error(msg('match', 'files', 'a string or array')); } files = utils_1.arrayify(files); opts = opts || {}; var negate = opts.negate || false; var orig = pattern; if (typeof pattern === 'string') { negate = pattern.charAt(0) === '!'; if (negate) { pattern = pattern.slice(1); } // we need to remove the character regardless, // so the above logic is still needed if (opts.nonegate === true) { negate = false; } } var _isMatch = matcher(pattern, opts); var len = files.length, i = 0; var res = []; while (i < len) { var file = files[i++]; var fp = utils_1.unixify(file, opts); if (!_isMatch(fp)) { continue; } res.push(fp); } if (res.length === 0) { if (opts.failglob === true) { throw new Error('micromatch.match() found no matches for: "' + orig + '".'); } if (opts.nonull || opts.nullglob) { res.push(utils_1.unescapeGlob(orig)); } } // if `negate` was defined, diff negated files if (negate) { res = utils_1.diff(files, res); } // if `ignore` was defined, diff ignored filed if (opts.ignore && opts.ignore.length) { pattern = opts.ignore; opts = utils_1.omit(opts, ['ignore']); res = utils_1.diff(res, micromatch(res, pattern, opts)); } if (opts.nodupes) { return utils_1.unique(res); } return res; } /** * Returns a function that takes a glob pattern or array of glob patterns * to be used with `Array#filter()`. (Internally this function generates * the matching function using the [matcher] method). * * ```js * var fn = mm.filter('[a-c]'); * ['a', 'b', 'c', 'd', 'e'].filter(fn); * //=> ['a', 'b', 'c'] * ``` * @param {String|Array} `patterns` Can be a glob or array of globs. * @param {Options} `opts` Options to pass to the [matcher] method. * @return {Function} Filter function to be passed to `Array#filter()`. */ function filter$1(patterns, opts) { if (!Array.isArray(patterns) && typeof patterns !== 'string') { throw new TypeError(msg('filter', 'patterns', 'a string or array')); } patterns = utils_1.arrayify(patterns); var len = patterns.length, i = 0; var patternMatchers = Array(len); while (i < len) { patternMatchers[i] = matcher(patterns[i++], opts); } return function(fp) { if (fp == null) return []; var len = patternMatchers.length, i = 0; var res = true; fp = utils_1.unixify(fp, opts); while (i < len) { var fn = patternMatchers[i++]; if (!fn(fp)) { res = false; break; } } return res; }; } /** * Returns true if the filepath contains the given * pattern. Can also return a function for matching. * * ```js * isMatch('foo.md', '*.md', {}); * //=> true * * isMatch('*.md', {})('foo.md') * //=> true * ``` * @param {String} `fp` * @param {String} `pattern` * @param {Object} `opts` * @return {Boolean} */ function isMatch(fp, pattern, opts) { if (typeof fp !== 'string') { throw new TypeError(msg('isMatch', 'filepath', 'a string')); } fp = utils_1.unixify(fp, opts); if (utils_1.typeOf(pattern) === 'object') { return matcher(fp, pattern); } return matcher(pattern, opts)(fp); } /** * Returns true if the filepath matches the * given pattern. */ function contains(fp, pattern, opts) { if (typeof fp !== 'string') { throw new TypeError(msg('contains', 'pattern', 'a string')); } opts = opts || {}; opts.contains = (pattern !== ''); fp = utils_1.unixify(fp, opts); if (opts.contains && !utils_1.isGlob(pattern)) { return fp.indexOf(pattern) !== -1; } return matcher(pattern, opts)(fp); } /** * Returns true if a file path matches any of the * given patterns. * * @param {String} `fp` The filepath to test. * @param {String|Array} `patterns` Glob patterns to use. * @param {Object} `opts` Options to pass to the `matcher()` function. * @return {String} */ function any(fp, patterns, opts) { if (!Array.isArray(patterns) && typeof patterns !== 'string') { throw new TypeError(msg('any', 'patterns', 'a string or array')); } patterns = utils_1.arrayify(patterns); var len = patterns.length; fp = utils_1.unixify(fp, opts); while (len--) { var isMatch = matcher(patterns[len], opts); if (isMatch(fp)) { return true; } } return false; } /** * Filter the keys of an object with the given `glob` pattern * and `options` * * @param {Object} `object` * @param {Pattern} `object` * @return {Array} */ function matchKeys(obj, glob, options) { if (utils_1.typeOf(obj) !== 'object') { throw new TypeError(msg('matchKeys', 'first argument', 'an object')); } var fn = matcher(glob, options); var res = {}; for (var key in obj) { if (obj.hasOwnProperty(key) && fn(key)) { res[key] = obj[key]; } } return res; } /** * Return a function for matching based on the * given `pattern` and `options`. * * @param {String} `pattern` * @param {Object} `options` * @return {Function} */ function matcher(pattern, opts) { // pattern is a function if (typeof pattern === 'function') { return pattern; } // pattern is a regex if (pattern instanceof RegExp) { return function(fp) { return pattern.test(fp); }; } if (typeof pattern !== 'string') { throw new TypeError(msg('matcher', 'pattern', 'a string, regex, or function')); } // strings, all the way down... pattern = utils_1.unixify(pattern, opts); // pattern is a non-glob string if (!utils_1.isGlob(pattern)) { return utils_1.matchPath(pattern, opts); } // pattern is a glob string var re = makeRe(pattern, opts); // `matchBase` is defined if (opts && opts.matchBase) { return utils_1.hasFilename(re, opts); } // `matchBase` is not defined return function(fp) { fp = utils_1.unixify(fp, opts); return re.test(fp); }; } /** * Create and cache a regular expression for matching * file paths. * * If the leading character in the `glob` is `!`, a negation * regex is returned. * * @param {String} `glob` * @param {Object} `options` * @return {RegExp} */ function toRegex(glob, options) { // clone options to prevent mutating the original object var opts = Object.create(options || {}); var flags = opts.flags || ''; if (opts.nocase && flags.indexOf('i') === -1) { flags += 'i'; } var parsed = expand_1(glob, opts); // pass in tokens to avoid parsing more than once opts.negated = opts.negated || parsed.negated; opts.negate = opts.negated; glob = wrapGlob(parsed.pattern, opts); var re; try { re = new RegExp(glob, flags); return re; } catch (err) { err.reason = 'micromatch invalid regex: (' + re + ')'; if (opts.strict) throw new SyntaxError(err); } // we're only here if a bad pattern was used and the user // passed `options.silent`, so match nothing return /$^/; } /** * Create the regex to do the matching. If the leading * character in the `glob` is `!` a negation regex is returned. * * @param {String} `glob` * @param {Boolean} `negate` */ function wrapGlob(glob, opts) { var prefix = (opts && !opts.contains) ? '^' : ''; var after = (opts && !opts.contains) ? '$' : ''; glob = ('(?:' + glob + ')' + after); if (opts && opts.negate) { return prefix + ('(?!^' + glob + ').*$'); } return prefix + glob; } /** * Create and cache a regular expression for matching file paths. * If the leading character in the `glob` is `!`, a negation * regex is returned. * * @param {String} `glob` * @param {Object} `options` * @return {RegExp} */ function makeRe(glob, opts) { if (utils_1.typeOf(glob) !== 'string') { throw new Error(msg('makeRe', 'glob', 'a string')); } return utils_1.cache(toRegex, glob, opts); } /** * Make error messages consistent. Follows this format: * * ```js * msg(methodName, argNumber, nativeType); * // example: * msg('matchKeys', 'first', 'an object'); * ``` * * @param {String} `method` * @param {String} `num` * @param {String} `type` * @return {String} */ function msg(method, what, type) { return 'micromatch.' + method + '(): ' + what + ' should be ' + type + '.'; } /** * Public methods */ /* eslint no-multi-spaces: 0 */ micromatch.any = any; micromatch.braces = micromatch.braceExpand = utils_1.braces; micromatch.contains = contains; micromatch.expand = expand_1; micromatch.filter = filter$1; micromatch.isMatch = isMatch; micromatch.makeRe = makeRe; micromatch.match = match; micromatch.matcher = matcher; micromatch.matchKeys = matchKeys; /** * Expose `micromatch` */ var micromatch_1 = micromatch; var slash = function (str) { var isExtendedLengthPath = /^\\\\\?\\/.test(str); var hasNonAscii = /[^\x00-\x80]+/.test(str); if (isExtendedLengthPath || hasNonAscii) { return str; } return str.replace(/\\/g, '/'); }; var jsTokens = createCommonjsModule(function (module, exports) { // Copyright 2014, 2015, 2016, 2017 Simon Lydell // License: MIT. (See LICENSE.) Object.defineProperty(exports, "__esModule", { value: true }); // This regex comes from regex.coffee, and is inserted here by generate-index.js // (run `npm run build`). exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g; exports.matchToToken = function(match) { var token = {type: "invalid", value: match[0]}; if (match[ 1]) token.type = "string", token.closed = !!(match[3] || match[4]); else if (match[ 5]) token.type = "comment"; else if (match[ 6]) token.type = "comment", token.closed = !!match[7]; else if (match[ 8]) token.type = "regex"; else if (match[ 9]) token.type = "number"; else if (match[10]) token.type = "name"; else if (match[11]) token.type = "punctuator"; else if (match[12]) token.type = "whitespace"; return token }; }); unwrapExports(jsTokens); var jsTokens_1 = jsTokens.matchToToken; var ast = createCommonjsModule(function (module) { /* Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function () { function isExpression(node) { if (node == null) { return false; } switch (node.type) { case 'ArrayExpression': case 'AssignmentExpression': case 'BinaryExpression': case 'CallExpression': case 'ConditionalExpression': case 'FunctionExpression': case 'Identifier': case 'Literal': case 'LogicalExpression': case 'MemberExpression': case 'NewExpression': case 'ObjectExpression': case 'SequenceExpression': case 'ThisExpression': case 'UnaryExpression': case 'UpdateExpression': return true; } return false; } function isIterationStatement(node) { if (node == null) { return false; } switch (node.type) { case 'DoWhileStatement': case 'ForInStatement': case 'ForStatement': case 'WhileStatement': return true; } return false; } function isStatement(node) { if (node == null) { return false; } switch (node.type) { case 'BlockStatement': case 'BreakStatement': case 'ContinueStatement': case 'DebuggerStatement': case 'DoWhileStatement': case 'EmptyStatement': case 'ExpressionStatement': case 'ForInStatement': case 'ForStatement': case 'IfStatement': case 'LabeledStatement': case 'ReturnStatement': case 'SwitchStatement': case 'ThrowStatement': case 'TryStatement': case 'VariableDeclaration': case 'WhileStatement': case 'WithStatement': return true; } return false; } function isSourceElement(node) { return isStatement(node) || node != null && node.type === 'FunctionDeclaration'; } function trailingStatement(node) { switch (node.type) { case 'IfStatement': if (node.alternate != null) { return node.alternate; } return node.consequent; case 'LabeledStatement': case 'ForStatement': case 'ForInStatement': case 'WhileStatement': case 'WithStatement': return node.body; } return null; } function isProblematicIfStatement(node) { var current; if (node.type !== 'IfStatement') { return false; } if (node.alternate == null) { return false; } current = node.consequent; do { if (current.type === 'IfStatement') { if (current.alternate == null) { return true; } } current = trailingStatement(current); } while (current); return false; } module.exports = { isExpression: isExpression, isStatement: isStatement, isIterationStatement: isIterationStatement, isSourceElement: isSourceElement, isProblematicIfStatement: isProblematicIfStatement, trailingStatement: trailingStatement }; }()); /* vim: set sw=4 ts=4 et tw=80 : */ }); var ast_1 = ast.isExpression; var ast_2 = ast.isStatement; var ast_3 = ast.isIterationStatement; var ast_4 = ast.isSourceElement; var ast_5 = ast.isProblematicIfStatement; var ast_6 = ast.trailingStatement; var code = createCommonjsModule(function (module) { /* Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com> Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function () { var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`. ES5Regex = { // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart: NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/, // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart: NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/ }; ES6Regex = { // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart: NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/, // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart: NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ }; function isDecimalDigit(ch) { return 0x30 <= ch && ch <= 0x39; // 0..9 } function isHexDigit(ch) { return 0x30 <= ch && ch <= 0x39 || // 0..9 0x61 <= ch && ch <= 0x66 || // a..f 0x41 <= ch && ch <= 0x46; // A..F } function isOctalDigit(ch) { return ch >= 0x30 && ch <= 0x37; // 0..7 } // 7.2 White Space NON_ASCII_WHITESPACES = [ 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF ]; function isWhiteSpace(ch) { return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0; } // 7.3 Line Terminators function isLineTerminator(ch) { return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029; } // 7.6 Identifier Names and Identifiers function fromCodePoint(cp) { if (cp <= 0xFFFF) { return String.fromCharCode(cp); } var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800); var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00); return cu1 + cu2; } IDENTIFIER_START = new Array(0x80); for(ch = 0; ch < 0x80; ++ch) { IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z ch >= 0x41 && ch <= 0x5A || // A..Z ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) } IDENTIFIER_PART = new Array(0x80); for(ch = 0; ch < 0x80; ++ch) { IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z ch >= 0x41 && ch <= 0x5A || // A..Z ch >= 0x30 && ch <= 0x39 || // 0..9 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) } function isIdentifierStartES5(ch) { return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); } function isIdentifierPartES5(ch) { return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); } function isIdentifierStartES6(ch) { return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); } function isIdentifierPartES6(ch) { return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); } module.exports = { isDecimalDigit: isDecimalDigit, isHexDigit: isHexDigit, isOctalDigit: isOctalDigit, isWhiteSpace: isWhiteSpace, isLineTerminator: isLineTerminator, isIdentifierStartES5: isIdentifierStartES5, isIdentifierPartES5: isIdentifierPartES5, isIdentifierStartES6: isIdentifierStartES6, isIdentifierPartES6: isIdentifierPartES6 }; }()); /* vim: set sw=4 ts=4 et tw=80 : */ }); var code_1 = code.isDecimalDigit; var code_2 = code.isHexDigit; var code_3 = code.isOctalDigit; var code_4 = code.isWhiteSpace; var code_5 = code.isLineTerminator; var code_6 = code.isIdentifierStartES5; var code_7 = code.isIdentifierPartES5; var code_8 = code.isIdentifierStartES6; var code_9 = code.isIdentifierPartES6; var keyword = createCommonjsModule(function (module) { /* Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function () { var code$$1 = code; function isStrictModeReservedWordES6(id) { switch (id) { case 'implements': case 'interface': case 'package': case 'private': case 'protected': case 'public': case 'static': case 'let': return true; default: return false; } } function isKeywordES5(id, strict) { // yield should not be treated as keyword under non-strict mode. if (!strict && id === 'yield') { return false; } return isKeywordES6(id, strict); } function isKeywordES6(id, strict) { if (strict && isStrictModeReservedWordES6(id)) { return true; } switch (id.length) { case 2: return (id === 'if') || (id === 'in') || (id === 'do'); case 3: return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); case 4: return (id === 'this') || (id === 'else') || (id === 'case') || (id === 'void') || (id === 'with') || (id === 'enum'); case 5: return (id === 'while') || (id === 'break') || (id === 'catch') || (id === 'throw') || (id === 'const') || (id === 'yield') || (id === 'class') || (id === 'super'); case 6: return (id === 'return') || (id === 'typeof') || (id === 'delete') || (id === 'switch') || (id === 'export') || (id === 'import'); case 7: return (id === 'default') || (id === 'finally') || (id === 'extends'); case 8: return (id === 'function') || (id === 'continue') || (id === 'debugger'); case 10: return (id === 'instanceof'); default: return false; } } function isReservedWordES5(id, strict) { return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict); } function isReservedWordES6(id, strict) { return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict); } function isRestrictedWord(id) { return id === 'eval' || id === 'arguments'; } function isIdentifierNameES5(id) { var i, iz, ch; if (id.length === 0) { return false; } ch = id.charCodeAt(0); if (!code$$1.isIdentifierStartES5(ch)) { return false; } for (i = 1, iz = id.length; i < iz; ++i) { ch = id.charCodeAt(i); if (!code$$1.isIdentifierPartES5(ch)) { return false; } } return true; } function decodeUtf16(lead, trail) { return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; } function isIdentifierNameES6(id) { var i, iz, ch, lowCh, check; if (id.length === 0) { return false; } check = code$$1.isIdentifierStartES6; for (i = 0, iz = id.length; i < iz; ++i) { ch = id.charCodeAt(i); if (0xD800 <= ch && ch <= 0xDBFF) { ++i; if (i >= iz) { return false; } lowCh = id.charCodeAt(i); if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) { return false; } ch = decodeUtf16(ch, lowCh); } if (!check(ch)) { return false; } check = code$$1.isIdentifierPartES6; } return true; } function isIdentifierES5(id, strict) { return isIdentifierNameES5(id) && !isReservedWordES5(id, strict); } function isIdentifierES6(id, strict) { return isIdentifierNameES6(id) && !isReservedWordES6(id, strict); } module.exports = { isKeywordES5: isKeywordES5, isKeywordES6: isKeywordES6, isReservedWordES5: isReservedWordES5, isReservedWordES6: isReservedWordES6, isRestrictedWord: isRestrictedWord, isIdentifierNameES5: isIdentifierNameES5, isIdentifierNameES6: isIdentifierNameES6, isIdentifierES5: isIdentifierES5, isIdentifierES6: isIdentifierES6 }; }()); /* vim: set sw=4 ts=4 et tw=80 : */ }); var keyword_1 = keyword.isKeywordES5; var keyword_2 = keyword.isKeywordES6; var keyword_3 = keyword.isReservedWordES5; var keyword_4 = keyword.isReservedWordES6; var keyword_5 = keyword.isRestrictedWord; var keyword_6 = keyword.isIdentifierNameES5; var keyword_7 = keyword.isIdentifierNameES6; var keyword_8 = keyword.isIdentifierES5; var keyword_9 = keyword.isIdentifierES6; var utils$2 = createCommonjsModule(function (module, exports) { /* Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function () { exports.ast = ast; exports.code = code; exports.keyword = keyword; }()); /* vim: set sw=4 ts=4 et tw=80 : */ }); var utils_1$2 = utils$2.ast; var utils_2 = utils$2.code; var utils_3 = utils$2.keyword; var lib$1 = createCommonjsModule(function (module, exports) { exports.__esModule = true; exports.codeFrameColumns = codeFrameColumns; exports.default = _default; var _jsTokens = _interopRequireWildcard(jsTokens); var _esutils = _interopRequireDefault(utils$2); var _chalk = _interopRequireDefault(fake_chalk); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } var deprecationWarningShown = false; function getDefs(chalk) { return { keyword: chalk.cyan, capitalized: chalk.yellow, jsx_tag: chalk.yellow, punctuator: chalk.yellow, number: chalk.magenta, string: chalk.green, regex: chalk.magenta, comment: chalk.grey, invalid: chalk.white.bgRed.bold, gutter: chalk.grey, marker: chalk.red.bold }; } var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; var JSX_TAG = /^[a-z][\w-]*$/i; var BRACKET = /^[()[\]{}]$/; function getTokenType(match) { var _match$slice = match.slice(-2), offset = _match$slice[0], text = _match$slice[1]; var token = (0, _jsTokens.matchToToken)(match); if (token.type === "name") { if (_esutils.default.keyword.isReservedWordES6(token.value)) { return "keyword"; } if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) { return "jsx_tag"; } if (token.value[0] !== token.value[0].toLowerCase()) { return "capitalized"; } } if (token.type === "punctuator" && BRACKET.test(token.value)) { return "bracket"; } if (token.type === "invalid" && (token.value === "@" || token.value === "#")) { return "punctuator"; } return token.type; } function highlight(defs, text) { return text.replace(_jsTokens.default, function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var type = getTokenType(args); var colorize = defs[type]; if (colorize) { return args[0].split(NEWLINE).map(function (str) { return colorize(str); }).join("\n"); } else { return args[0]; } }); } function getMarkerLines(loc, source, opts) { var startLoc = Object.assign({}, { column: 0, line: -1 }, loc.start); var endLoc = Object.assign({}, startLoc, loc.end); var linesAbove = opts.linesAbove || 2; var linesBelow = opts.linesBelow || 3; var startLine = startLoc.line; var startColumn = startLoc.column; var endLine = endLoc.line; var endColumn = endLoc.column; var start = Math.max(startLine - (linesAbove + 1), 0); var end = Math.min(source.length, endLine + linesBelow); if (startLine === -1) { start = 0; } if (endLine === -1) { end = source.length; } var lineDiff = endLine - startLine; var markerLines = {}; if (lineDiff) { for (var i = 0; i <= lineDiff; i++) { var lineNumber = i + startLine; if (!startColumn) { markerLines[lineNumber] = true; } else if (i === 0) { var sourceLength = source[lineNumber - 1].length; markerLines[lineNumber] = [startColumn, sourceLength - startColumn]; } else if (i === lineDiff) { markerLines[lineNumber] = [0, endColumn]; } else { var _sourceLength = source[lineNumber - i].length; markerLines[lineNumber] = [0, _sourceLength]; } } } else { if (startColumn === endColumn) { if (startColumn) { markerLines[startLine] = [startColumn, 0]; } else { markerLines[startLine] = true; } } else { markerLines[startLine] = [startColumn, endColumn - startColumn]; } } return { start: start, end: end, markerLines: markerLines }; } function codeFrameColumns(rawLines, loc, opts) { if (opts === void 0) { opts = {}; } var highlighted = opts.highlightCode && _chalk.default.supportsColor || opts.forceColor; var chalk = _chalk.default; if (opts.forceColor) { chalk = new _chalk.default.constructor({ enabled: true }); } var maybeHighlight = function maybeHighlight(chalkFn, string) { return highlighted ? chalkFn(string) : string; }; var defs = getDefs(chalk); if (highlighted) rawLines = highlight(defs, rawLines); var lines = rawLines.split(NEWLINE); var _getMarkerLines = getMarkerLines(loc, lines, opts), start = _getMarkerLines.start, end = _getMarkerLines.end, markerLines = _getMarkerLines.markerLines; var numberMaxWidth = String(end).length; var frame = lines.slice(start, end).map(function (line, index) { var number = start + 1 + index; var paddedNumber = (" " + number).slice(-numberMaxWidth); var gutter = " " + paddedNumber + " | "; var hasMarker = markerLines[number]; if (hasMarker) { var markerLine = ""; if (Array.isArray(hasMarker)) { var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); var numberOfMarkers = hasMarker[1] || 1; markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); } return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join(""); } else { return " " + maybeHighlight(defs.gutter, gutter) + line; } }).join("\n"); if (highlighted) { return chalk.reset(frame); } else { return frame; } } function _default(rawLines, lineNumber, colNumber, opts) { if (opts === void 0) { opts = {}; } if (!deprecationWarningShown) { deprecationWarningShown = true; var deprecationError = new Error("Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."); deprecationError.name = "DeprecationWarning"; if (process$3.emitWarning) { process$3.emitWarning(deprecationError); } else { console.warn(deprecationError); } } colNumber = Math.max(colNumber, 0); var location = { start: { column: colNumber, line: lineNumber } }; return codeFrameColumns(rawLines, location, opts); } }); unwrapExports(lib$1); var lib_1$1 = lib$1.codeFrameColumns; var stackUtils = createCommonjsModule(function (module) { module.exports = StackUtils; function StackUtils(opts) { if (!(this instanceof StackUtils)) { throw new Error('StackUtils constructor must be called with new'); } opts = opts || {}; this._cwd = (opts.cwd || process$3.cwd()).replace(/\\/g, '/'); this._internals = opts.internals || []; this._wrapCallSite = opts.wrapCallSite || false; } module.exports.nodeInternals = nodeInternals; function nodeInternals() { if (!module.exports.natives) { module.exports.natives = Object.keys(process$3.binding('natives')); module.exports.natives.push('bootstrap_node', 'node'); } return module.exports.natives.map(function (n) { return new RegExp('\\(' + n + '\\.js:\\d+:\\d+\\)$'); }).concat([ /\s*at (bootstrap_)?node\.js:\d+:\d+?$/, /\/\.node-spawn-wrap-\w+-\w+\/node:\d+:\d+\)?$/ ]); } StackUtils.prototype.clean = function (stack) { if (!Array.isArray(stack)) { stack = stack.split('\n'); } if (!(/^\s*at /.test(stack[0])) && (/^\s*at /.test(stack[1]))) { stack = stack.slice(1); } var outdent = false; var lastNonAtLine = null; var result = []; stack.forEach(function (st) { st = st.replace(/\\/g, '/'); var isInternal = this._internals.some(function (internal) { return internal.test(st); }); if (isInternal) { return null; } var isAtLine = /^\s*at /.test(st); if (outdent) { st = st.replace(/\s+$/, '').replace(/^(\s+)at /, '$1'); } else { st = st.trim(); if (isAtLine) { st = st.substring(3); } } st = st.replace(this._cwd + '/', ''); if (st) { if (isAtLine) { if (lastNonAtLine) { result.push(lastNonAtLine); lastNonAtLine = null; } result.push(st); } else { outdent = true; lastNonAtLine = st; } } }, this); stack = result.join('\n').trim(); if (stack) { return stack + '\n'; } return ''; }; StackUtils.prototype.captureString = function (limit, fn) { if (typeof limit === 'function') { fn = limit; limit = Infinity; } if (!fn) { fn = this.captureString; } var limitBefore = Error.stackTraceLimit; if (limit) { Error.stackTraceLimit = limit; } var obj = {}; Error.captureStackTrace(obj, fn); var stack = obj.stack; Error.stackTraceLimit = limitBefore; return this.clean(stack); }; StackUtils.prototype.capture = function (limit, fn) { if (typeof limit === 'function') { fn = limit; limit = Infinity; } if (!fn) { fn = this.capture; } var prepBefore = Error.prepareStackTrace; var limitBefore = Error.stackTraceLimit; var wrapCallSite = this._wrapCallSite; Error.prepareStackTrace = function (obj, site) { if (wrapCallSite) { return site.map(wrapCallSite); } return site; }; if (limit) { Error.stackTraceLimit = limit; } var obj = {}; Error.captureStackTrace(obj, fn); var stack = obj.stack; Error.prepareStackTrace = prepBefore; Error.stackTraceLimit = limitBefore; return stack; }; StackUtils.prototype.at = function at(fn) { if (!fn) { fn = at; } var site = this.capture(1, fn)[0]; if (!site) { return {}; } var res = { line: site.getLineNumber(), column: site.getColumnNumber() }; this._setFile(res, site.getFileName()); if (site.isConstructor()) { res.constructor = true; } if (site.isEval()) { res.evalOrigin = site.getEvalOrigin(); } if (site.isNative()) { res.native = true; } var typename = null; try { typename = site.getTypeName(); } catch (er) {} if (typename && typename !== 'Object' && typename !== '[object Object]') { res.type = typename; } var fname = site.getFunctionName(); if (fname) { res.function = fname; } var meth = site.getMethodName(); if (meth && fname !== meth) { res.method = meth; } return res; }; StackUtils.prototype._setFile = function (result, filename) { if (filename) { filename = filename.replace(/\\/g, '/'); if ((filename.indexOf(this._cwd + '/') === 0)) { filename = filename.substr(this._cwd.length + 1); } result.file = filename; } }; var re = new RegExp( '^' + // Sometimes we strip out the ' at' because it's noisy '(?:\\s*at )?' + // $1 = ctor if 'new' '(?:(new) )?' + // $2 = function name (can be literally anything) // May contain method at the end as [as xyz] '(?:(.*?) \\()?' + // (eval at <anonymous> (file.js:1:1), // $3 = eval origin // $4:$5:$6 are eval file/line/col, but not normally reported '(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?' + // file:line:col // $7:$8:$9 // $10 = 'native' if native '(?:(.+?):(\\d+):(\\d+)|(native))' + // maybe close the paren, then end // if $11 is ), then we only allow balanced parens in the filename // any imbalance is placed on the fname. This is a heuristic, and // bound to be incorrect in some edge cases. The bet is that // having weird characters in method names is more common than // having weird characters in filenames, which seems reasonable. '(\\)?)$' ); var methodRe = /^(.*?) \[as (.*?)\]$/; StackUtils.prototype.parseLine = function parseLine(line) { var match = line && line.match(re); if (!match) { return null; } var ctor = match[1] === 'new'; var fname = match[2]; var evalOrigin = match[3]; var evalFile = match[4]; var evalLine = Number(match[5]); var evalCol = Number(match[6]); var file = match[7]; var lnum = match[8]; var col = match[9]; var native = match[10] === 'native'; var closeParen = match[11] === ')'; var res = {}; if (lnum) { res.line = Number(lnum); } if (col) { res.column = Number(col); } if (closeParen && file) { // make sure parens are balanced // if we have a file like "asdf) [as foo] (xyz.js", then odds are // that the fname should be += " (asdf) [as foo]" and the file // should be just "xyz.js" // walk backwards from the end to find the last unbalanced ( var closes = 0; for (var i = file.length - 1; i > 0; i--) { if (file.charAt(i) === ')') { closes ++; } else if (file.charAt(i) === '(' && file.charAt(i - 1) === ' ') { closes --; if (closes === -1 && file.charAt(i - 1) === ' ') { var before = file.substr(0, i - 1); var after = file.substr(i + 1); file = after; fname += ' (' + before; break; } } } } if (fname) { var methodMatch = fname.match(methodRe); if (methodMatch) { fname = methodMatch[1]; var meth = methodMatch[2]; } } this._setFile(res, file); if (ctor) { res.constructor = true; } if (evalOrigin) { res.evalOrigin = evalOrigin; res.evalLine = evalLine; res.evalColumn = evalCol; res.evalFile = evalFile && evalFile.replace(/\\/g, '/'); } if (native) { res.native = true; } if (fname) { res.function = fname; } if (meth && fname !== meth) { res.method = meth; } return res; }; var bound = new StackUtils(); Object.keys(StackUtils.prototype).forEach(function (key) { StackUtils[key] = bound[key].bind(bound); }); }); var stackUtils_1 = stackUtils.nodeInternals; var stackUtils_2 = stackUtils.natives; var _fs = ( empty$2 && empty$1 ) || empty$2; var build$5 = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.separateMessageFromStack = exports.formatResultsErrors = exports.formatStackTrace = exports.formatExecError = undefined; var _fs2 = _interopRequireDefault(_fs); var _path2 = _interopRequireDefault(path$2); var _chalk2 = _interopRequireDefault(fake_chalk); var _micromatch2 = _interopRequireDefault(micromatch_1); var _slash2 = _interopRequireDefault(slash); var _stackUtils2 = _interopRequireDefault(stackUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // stack utils tries to create pretty stack by making paths relative. var stackUtils$$1 = new _stackUtils2.default({ cwd: 'something which does not exist' }); /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ var nodeInternals = []; try { nodeInternals = _stackUtils2.default.nodeInternals() // this is to have the tests be the same in node 4 and node 6. // TODO: Remove when we drop support for node 4 .concat(new RegExp('internal/process/next_tick.js')); } catch (e) { // `StackUtils.nodeInternals()` fails in browsers. We don't need to remove // node internals in the browser though, so no issue. } var PATH_NODE_MODULES = _path2.default.sep + 'node_modules' + _path2.default.sep; var PATH_EXPECT_BUILD = _path2.default.sep + 'expect' + _path2.default.sep + 'build' + _path2.default.sep; // filter for noisy stack trace lines var JASMINE_IGNORE = /^\s+at(?:(?:.*?vendor\/|jasmine\-)|\s+jasmine\.buildExpectationResult)/; var JEST_INTERNALS_IGNORE = /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/; var ANONYMOUS_FN_IGNORE = /^\s+at <anonymous>.*$/; var ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(<anonymous>\).*$/; var ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(<anonymous>\).*$/; var NATIVE_NEXT_IGNORE = /^\s+at next \(native\).*$/; var TITLE_INDENT = ' '; var MESSAGE_INDENT = ' '; var STACK_INDENT = ' '; var ANCESTRY_SEPARATOR = ' \u203A '; var TITLE_BULLET = _chalk2.default.bold('\u25CF '); var STACK_TRACE_COLOR = _chalk2.default.dim; var STACK_PATH_REGEXP = /\s*at.*\(?(\:\d*\:\d*|native)\)?/; var EXEC_ERROR_MESSAGE = 'Test suite failed to run'; var ERROR_TEXT = 'Error: '; var trim = function trim(string) { return (string || '').trim(); }; // Some errors contain not only line numbers in stack traces // e.g. SyntaxErrors can contain snippets of code, and we don't // want to trim those, because they may have pointers to the column/character // which will get misaligned. var trimPaths = function trimPaths(string) { return string.match(STACK_PATH_REGEXP) ? trim(string) : string; }; var getRenderedCallsite = function getRenderedCallsite(fileContent, line) { var renderedCallsite = (0, lib$1.codeFrameColumns)(fileContent, { start: { line: line } }, { highlightCode: true }); renderedCallsite = renderedCallsite.split('\n').map(function (line) { return MESSAGE_INDENT + line; }).join('\n'); renderedCallsite = '\n' + renderedCallsite + '\n'; return renderedCallsite; }; // ExecError is an error thrown outside of the test suite (not inside an `it` or // `before/after each` hooks). If it's thrown, none of the tests in the file // are executed. var formatExecError = exports.formatExecError = function (testResult, config, options, testPath) { var error = testResult.testExecError; if (!error || typeof error === 'number') { error = new Error('Expected an Error, but "' + String(error) + '" was thrown'); error.stack = ''; } var _error = error; var message = _error.message, stack = _error.stack; if (typeof error === 'string' || !error) { error || (error = 'EMPTY ERROR'); message = ''; stack = error; } var separated = separateMessageFromStack(stack || ''); stack = separated.stack; if (separated.message.indexOf(trim(message)) !== -1) { // Often stack trace already contains the duplicate of the message message = separated.message; } message = message.split(/\n/).map(function (line) { return MESSAGE_INDENT + line; }).join('\n'); stack = stack && !options.noStackTrace ? '\n' + formatStackTrace(stack, config, options, testPath) : ''; if (message.match(/^\s*$/) && stack.match(/^\s*$/)) { // this can happen if an empty object is thrown. message = MESSAGE_INDENT + 'Error: No message was provided'; } return TITLE_INDENT + TITLE_BULLET + EXEC_ERROR_MESSAGE + '\n\n' + message + stack + '\n'; }; var removeInternalStackEntries = function removeInternalStackEntries(lines, options) { var pathCounter = 0; return lines.filter(function (line) { if (ANONYMOUS_FN_IGNORE.test(line)) { return false; } if (ANONYMOUS_PROMISE_IGNORE.test(line)) { return false; } if (ANONYMOUS_GENERATOR_IGNORE.test(line)) { return false; } if (NATIVE_NEXT_IGNORE.test(line)) { return false; } if (nodeInternals.some(function (internal) { return internal.test(line); })) { return false; } if (!STACK_PATH_REGEXP.test(line)) { return true; } if (JASMINE_IGNORE.test(line)) { return false; } if (++pathCounter === 1) { return true; // always keep the first line even if it's from Jest } if (options.noStackTrace) { return false; } if (JEST_INTERNALS_IGNORE.test(line)) { return false; } return true; }); }; var formatPaths = function formatPaths(config, options, relativeTestPath, line) { // Extract the file path from the trace line. var match = line.match(/(^\s*at .*?\(?)([^()]+)(:[0-9]+:[0-9]+\)?.*$)/); if (!match) { return line; } var filePath = (0, _slash2.default)(_path2.default.relative(config.rootDir, match[2])); // highlight paths from the current test file if (config.testMatch && config.testMatch.length && (0, _micromatch2.default)(filePath, config.testMatch) || filePath === relativeTestPath) { filePath = _chalk2.default.reset.cyan(filePath); } return STACK_TRACE_COLOR(match[1]) + filePath + STACK_TRACE_COLOR(match[3]); }; var getTopFrame = function getTopFrame(lines) { var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = _getIterator(lines), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var line = _step.value; if (line.includes(PATH_NODE_MODULES) || line.includes(PATH_EXPECT_BUILD)) { continue; } var parsedFrame = stackUtils$$1.parseLine(line.trim()); if (parsedFrame && parsedFrame.file) { return parsedFrame; } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } return null; }; var formatStackTrace = exports.formatStackTrace = function (stack, config, options, testPath) { var lines = stack.split(/\n/); var renderedCallsite = ''; var relativeTestPath = testPath ? (0, _slash2.default)(_path2.default.relative(config.rootDir, testPath)) : null; lines = removeInternalStackEntries(lines, options); var topFrame = getTopFrame(lines); if (topFrame) { var filename = topFrame.file; if (_path2.default.isAbsolute(filename)) { var fileContent = void 0; try { // TODO: check & read HasteFS instead of reading the filesystem: // see: https://github.com/facebook/jest/pull/5405#discussion_r164281696 fileContent = _fs2.default.readFileSync(filename, 'utf8'); renderedCallsite = getRenderedCallsite(fileContent, topFrame.line); } catch (e) { // the file does not exist or is inaccessible, we ignore } } } var stacktrace = lines.map(function (line) { return STACK_INDENT + formatPaths(config, options, relativeTestPath, trimPaths(line)); }).join('\n'); return renderedCallsite + stacktrace; }; var formatResultsErrors = exports.formatResultsErrors = function (testResults, config, options, testPath) { var failedResults = testResults.reduce(function (errors, result) { result.failureMessages.forEach(function (content) { return errors.push({ content: content, result: result }); }); return errors; }, []); if (!failedResults.length) { return null; } return failedResults.map(function (_ref) { var result = _ref.result, content = _ref.content; var _separateMessageFromS = separateMessageFromStack(content); var message = _separateMessageFromS.message, stack = _separateMessageFromS.stack; stack = options.noStackTrace ? '' : STACK_TRACE_COLOR(formatStackTrace(stack, config, options, testPath)) + '\n'; message = message.split(/\n/).map(function (line) { return MESSAGE_INDENT + line; }).join('\n'); var title = _chalk2.default.bold.red(TITLE_INDENT + TITLE_BULLET + result.ancestorTitles.join(ANCESTRY_SEPARATOR) + (result.ancestorTitles.length ? ANCESTRY_SEPARATOR : '') + result.title) + '\n'; return title + '\n' + message + '\n' + stack; }).join('\n'); }; // jasmine and worker farm sometimes don't give us access to the actual // Error object, so we have to regexp out the message from the stack string // to format it. var separateMessageFromStack = exports.separateMessageFromStack = function (content) { if (!content) { return { message: '', stack: '' }; } var messageMatch = content.match(/(^(.|\n)*?(?=\n\s*at\s.*\:\d*\:\d*))/); var message = messageMatch ? messageMatch[0] : 'Error'; var stack = messageMatch ? content.slice(message.length) : content; // If the error is a plain error instead of a SyntaxError or TypeError // we remove it from the message because it is generally not useful. if (message.startsWith(ERROR_TEXT)) { message = message.substr(ERROR_TEXT.length); } return { message: message, stack: stack }; }; }); unwrapExports(build$5); var build_1$2 = build$5.separateMessageFromStack; var build_2$2 = build$5.formatResultsErrors; var build_3$2 = build$5.formatStackTrace; var build_4$1 = build$5.formatExecError; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ var createMatcher = function createMatcher(matcherName, fromPromise) { return function (actual, expected) { var value = expected; var error = void 0; if (fromPromise) { error = actual; } else { if (typeof actual !== 'function') { throw new Error(build_1(matcherName, 'function', build$1(value)) + '\n\n' + 'Received value must be a function, but instead ' + ('"' + build$1(actual) + '" was found')); } try { actual(); } catch (e) { error = e; } } if (typeof expected === 'string') { expected = new RegExp(build_2$1(expected)); } if (typeof expected === 'function') { return toThrowMatchingError(matcherName, error, expected); } else if (expected instanceof RegExp) { return toThrowMatchingStringOrRegexp(matcherName, error, expected, value); } else if (expected && (typeof expected === 'undefined' ? 'undefined' : _typeof(expected)) === 'object') { return toThrowMatchingErrorInstance(matcherName, error, expected); } else if (expected === undefined) { var pass = error !== undefined; return { message: pass ? function () { return build_1('.not' + matcherName, 'function', '') + '\n\n' + 'Expected the function not to throw an error.\n' + printActualErrorMessage(error); } : function () { return build_1(matcherName, 'function', build$1(value)) + '\n\n' + 'Expected the function to throw an error.\n' + printActualErrorMessage(error); }, pass: pass }; } else { throw new Error(build_1('.not' + matcherName, 'function', build$1(value)) + '\n\n' + 'Unexpected argument passed.\nExpected: ' + (build_8('string') + ', ' + build_8('Error (type)') + ' or ' + build_8('regexp') + '.\n') + build_7('Got', String(expected), build_8)); } }; }; var matchers$2 = { toThrow: createMatcher('.toThrow'), toThrowError: createMatcher('.toThrowError') }; var toThrowMatchingStringOrRegexp = function toThrowMatchingStringOrRegexp(name, error, pattern, value) { if (error && !error.message && !error.name) { error = new Error(error); } var pass = !!(error && error.message.match(pattern)); var message = pass ? function () { return build_1('.not' + name, 'function', build$1(value)) + '\n\n' + 'Expected the function not to throw an error matching:\n' + (' ' + build_8(value) + '\n') + printActualErrorMessage(error); } : function () { return build_1(name, 'function', build$1(value)) + '\n\n' + 'Expected the function to throw an error matching:\n' + (' ' + build_8(value) + '\n') + printActualErrorMessage(error); }; return { message: message, pass: pass }; }; var toThrowMatchingErrorInstance = function toThrowMatchingErrorInstance(name, error, expectedError) { if (error && !error.message && !error.name) { error = new Error(error); } var pass = equals(error, expectedError); var message = pass ? function () { return build_1('.not' + name, 'function', 'error') + '\n\n' + 'Expected the function not to throw an error matching:\n' + (' ' + build_8(expectedError) + '\n') + printActualErrorMessage(error); } : function () { return build_1(name, 'function', 'error') + '\n\n' + 'Expected the function to throw an error matching:\n' + (' ' + build_8(expectedError) + '\n') + printActualErrorMessage(error); }; return { message: message, pass: pass }; }; var toThrowMatchingError = function toThrowMatchingError(name, error, ErrorClass) { var pass = !!(error && error instanceof ErrorClass); var message = pass ? function () { return build_1('.not' + name, 'function', 'type') + '\n\n' + 'Expected the function not to throw an error of type:\n' + (' ' + build_8(ErrorClass.name) + '\n') + printActualErrorMessage(error); } : function () { return build_1(name, 'function', 'type') + '\n\n' + 'Expected the function to throw an error of type:\n' + (' ' + build_8(ErrorClass.name) + '\n') + printActualErrorMessage(error); }; return { message: message, pass: pass }; }; var printActualErrorMessage = function printActualErrorMessage(error) { if (error) { var _separateMessageFromS = build_1$2(error.stack), message = _separateMessageFromS.message, stack = _separateMessageFromS.stack; return 'Instead, it threw:\n' + build_13(' ' + build_10(message) + build_3$2(stack, { rootDir: process$3.cwd(), testMatch: [] }, { noStackTrace: false })); } return 'But it didn\'t throw anything.'; }; var createClass = createCommonjsModule(function (module, exports) { exports.__esModule = true; var _defineProperty2 = _interopRequireDefault(defineProperty$2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; (0, _defineProperty2.default)(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); }); var _createClass = unwrapExports(createClass); /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ var AsymmetricMatcher = function AsymmetricMatcher() { _classCallCheck(this, AsymmetricMatcher); this.$$typeof = _Symbol$for('jest.asymmetricMatcher'); }; var Any = function (_AsymmetricMatcher) { _inherits(Any, _AsymmetricMatcher); function Any(sample) { _classCallCheck(this, Any); var _this = _possibleConstructorReturn(this, (Any.__proto__ || _Object$getPrototypeOf(Any)).call(this)); if (typeof sample === 'undefined') { throw new TypeError('any() expects to be passed a constructor function. ' + 'Please pass one or use anything() to match any object.'); } _this.sample = sample; return _this; } _createClass(Any, [{ key: 'asymmetricMatch', value: function asymmetricMatch(other) { if (this.sample == String) { return typeof other == 'string' || other instanceof String; } if (this.sample == Number) { return typeof other == 'number' || other instanceof Number; } if (this.sample == Function) { return typeof other == 'function' || other instanceof Function; } if (this.sample == Object) { return (typeof other === 'undefined' ? 'undefined' : _typeof(other)) == 'object'; } if (this.sample == Boolean) { return typeof other == 'boolean'; } return other instanceof this.sample; } }, { key: 'toString', value: function toString() { return 'Any'; } }, { key: 'getExpectedType', value: function getExpectedType() { if (this.sample == String) { return 'string'; } if (this.sample == Number) { return 'number'; } if (this.sample == Function) { return 'function'; } if (this.sample == Object) { return 'object'; } if (this.sample == Boolean) { return 'boolean'; } return fnNameFor(this.sample); } }, { key: 'toAsymmetricMatcher', value: function toAsymmetricMatcher() { return 'Any<' + fnNameFor(this.sample) + '>'; } }]); return Any; }(AsymmetricMatcher); var Anything = function (_AsymmetricMatcher2) { _inherits(Anything, _AsymmetricMatcher2); function Anything() { _classCallCheck(this, Anything); return _possibleConstructorReturn(this, (Anything.__proto__ || _Object$getPrototypeOf(Anything)).apply(this, arguments)); } _createClass(Anything, [{ key: 'asymmetricMatch', value: function asymmetricMatch(other) { return !isUndefined(other) && other !== null; } }, { key: 'toString', value: function toString() { return 'Anything'; } // No getExpectedType method, because it matches either null or undefined. }, { key: 'toAsymmetricMatcher', value: function toAsymmetricMatcher() { return 'Anything'; } }]); return Anything; }(AsymmetricMatcher); var ArrayContaining = function (_AsymmetricMatcher3) { _inherits(ArrayContaining, _AsymmetricMatcher3); function ArrayContaining(sample) { _classCallCheck(this, ArrayContaining); var _this3 = _possibleConstructorReturn(this, (ArrayContaining.__proto__ || _Object$getPrototypeOf(ArrayContaining)).call(this)); _this3.sample = sample; return _this3; } _createClass(ArrayContaining, [{ key: 'asymmetricMatch', value: function asymmetricMatch(other) { if (!Array.isArray(this.sample)) { throw new Error("You must provide an array to ArrayContaining, not '" + _typeof(this.sample) + "'."); } return this.sample.length === 0 || Array.isArray(other) && this.sample.every(function (item) { return other.some(function (another) { return equals(item, another); }); }); } }, { key: 'toString', value: function toString() { return 'ArrayContaining'; } }, { key: 'getExpectedType', value: function getExpectedType() { return 'array'; } }]); return ArrayContaining; }(AsymmetricMatcher); var ObjectContaining = function (_AsymmetricMatcher4) { _inherits(ObjectContaining, _AsymmetricMatcher4); function ObjectContaining(sample) { _classCallCheck(this, ObjectContaining); var _this4 = _possibleConstructorReturn(this, (ObjectContaining.__proto__ || _Object$getPrototypeOf(ObjectContaining)).call(this)); _this4.sample = sample; return _this4; } _createClass(ObjectContaining, [{ key: 'asymmetricMatch', value: function asymmetricMatch(other) { if (_typeof(this.sample) !== 'object') { throw new Error("You must provide an object to ObjectContaining, not '" + _typeof(this.sample) + "'."); } for (var property in this.sample) { if (!hasProperty(other, property) || !equals(this.sample[property], other[property])) { return false; } } return true; } }, { key: 'toString', value: function toString() { return 'ObjectContaining'; } }, { key: 'getExpectedType', value: function getExpectedType() { return 'object'; } }]); return ObjectContaining; }(AsymmetricMatcher); var StringContaining = function (_AsymmetricMatcher5) { _inherits(StringContaining, _AsymmetricMatcher5); function StringContaining(sample) { _classCallCheck(this, StringContaining); var _this5 = _possibleConstructorReturn(this, (StringContaining.__proto__ || _Object$getPrototypeOf(StringContaining)).call(this)); if (!isA('String', sample)) { throw new Error('Expected is not a string'); } _this5.sample = sample; return _this5; } _createClass(StringContaining, [{ key: 'asymmetricMatch', value: function asymmetricMatch(other) { if (!isA('String', other)) { return false; } return other.includes(this.sample); } }, { key: 'toString', value: function toString() { return 'StringContaining'; } }, { key: 'getExpectedType', value: function getExpectedType() { return 'string'; } }]); return StringContaining; }(AsymmetricMatcher); var StringMatching = function (_AsymmetricMatcher6) { _inherits(StringMatching, _AsymmetricMatcher6); function StringMatching(sample) { _classCallCheck(this, StringMatching); var _this6 = _possibleConstructorReturn(this, (StringMatching.__proto__ || _Object$getPrototypeOf(StringMatching)).call(this)); if (!isA('String', sample) && !isA('RegExp', sample)) { throw new Error('Expected is not a String or a RegExp'); } _this6.sample = new RegExp(sample); return _this6; } _createClass(StringMatching, [{ key: 'asymmetricMatch', value: function asymmetricMatch(other) { if (!isA('String', other)) { return false; } return this.sample.test(other); } }, { key: 'toString', value: function toString() { return 'StringMatching'; } }, { key: 'getExpectedType', value: function getExpectedType() { return 'string'; } }]); return StringMatching; }(AsymmetricMatcher); var any$1 = function any(expectedObject) { return new Any(expectedObject); }; var anything = function anything() { return new Anything(); }; var arrayContaining = function arrayContaining(sample) { return new ArrayContaining(sample); }; var objectContaining = function objectContaining(sample) { return new ObjectContaining(sample); }; var stringContaining = function stringContaining(expected) { return new StringContaining(expected); }; var stringMatching = function stringMatching(expected) { return new StringMatching(expected); }; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ // Global matchers object holds the list of available matchers and // the state, that can hold matcher specific values that change over time. var JEST_MATCHERS_OBJECT = _Symbol$for('$$jest-matchers-object'); // Notes a built-in/internal Jest matcher. // Jest may override the stack trace of Errors thrown by internal matchers. var INTERNAL_MATCHER_FLAG = _Symbol$for('$$jest-internal-matcher'); if (!global$2[JEST_MATCHERS_OBJECT]) { _Object$defineProperty(global$2, JEST_MATCHERS_OBJECT, { value: { matchers: _Object$create(null), state: { assertionCalls: 0, expectedAssertionsNumber: null, isExpectingAssertions: false, suppressedErrors: [] // errors that are not thrown immediately. } } }); } var getState = function getState() { return global$2[JEST_MATCHERS_OBJECT].state; }; var setState = function setState(state) { _Object$assign(global$2[JEST_MATCHERS_OBJECT].state, state); }; var getMatchers = function getMatchers() { return global$2[JEST_MATCHERS_OBJECT].matchers; }; var setMatchers = function setMatchers(matchers, isInternal) { _Object$keys(matchers).forEach(function (key) { var matcher = matchers[key]; _Object$defineProperty(matcher, INTERNAL_MATCHER_FLAG, { value: isInternal }); }); _Object$assign(global$2[JEST_MATCHERS_OBJECT].matchers, matchers); }; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ var resetAssertionsLocalState = function resetAssertionsLocalState() { setState({ assertionCalls: 0, expectedAssertionsNumber: null, isExpectingAssertions: false }); }; // Create and format all errors related to the mismatched number of `expect` // calls and reset the matchers state. var extractExpectedAssertionsErrors = function extractExpectedAssertionsErrors() { var result = []; var _getState = getState(), assertionCalls = _getState.assertionCalls, expectedAssertionsNumber = _getState.expectedAssertionsNumber, isExpectingAssertions = _getState.isExpectingAssertions; resetAssertionsLocalState(); if (typeof expectedAssertionsNumber === 'number' && assertionCalls !== expectedAssertionsNumber) { var numOfAssertionsExpected = build_14(build_2('assertion', expectedAssertionsNumber)); var error = new Error(build_1('.assertions', '', String(expectedAssertionsNumber), { isDirectExpectCall: true }) + '\n\n' + ('Expected ' + numOfAssertionsExpected + ' to be called but received ') + build_13(build_2('assertion call', assertionCalls || 0)) + '.'); result.push({ actual: assertionCalls, error: error, expected: expectedAssertionsNumber }); } if (isExpectingAssertions && assertionCalls === 0) { var expected = build_14('at least one assertion'); var received = build_13('received none'); var _error = new Error(build_1('.hasAssertions', '', '', { isDirectExpectCall: true }) + '\n\n' + ('Expected ' + expected + ' to be called but ' + received + '.')); result.push({ actual: 'none', error: _error, expected: 'at least one' }); } return result; }; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ var JestAssertionError = function (_Error) { _inherits(JestAssertionError, _Error); function JestAssertionError() { _classCallCheck(this, JestAssertionError); return _possibleConstructorReturn(this, (JestAssertionError.__proto__ || _Object$getPrototypeOf(JestAssertionError)).apply(this, arguments)); } return JestAssertionError; }(Error); var isPromise = function isPromise(obj) { return !!obj && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; }; var createToThrowErrorMatchingSnapshotMatcher = function createToThrowErrorMatchingSnapshotMatcher(matcher) { return function (received, testName) { return matcher.apply(this, [received, testName, true]); }; }; var getPromiseMatcher = function getPromiseMatcher(name, matcher) { if (name === 'toThrow' || name === 'toThrowError') { return createMatcher('.' + name, true); } else if (name === 'toThrowErrorMatchingSnapshot') { return createToThrowErrorMatchingSnapshotMatcher(matcher); } return null; }; var expect = function expect(actual) { if ((arguments.length <= 1 ? 0 : arguments.length - 1) !== 0) { throw new Error('Expect takes at most one argument.'); } var allMatchers = getMatchers(); var expectation = { not: {}, rejects: { not: {} }, resolves: { not: {} } }; _Object$keys(allMatchers).forEach(function (name) { var matcher = allMatchers[name]; var promiseMatcher = getPromiseMatcher(name, matcher) || matcher; expectation[name] = makeThrowingMatcher(matcher, false, actual); expectation.not[name] = makeThrowingMatcher(matcher, true, actual); expectation.resolves[name] = makeResolveMatcher(name, promiseMatcher, false, actual); expectation.resolves.not[name] = makeResolveMatcher(name, promiseMatcher, true, actual); expectation.rejects[name] = makeRejectMatcher(name, promiseMatcher, false, actual); expectation.rejects.not[name] = makeRejectMatcher(name, matcher, true, actual); }); return expectation; }; var getMessage = function getMessage(message) { return message && message() || build_13('No message was specified for this matcher.'); }; var makeResolveMatcher = function makeResolveMatcher(matcherName, matcher, isNot, actual) { return function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var matcherStatement = '.resolves.' + (isNot ? 'not.' : '') + matcherName; if (!isPromise(actual)) { throw new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + (build_13('received') + ' value must be a Promise.\n') + build_7('Received', actual, build_9)); } return actual.then(function (result) { return makeThrowingMatcher(matcher, isNot, result).apply(null, args); }, function (reason) { var err = new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + ('Expected ' + build_13('received') + ' Promise to resolve, ') + 'instead it rejected to value\n' + (' ' + build_9(reason))); return _Promise.reject(err); }); }; }; var makeRejectMatcher = function makeRejectMatcher(matcherName, matcher, isNot, actual) { return function () { for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } var matcherStatement = '.rejects.' + (isNot ? 'not.' : '') + matcherName; if (!isPromise(actual)) { throw new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + (build_13('received') + ' value must be a Promise.\n') + build_7('Received', actual, build_9)); } return actual.then(function (result) { var err = new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + ('Expected ' + build_13('received') + ' Promise to reject, ') + 'instead it resolved to value\n' + (' ' + build_9(result))); return _Promise.reject(err); }, function (reason) { return makeThrowingMatcher(matcher, isNot, reason).apply(null, args); }); }; }; var makeThrowingMatcher = function makeThrowingMatcher(matcher, isNot, actual) { return function throwingMatcher() { var throws = true; var matcherContext = _Object$assign( // When throws is disabled, the matcher will not throw errors during test // execution but instead add them to the global matcher state. If a // matcher throws, test execution is normally stopped immediately. The // snapshot matcher uses it because we want to log all snapshot // failures in a test. { dontThrow: function dontThrow() { return throws = false; } }, getState(), { equals: equals, isNot: isNot, utils: utils }); var result = void 0; try { for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } result = matcher.apply(matcherContext, [actual].concat(args)); } catch (error) { if (matcher[INTERNAL_MATCHER_FLAG] === true && !(error instanceof JestAssertionError) && error.name !== 'PrettyFormatPluginError' && // Guard for some environments (browsers) that do not support this feature. Error.captureStackTrace) { // Try to remove this and deeper functions from the stack trace frame. Error.captureStackTrace(error, throwingMatcher); } throw error; } _validateResult(result); getState().assertionCalls++; if (result.pass && isNot || !result.pass && !isNot) { // XOR var message = getMessage(result.message); var error = new JestAssertionError(message); // Passing the result of the matcher with the error so that a custom // reporter could access the actual and expected objects of the result // for example in order to display a custom visual diff error.matcherResult = result; // Try to remove this function from the stack trace frame. // Guard for some environments (browsers) that do not support this feature. if (Error.captureStackTrace) { Error.captureStackTrace(error, throwingMatcher); } if (throws) { throw error; } else { getState().suppressedErrors.push(error); } } }; }; expect.extend = function (matchers$$1) { return setMatchers(matchers$$1, false); }; expect.anything = anything; expect.any = any$1; expect.objectContaining = objectContaining; expect.arrayContaining = arrayContaining; expect.stringContaining = stringContaining; expect.stringMatching = stringMatching; var _validateResult = function _validateResult(result) { if ((typeof result === 'undefined' ? 'undefined' : _typeof(result)) !== 'object' || typeof result.pass !== 'boolean' || result.message && typeof result.message !== 'string' && typeof result.message !== 'function') { throw new Error('Unexpected return from a matcher function.\n' + 'Matcher functions should ' + 'return an object in the following format:\n' + ' {message?: string | function, pass: boolean}\n' + ('\'' + build_11(result) + '\' was returned')); } }; // add default jest matchers setMatchers(matchers, true); setMatchers(spyMatchers, true); setMatchers(matchers$2, true); expect.addSnapshotSerializer = function () { return void 0; }; expect.assertions = function (expected) { getState().expectedAssertionsNumber = expected; }; expect.hasAssertions = function (expected) { build_6(expected, '.hasAssertions'); getState().isExpectingAssertions = true; }; expect.getState = getState; expect.setState = setState; expect.extractExpectedAssertionsErrors = extractExpectedAssertionsErrors; module.exports = expect; }))); Kodo/kodo - Gogs: Go Git Service

1 コミット (3a21a72ff89ff589d71be16989ad42f86d35d66c)

作者 SHA1 メッセージ 日付
  Brightcells 4fdd237863 add api price_fix 9 年 前