code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function overRest(func, start, transform) { start = nativeMax(start === undefined ? func.length - 1 : start, 0); return function () { var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length); while (++index < length) { array[index] = args[start + index]; } index = -1; var otherArgs = Array(start + 1); while (++index < start) { otherArgs[index] = args[index]; } otherArgs[start] = transform(array); return _apply(func, this, otherArgs); }; }
A specialized version of `baseRest` which transforms the rest array. @private @param {Function} func The function to apply a rest parameter to. @param {number} [start=func.length-1] The start position of the rest parameter. @param {Function} transform The rest array transform. @returns {Function} Returns the new function.
overRest
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function constant(value) { return function () { return value; }; }
Creates a function that returns `value`. @static @memberOf _ @since 2.4.0 @category Util @param {*} value The value to return from the new function. @returns {Function} Returns the new constant function. @example var objects = _.times(2, _.constant({ 'a': 1 })); console.log(objects); // => [{ 'a': 1 }, { 'a': 1 }] console.log(objects[0] === objects[1]); // => true
constant
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function identity(value) { return value; }
This method returns the first argument it receives. @static @since 0.1.0 @memberOf _ @category Util @param {*} value Any value. @returns {*} Returns `value`. @example var object = { 'a': 1 }; console.log(_.identity(object) === object); // => true
identity
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function shortOut(func) { var count = 0, lastCalled = 0; return function () { var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; if (remaining > 0) { if (++count >= HOT_COUNT) { return arguments[0]; } } else { count = 0; } return func.apply(undefined, arguments); }; }
Creates a function that'll short out and invoke `identity` instead of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` milliseconds. @private @param {Function} func The function to restrict. @returns {Function} Returns the new shortable function.
shortOut
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function flatRest(func) { return _setToString(_overRest(func, undefined, flatten_1), func + ''); }
A specialized version of `baseRest` which flattens the rest array. @private @param {Function} func The function to apply a rest parameter to. @returns {Function} Returns the new function.
flatRest
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function arrayAggregator(array, setter, iteratee, accumulator) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { var value = array[index]; setter(accumulator, value, iteratee(value), array); } return accumulator; }
A specialized version of `baseAggregator` for arrays. @private @param {Array} [array] The array to iterate over. @param {Function} setter The function to set `accumulator` values. @param {Function} iteratee The iteratee to transform keys. @param {Object} accumulator The initial aggregated object. @returns {Function} Returns `accumulator`.
arrayAggregator
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function createBaseFor(fromRight) { return function (object, iteratee, keysFunc) { var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; while (length--) { var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } } return object; }; }
Creates a base function for methods like `_.forIn` and `_.forOwn`. @private @param {boolean} [fromRight] Specify iterating from right to left. @returns {Function} Returns the new base function.
createBaseFor
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseTimes(n, iteratee) { var index = -1, result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; }
The base implementation of `_.times` without support for iteratee shorthands or max array length checks. @private @param {number} n The number of times to invoke `iteratee`. @param {Function} iteratee The function invoked per iteration. @returns {Array} Returns the array of results.
baseTimes
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function stubFalse() { return false; }
This method returns `false`. @static @memberOf _ @since 4.13.0 @category Util @returns {boolean} Returns `false`. @example _.times(2, _.stubFalse); // => [false, false]
stubFalse
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseIsTypedArray(value) { return isObjectLike_1(value) && isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)]; }
The base implementation of `_.isTypedArray` without Node.js optimizations. @private @param {*} value The value to check. @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
baseIsTypedArray
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseUnary(func) { return function (value) { return func(value); }; }
The base implementation of `_.unary` without support for storing metadata. @private @param {Function} func The function to cap arguments for. @returns {Function} Returns the new capped function.
baseUnary
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function arrayLikeKeys(value, inherited) { var isArr = isArray_1(value), isArg = !isArr && isArguments_1(value), isBuff = !isArr && !isArg && isBuffer_1(value), isType = !isArr && !isArg && !isBuff && isTypedArray_1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? _baseTimes(value.length, String) : [], length = result.length; for (var key in value) { if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode. key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties. _isIndex(key, length)))) { result.push(key); } } return result; }
Creates an array of the enumerable property names of the array-like `value`. @private @param {*} value The value to query. @param {boolean} inherited Specify returning inherited property names. @returns {Array} Returns the array of property names.
arrayLikeKeys
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function isPrototype(value) { var Ctor = value && value.constructor, proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$8; return value === proto; }
Checks if `value` is likely a prototype object. @private @param {*} value The value to check. @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
isPrototype
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function overArg(func, transform) { return function (arg) { return func(transform(arg)); }; }
Creates a unary function that invokes `func` with its argument transformed. @private @param {Function} func The function to wrap. @param {Function} transform The argument transform. @returns {Function} Returns the new function.
overArg
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseKeys(object) { if (!_isPrototype(object)) { return _nativeKeys(object); } var result = []; for (var key in Object(object)) { if (hasOwnProperty$7.call(object, key) && key != 'constructor') { result.push(key); } } return result; }
The base implementation of `_.keys` which doesn't treat sparse arrays as dense. @private @param {Object} object The object to query. @returns {Array} Returns the array of property names.
baseKeys
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function isArrayLike(value) { return value != null && isLength_1(value.length) && !isFunction_1(value); }
Checks if `value` is array-like. A value is considered array-like if it's not a function and has a `value.length` that's an integer greater than or equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. @static @memberOf _ @since 4.0.0 @category Lang @param {*} value The value to check. @returns {boolean} Returns `true` if `value` is array-like, else `false`. @example _.isArrayLike([1, 2, 3]); // => true _.isArrayLike(document.body.children); // => true _.isArrayLike('abc'); // => true _.isArrayLike(_.noop); // => false
isArrayLike
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function keys(object) { return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object); }
Creates an array of the own enumerable property names of `object`. **Note:** Non-object values are coerced to objects. See the [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) for more details. @static @since 0.1.0 @memberOf _ @category Object @param {Object} object The object to query. @returns {Array} Returns the array of property names. @example function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.keys(new Foo); // => ['a', 'b'] (iteration order is not guaranteed) _.keys('hi'); // => ['0', '1']
keys
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseForOwn(object, iteratee) { return object && _baseFor(object, iteratee, keys_1); }
The base implementation of `_.forOwn` without support for iteratee shorthands. @private @param {Object} object The object to iterate over. @param {Function} iteratee The function invoked per iteration. @returns {Object} Returns `object`.
baseForOwn
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function createBaseEach(eachFunc, fromRight) { return function (collection, iteratee) { if (collection == null) { return collection; } if (!isArrayLike_1(collection)) { return eachFunc(collection, iteratee); } var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection); while (fromRight ? index-- : ++index < length) { if (iteratee(iterable[index], index, iterable) === false) { break; } } return collection; }; }
Creates a `baseEach` or `baseEachRight` function. @private @param {Function} eachFunc The function to iterate over a collection. @param {boolean} [fromRight] Specify iterating from right to left. @returns {Function} Returns the new base function.
createBaseEach
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseAggregator(collection, setter, iteratee, accumulator) { _baseEach(collection, function (value, key, collection) { setter(accumulator, value, iteratee(value), collection); }); return accumulator; }
Aggregates elements of `collection` on `accumulator` with keys transformed by `iteratee` and values set by `setter`. @private @param {Array|Object} collection The collection to iterate over. @param {Function} setter The function to set `accumulator` values. @param {Function} iteratee The iteratee to transform keys. @param {Object} accumulator The initial aggregated object. @returns {Function} Returns `accumulator`.
baseAggregator
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function stackClear() { this.__data__ = new _ListCache(); this.size = 0; }
Removes all key-value entries from the stack. @private @name clear @memberOf Stack
stackClear
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function stackDelete(key) { var data = this.__data__, result = data['delete'](key); this.size = data.size; return result; }
Removes `key` and its value from the stack. @private @name delete @memberOf Stack @param {string} key The key of the value to remove. @returns {boolean} Returns `true` if the entry was removed, else `false`.
stackDelete
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function stackGet(key) { return this.__data__.get(key); }
Gets the stack value for `key`. @private @name get @memberOf Stack @param {string} key The key of the value to get. @returns {*} Returns the entry value.
stackGet
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function stackHas(key) { return this.__data__.has(key); }
Checks if a stack value for `key` exists. @private @name has @memberOf Stack @param {string} key The key of the entry to check. @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
stackHas
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function stackSet(key, value) { var data = this.__data__; if (data instanceof _ListCache) { var pairs = data.__data__; if (!_Map || pairs.length < LARGE_ARRAY_SIZE - 1) { pairs.push([key, value]); this.size = ++data.size; return this; } data = this.__data__ = new _MapCache(pairs); } data.set(key, value); this.size = data.size; return this; }
Sets the stack `key` to `value`. @private @name set @memberOf Stack @param {string} key The key of the value to set. @param {*} value The value to set. @returns {Object} Returns the stack cache instance.
stackSet
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function Stack(entries) { var data = this.__data__ = new _ListCache(entries); this.size = data.size; } // Add methods to `Stack`.
Creates a stack cache object to store key-value pairs. @private @constructor @param {Array} [entries] The key-value pairs to cache.
Stack
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function setCacheAdd(value) { this.__data__.set(value, HASH_UNDEFINED$2); return this; }
Adds `value` to the array cache. @private @name add @memberOf SetCache @alias push @param {*} value The value to cache. @returns {Object} Returns the cache instance.
setCacheAdd
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function setCacheHas(value) { return this.__data__.has(value); }
Checks if `value` is in the array cache. @private @name has @memberOf SetCache @param {*} value The value to search for. @returns {number} Returns `true` if `value` is found, else `false`.
setCacheHas
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function SetCache(values) { var index = -1, length = values == null ? 0 : values.length; this.__data__ = new _MapCache(); while (++index < length) { this.add(values[index]); } } // Add methods to `SetCache`.
Creates an array cache object to store unique values. @private @constructor @param {Array} [values] The values to cache.
SetCache
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function arraySome(array, predicate) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (predicate(array[index], index, array)) { return true; } } return false; }
A specialized version of `_.some` for arrays without support for iteratee shorthands. @private @param {Array} [array] The array to iterate over. @param {Function} predicate The function invoked per iteration. @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
arraySome
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function cacheHas(cache, key) { return cache.has(key); }
Checks if a `cache` value for `key` exists. @private @param {Object} cache The cache to query. @param {string} key The key of the entry to check. @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
cacheHas
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } // Assume cyclic values are equal. var stacked = stack.get(array); if (stacked && stack.get(other)) { return stacked == other; } var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new _SetCache() : undefined; stack.set(array, other); stack.set(other, array); // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; if (customizer) { var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); } if (compared !== undefined) { if (compared) { continue; } result = false; break; } // Recursively compare arrays (susceptible to call stack limits). if (seen) { if (!_arraySome(other, function (othValue, othIndex) { if (!_cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { return seen.push(othIndex); } })) { result = false; break; } } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { result = false; break; } } stack['delete'](array); stack['delete'](other); return result; }
A specialized version of `baseIsEqualDeep` for arrays with support for partial deep comparisons. @private @param {Array} array The array to compare. @param {Array} other The other array to compare. @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. @param {Function} customizer The function to customize comparisons. @param {Function} equalFunc The function to determine equivalents of values. @param {Object} stack Tracks traversed `array` and `other` objects. @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
equalArrays
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function mapToArray(map) { var index = -1, result = Array(map.size); map.forEach(function (value, key) { result[++index] = [key, value]; }); return result; }
Converts `map` to its key-value pairs. @private @param {Object} map The map to convert. @returns {Array} Returns the key-value pairs.
mapToArray
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function setToArray(set) { var index = -1, result = Array(set.size); set.forEach(function (value) { result[++index] = value; }); return result; }
Converts `set` to an array of its values. @private @param {Object} set The set to convert. @returns {Array} Returns the values.
setToArray
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { switch (tag) { case dataViewTag$1: if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { return false; } object = object.buffer; other = other.buffer; case arrayBufferTag$1: if (object.byteLength != other.byteLength || !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) { return false; } return true; case boolTag$1: case dateTag$1: case numberTag$1: // Coerce booleans to `1` or `0` and dates to milliseconds. // Invalid dates are coerced to `NaN`. return eq_1(+object, +other); case errorTag$1: return object.name == other.name && object.message == other.message; case regexpTag$1: case stringTag$1: // Coerce regexes to strings and treat strings, primitives and objects, // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring // for more details. return object == other + ''; case mapTag$1: var convert = _mapToArray; case setTag$1: var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1; convert || (convert = _setToArray); if (object.size != other.size && !isPartial) { return false; } // Assume cyclic values are equal. var stacked = stack.get(object); if (stacked) { return stacked == other; } bitmask |= COMPARE_UNORDERED_FLAG$1; // Recursively compare objects (susceptible to call stack limits). stack.set(object, other); var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); stack['delete'](object); return result; case symbolTag$1: if (symbolValueOf) { return symbolValueOf.call(object) == symbolValueOf.call(other); } } return false; }
A specialized version of `baseIsEqualDeep` for comparing objects of the same `toStringTag`. **Note:** This function only supports comparing values with tags of `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. @private @param {Object} object The object to compare. @param {Object} other The other object to compare. @param {string} tag The `toStringTag` of the objects to compare. @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. @param {Function} customizer The function to customize comparisons. @param {Function} equalFunc The function to determine equivalents of values. @param {Object} stack Tracks traversed `object` and `other` objects. @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
equalByTag
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseGetAllKeys(object, keysFunc, symbolsFunc) { var result = keysFunc(object); return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object)); }
The base implementation of `getAllKeys` and `getAllKeysIn` which uses `keysFunc` and `symbolsFunc` to get the enumerable property names and symbols of `object`. @private @param {Object} object The object to query. @param {Function} keysFunc The function to get the keys of `object`. @param {Function} symbolsFunc The function to get the symbols of `object`. @returns {Array} Returns the array of property names and symbols.
baseGetAllKeys
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function arrayFilter(array, predicate) { var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { result[resIndex++] = value; } } return result; }
A specialized version of `_.filter` for arrays without support for iteratee shorthands. @private @param {Array} [array] The array to iterate over. @param {Function} predicate The function invoked per iteration. @returns {Array} Returns the new filtered array.
arrayFilter
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function stubArray() { return []; }
This method returns a new empty array. @static @memberOf _ @since 4.13.0 @category Util @returns {Array} Returns the new empty array. @example var arrays = _.times(2, _.stubArray); console.log(arrays); // => [[], []] console.log(arrays[0] === arrays[1]); // => false
stubArray
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function getAllKeys(object) { return _baseGetAllKeys(object, keys_1, _getSymbols); }
Creates an array of own enumerable property names and symbols of `object`. @private @param {Object} object The object to query. @returns {Array} Returns the array of property names and symbols.
getAllKeys
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2, objProps = _getAllKeys(object), objLength = objProps.length, othProps = _getAllKeys(other), othLength = othProps.length; if (objLength != othLength && !isPartial) { return false; } var index = objLength; while (index--) { var key = objProps[index]; if (!(isPartial ? key in other : hasOwnProperty$8.call(other, key))) { return false; } } // Assume cyclic values are equal. var stacked = stack.get(object); if (stacked && stack.get(other)) { return stacked == other; } var result = true; stack.set(object, other); stack.set(other, object); var skipCtor = isPartial; while (++index < objLength) { key = objProps[index]; var objValue = object[key], othValue = other[key]; if (customizer) { var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); } // Recursively compare objects (susceptible to call stack limits). if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { result = false; break; } skipCtor || (skipCtor = key == 'constructor'); } if (result && !skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { result = false; } } stack['delete'](object); stack['delete'](other); return result; }
A specialized version of `baseIsEqualDeep` for objects with support for partial deep comparisons. @private @param {Object} object The object to compare. @param {Object} other The other object to compare. @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. @param {Function} customizer The function to customize comparisons. @param {Function} equalFunc The function to determine equivalents of values. @param {Object} stack Tracks traversed `object` and `other` objects. @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
equalObjects
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { var objIsArr = isArray_1(object), othIsArr = isArray_1(other), objTag = objIsArr ? arrayTag$1 : _getTag(object), othTag = othIsArr ? arrayTag$1 : _getTag(other); objTag = objTag == argsTag$2 ? objectTag$2 : objTag; othTag = othTag == argsTag$2 ? objectTag$2 : othTag; var objIsObj = objTag == objectTag$2, othIsObj = othTag == objectTag$2, isSameTag = objTag == othTag; if (isSameTag && isBuffer_1(object)) { if (!isBuffer_1(other)) { return false; } objIsArr = true; objIsObj = false; } if (isSameTag && !objIsObj) { stack || (stack = new _Stack()); return objIsArr || isTypedArray_1(object) ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack) : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); } if (!(bitmask & COMPARE_PARTIAL_FLAG$3)) { var objIsWrapped = objIsObj && hasOwnProperty$9.call(object, '__wrapped__'), othIsWrapped = othIsObj && hasOwnProperty$9.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; stack || (stack = new _Stack()); return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); } } if (!isSameTag) { return false; } stack || (stack = new _Stack()); return _equalObjects(object, other, bitmask, customizer, equalFunc, stack); }
A specialized version of `baseIsEqual` for arrays and objects which performs deep comparisons and tracks traversed objects enabling objects with circular references to be compared. @private @param {Object} object The object to compare. @param {Object} other The other object to compare. @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. @param {Function} customizer The function to customize comparisons. @param {Function} equalFunc The function to determine equivalents of values. @param {Object} [stack] Tracks traversed `object` and `other` objects. @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
baseIsEqualDeep
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseIsEqual(value, other, bitmask, customizer, stack) { if (value === other) { return true; } if (value == null || other == null || !isObjectLike_1(value) && !isObjectLike_1(other)) { return value !== value && other !== other; } return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); }
The base implementation of `_.isEqual` which supports partial comparisons and tracks traversed objects. @private @param {*} value The value to compare. @param {*} other The other value to compare. @param {boolean} bitmask The bitmask flags. 1 - Unordered comparison 2 - Partial comparison @param {Function} [customizer] The function to customize comparisons. @param {Object} [stack] Tracks traversed `value` and `other` objects. @returns {boolean} Returns `true` if the values are equivalent, else `false`.
baseIsEqual
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseIsMatch(object, source, matchData, customizer) { var index = matchData.length, length = index, noCustomizer = !customizer; if (object == null) { return !length; } object = Object(object); while (index--) { var data = matchData[index]; if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { return false; } } while (++index < length) { data = matchData[index]; var key = data[0], objValue = object[key], srcValue = data[1]; if (noCustomizer && data[2]) { if (objValue === undefined && !(key in object)) { return false; } } else { var stack = new _Stack(); if (customizer) { var result = customizer(objValue, srcValue, key, object, source, stack); } if (!(result === undefined ? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$4 | COMPARE_UNORDERED_FLAG$2, customizer, stack) : result)) { return false; } } } return true; }
The base implementation of `_.isMatch` without support for iteratee shorthands. @private @param {Object} object The object to inspect. @param {Object} source The object of property values to match. @param {Array} matchData The property names, values, and compare flags to match. @param {Function} [customizer] The function to customize comparisons. @returns {boolean} Returns `true` if `object` is a match, else `false`.
baseIsMatch
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function isStrictComparable(value) { return value === value && !isObject_1(value); }
Checks if `value` is suitable for strict equality comparisons, i.e. `===`. @private @param {*} value The value to check. @returns {boolean} Returns `true` if `value` if suitable for strict equality comparisons, else `false`.
isStrictComparable
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function getMatchData(object) { var result = keys_1(object), length = result.length; while (length--) { var key = result[length], value = object[key]; result[length] = [key, value, _isStrictComparable(value)]; } return result; }
Gets the property names, values, and compare flags of `object`. @private @param {Object} object The object to query. @returns {Array} Returns the match data of `object`.
getMatchData
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function matchesStrictComparable(key, srcValue) { return function (object) { if (object == null) { return false; } return object[key] === srcValue && (srcValue !== undefined || key in Object(object)); }; }
A specialized version of `matchesProperty` for source values suitable for strict equality comparisons, i.e. `===`. @private @param {string} key The key of the property to get. @param {*} srcValue The value to match. @returns {Function} Returns the new spec function.
matchesStrictComparable
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseMatches(source) { var matchData = _getMatchData(source); if (matchData.length == 1 && matchData[0][2]) { return _matchesStrictComparable(matchData[0][0], matchData[0][1]); } return function (object) { return object === source || _baseIsMatch(object, source, matchData); }; }
The base implementation of `_.matches` which doesn't clone `source`. @private @param {Object} source The object of property values to match. @returns {Function} Returns the new spec function.
baseMatches
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function get(object, path, defaultValue) { var result = object == null ? undefined : _baseGet(object, path); return result === undefined ? defaultValue : result; }
Gets the value at `path` of `object`. If the resolved value is `undefined`, the `defaultValue` is returned in its place. @static @memberOf _ @since 3.7.0 @category Object @param {Object} object The object to query. @param {Array|string} path The path of the property to get. @param {*} [defaultValue] The value returned for `undefined` resolved values. @returns {*} Returns the resolved value. @example var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.get(object, 'a[0].b.c'); // => 3 _.get(object, ['a', '0', 'b', 'c']); // => 3 _.get(object, 'a.b.c', 'default'); // => 'default'
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseMatchesProperty(path, srcValue) { if (_isKey(path) && _isStrictComparable(srcValue)) { return _matchesStrictComparable(_toKey(path), srcValue); } return function (object) { var objValue = get_1(object, path); return objValue === undefined && objValue === srcValue ? hasIn_1(object, path) : _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3); }; }
The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. @private @param {string} path The path of the property to get. @param {*} srcValue The value to match. @returns {Function} Returns the new spec function.
baseMatchesProperty
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseProperty(key) { return function (object) { return object == null ? undefined : object[key]; }; }
The base implementation of `_.property` without support for deep paths. @private @param {string} key The key of the property to get. @returns {Function} Returns the new accessor function.
baseProperty
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function basePropertyDeep(path) { return function (object) { return _baseGet(object, path); }; }
A specialized version of `baseProperty` which supports deep paths. @private @param {Array|string} path The path of the property to get. @returns {Function} Returns the new accessor function.
basePropertyDeep
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function property(path) { return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path); }
Creates a function that returns the value at `path` of a given object. @static @memberOf _ @since 2.4.0 @category Util @param {Array|string} path The path of the property to get. @returns {Function} Returns the new accessor function. @example var objects = [ { 'a': { 'b': 2 } }, { 'a': { 'b': 1 } } ]; _.map(objects, _.property('a.b')); // => [2, 1] _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); // => [1, 2]
property
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function baseIteratee(value) { // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. if (typeof value == 'function') { return value; } if (value == null) { return identity_1; } if (typeof value == 'object') { return isArray_1(value) ? _baseMatchesProperty(value[0], value[1]) : _baseMatches(value); } return property_1(value); }
The base implementation of `_.iteratee`. @private @param {*} [value=_.identity] The value to convert to an iteratee. @returns {Function} Returns the iteratee.
baseIteratee
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function createAggregator(setter, initializer) { return function (collection, iteratee) { var func = isArray_1(collection) ? _arrayAggregator : _baseAggregator, accumulator = initializer ? initializer() : {}; return func(collection, setter, _baseIteratee(iteratee), accumulator); }; }
Creates a function like `_.groupBy`. @private @param {Function} setter The function to set accumulator values. @param {Function} [initializer] The accumulator object initializer. @returns {Function} Returns the new aggregator function.
createAggregator
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
minimist = function (args, opts) { if (!opts) opts = {}; var flags = { bools: {}, strings: {}, unknownFn: null }; if (typeof opts['unknown'] === 'function') { flags.unknownFn = opts['unknown']; } if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { flags.allBools = true; } else { [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { flags.bools[key] = true; }); } var aliases = {}; Object.keys(opts.alias || {}).forEach(function (key) { aliases[key] = [].concat(opts.alias[key]); aliases[key].forEach(function (x) { aliases[x] = [key].concat(aliases[key].filter(function (y) { return x !== y; })); }); }); [].concat(opts.string).filter(Boolean).forEach(function (key) { flags.strings[key] = true; if (aliases[key]) { flags.strings[aliases[key]] = true; } }); var defaults = opts['default'] || {}; var argv = { _: [] }; Object.keys(flags.bools).forEach(function (key) { setArg(key, defaults[key] === undefined ? false : defaults[key]); }); var notFlags = []; if (args.indexOf('--') !== -1) { notFlags = args.slice(args.indexOf('--') + 1); args = args.slice(0, args.indexOf('--')); } function argDefined(key, arg) { return flags.allBools && /^--[^=]+$/.test(arg) || flags.strings[key] || flags.bools[key] || aliases[key]; } function setArg(key, val, arg) { if (arg && flags.unknownFn && !argDefined(key, arg)) { if (flags.unknownFn(arg) === false) return; } var value = !flags.strings[key] && isNumber(val) ? Number(val) : val; setKey(argv, key.split('.'), value); (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), value); }); } function setKey(obj, keys, value) { var o = obj; for (var i = 0; i < keys.length - 1; i++) { var key = keys[i]; if (key === '__proto__') return; if (o[key] === undefined) o[key] = {}; if (o[key] === Object.prototype || o[key] === Number.prototype || o[key] === String.prototype) o[key] = {}; if (o[key] === Array.prototype) o[key] = []; o = o[key]; } var key = keys[keys.length - 1]; if (key === '__proto__') return; if (o === Object.prototype || o === Number.prototype || o === String.prototype) o = {}; if (o === Array.prototype) o = []; if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { o[key] = value; } else if (Array.isArray(o[key])) { o[key].push(value); } else { o[key] = [o[key], value]; } } function aliasIsBoolean(key) { return aliases[key].some(function (x) { return flags.bools[x]; }); } for (var i = 0; i < args.length; i++) { var arg = args[i]; if (/^--.+=/.test(arg)) { // Using [\s\S] instead of . because js doesn't support the // 'dotall' regex modifier. See: // http://stackoverflow.com/a/1068308/13216 var m = arg.match(/^--([^=]+)=([\s\S]*)$/); var key = m[1]; var value = m[2]; if (flags.bools[key]) { value = value !== 'false'; } setArg(key, value, arg); } else if (/^--no-.+/.test(arg)) { var key = arg.match(/^--no-(.+)/)[1]; setArg(key, false, arg); } else if (/^--.+/.test(arg)) { var key = arg.match(/^--(.+)/)[1]; var next = args[i + 1]; if (next !== undefined && !/^-/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) { setArg(key, next, arg); i++; } else if (/^(true|false)$/.test(next)) { setArg(key, next === 'true', arg); i++; } else { setArg(key, flags.strings[key] ? '' : true, arg); } } else if (/^-[^-]+/.test(arg)) { var letters = arg.slice(1, -1).split(''); var broken = false; for (var j = 0; j < letters.length; j++) { var next = arg.slice(j + 2); if (next === '-') { setArg(letters[j], next, arg); continue; } if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { setArg(letters[j], next.split('=')[1], arg); broken = true; break; } if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { setArg(letters[j], next, arg); broken = true; break; } if (letters[j + 1] && letters[j + 1].match(/\W/)) { setArg(letters[j], arg.slice(j + 2), arg); broken = true; break; } else { setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); } } var key = arg.slice(-1)[0]; if (!broken && key !== '-') { if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) { setArg(key, args[i + 1], arg); i++; } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) { setArg(key, args[i + 1] === 'true', arg); i++; } else { setArg(key, flags.strings[key] ? '' : true, arg); } } } else { if (!flags.unknownFn || flags.unknownFn(arg) !== false) { argv._.push(flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)); } if (opts.stopEarly) { argv._.push.apply(argv._, args.slice(i + 1)); break; } } } Object.keys(defaults).forEach(function (key) { if (!hasKey(argv, key.split('.'))) { setKey(argv, key.split('.'), defaults[key]); (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), defaults[key]); }); } }); if (opts['--']) { argv['--'] = new Array(); notFlags.forEach(function (key) { argv['--'].push(key); }); } else { notFlags.forEach(function (key) { argv._.push(key); }); } return argv; }
Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). @static @memberOf _ @since 0.1.0 @category Collection @param {Array|Object} collection The collection to iterate over. @param {Function} [iteratee=_.identity] The iteratee to transform keys. @returns {Object} Returns the composed aggregate object. @example _.groupBy([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] }
minimist
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function argDefined(key, arg) { return flags.allBools && /^--[^=]+$/.test(arg) || flags.strings[key] || flags.bools[key] || aliases[key]; }
Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). @static @memberOf _ @since 0.1.0 @category Collection @param {Array|Object} collection The collection to iterate over. @param {Function} [iteratee=_.identity] The iteratee to transform keys. @returns {Object} Returns the composed aggregate object. @example _.groupBy([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] }
argDefined
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function setArg(key, val, arg) { if (arg && flags.unknownFn && !argDefined(key, arg)) { if (flags.unknownFn(arg) === false) return; } var value = !flags.strings[key] && isNumber(val) ? Number(val) : val; setKey(argv, key.split('.'), value); (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), value); }); }
Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). @static @memberOf _ @since 0.1.0 @category Collection @param {Array|Object} collection The collection to iterate over. @param {Function} [iteratee=_.identity] The iteratee to transform keys. @returns {Object} Returns the composed aggregate object. @example _.groupBy([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] }
setArg
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function setKey(obj, keys, value) { var o = obj; for (var i = 0; i < keys.length - 1; i++) { var key = keys[i]; if (key === '__proto__') return; if (o[key] === undefined) o[key] = {}; if (o[key] === Object.prototype || o[key] === Number.prototype || o[key] === String.prototype) o[key] = {}; if (o[key] === Array.prototype) o[key] = []; o = o[key]; } var key = keys[keys.length - 1]; if (key === '__proto__') return; if (o === Object.prototype || o === Number.prototype || o === String.prototype) o = {}; if (o === Array.prototype) o = []; if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { o[key] = value; } else if (Array.isArray(o[key])) { o[key].push(value); } else { o[key] = [o[key], value]; } }
Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). @static @memberOf _ @since 0.1.0 @category Collection @param {Array|Object} collection The collection to iterate over. @param {Function} [iteratee=_.identity] The iteratee to transform keys. @returns {Object} Returns the composed aggregate object. @example _.groupBy([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] }
setKey
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function aliasIsBoolean(key) { return aliases[key].some(function (x) { return flags.bools[x]; }); }
Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). @static @memberOf _ @since 0.1.0 @category Collection @param {Array|Object} collection The collection to iterate over. @param {Function} [iteratee=_.identity] The iteratee to transform keys. @returns {Object} Returns the composed aggregate object. @example _.groupBy([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] }
aliasIsBoolean
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function hasKey(obj, keys) { var o = obj; keys.slice(0, -1).forEach(function (key) { o = o[key] || {}; }); var key = keys[keys.length - 1]; return key in o; }
Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). @static @memberOf _ @since 0.1.0 @category Collection @param {Array|Object} collection The collection to iterate over. @param {Function} [iteratee=_.identity] The iteratee to transform keys. @returns {Object} Returns the composed aggregate object. @example _.groupBy([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] }
hasKey
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function isNumber(x) { if (typeof x === 'number') return true; if (/^0x[0-9a-f]+$/i.test(x)) return true; return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); }
Creates an object composed of keys generated from the results of running each element of `collection` thru `iteratee`. The order of grouped values is determined by the order they occur in `collection`. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). @static @memberOf _ @since 0.1.0 @category Collection @param {Array|Object} collection The collection to iterate over. @param {Function} [iteratee=_.identity] The iteratee to transform keys. @returns {Object} Returns the composed aggregate object. @example _.groupBy([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.groupBy(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] }
isNumber
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
minimist_1 = function (args, options) { const boolean = options.boolean || []; const defaults = options.default || {}; const booleanWithoutDefault = boolean.filter(key => !(key in defaults)); const newDefaults = Object.assign(Object.assign({}, defaults), fromPairs_1(booleanWithoutDefault.map(key => [key, PLACEHOLDER]))); const parsed = minimist(args, Object.assign(Object.assign({}, options), {}, { default: newDefaults })); return fromPairs_1(Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)); }
unspecified boolean flag without default value is parsed as `undefined` instead of `false`
minimist_1
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function flatten(items) { return items.reduce((collection, item) => [].concat(collection, item), []); }
unspecified boolean flag without default value is parsed as `undefined` instead of `false`
flatten
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function splitWhen(items, predicate) { const result = [[]]; let groupIndex = 0; for (const item of items) { if (predicate(item)) { groupIndex++; result[groupIndex] = []; } else { result[groupIndex].push(item); } } return result; }
unspecified boolean flag without default value is parsed as `undefined` instead of `false`
splitWhen
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function isEnoentCodeError(error) { return error.code === 'ENOENT'; }
unspecified boolean flag without default value is parsed as `undefined` instead of `false`
isEnoentCodeError
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
constructor(name, stats) { this.name = name; this.isBlockDevice = stats.isBlockDevice.bind(stats); this.isCharacterDevice = stats.isCharacterDevice.bind(stats); this.isDirectory = stats.isDirectory.bind(stats); this.isFIFO = stats.isFIFO.bind(stats); this.isFile = stats.isFile.bind(stats); this.isSocket = stats.isSocket.bind(stats); this.isSymbolicLink = stats.isSymbolicLink.bind(stats); }
unspecified boolean flag without default value is parsed as `undefined` instead of `false`
constructor
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function createDirentFromStats(name, stats) { return new DirentFromStats(name, stats); }
unspecified boolean flag without default value is parsed as `undefined` instead of `false`
createDirentFromStats
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function unixify(filepath) { return filepath.replace(/\\/g, '/'); }
Designed to work only with simple paths: `dir\\file`.
unixify
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function makeAbsolute(cwd, filepath) { return path.resolve(cwd, filepath); }
Designed to work only with simple paths: `dir\\file`.
makeAbsolute
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function escape(pattern) { return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2'); }
Designed to work only with simple paths: `dir\\file`.
escape
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function removeLeadingDotSegment(entry) { // We do not use `startsWith` because this is 10x slower than current implementation for some cases. // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with if (entry.charAt(0) === '.') { const secondCharactery = entry.charAt(1); if (secondCharactery === '/' || secondCharactery === '\\') { return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT); } } return entry; }
Designed to work only with simple paths: `dir\\file`.
removeLeadingDotSegment
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
isExtglob = function isExtglob(str) { if (typeof str !== 'string' || str === '') { return false; } var match; while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) { if (match[2]) return true; str = str.slice(match.index + match[0].length); } return false; }
Designed to work only with simple paths: `dir\\file`.
isExtglob
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
isGlob = function isGlob(str, options) { if (typeof str !== 'string' || str === '') { return false; } if (isExtglob(str)) { return true; } var regex = strictRegex; var match; // optionally relax regex if (options && options.strict === false) { regex = relaxedRegex; } while (match = regex.exec(str)) { if (match[2]) return true; var idx = match.index + match[0].length; // if an open bracket/brace/paren is escaped, // set the index to the next closing character var open = match[1]; var close = open ? chars[open] : null; if (open && close) { var n = str.indexOf(close, idx); if (n !== -1) { idx = n + 1; } } str = str.slice(idx); } return false; }
Designed to work only with simple paths: `dir\\file`.
isGlob
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
globParent = function globParent(str, opts) { var options = Object.assign({ flipBackslashes: true }, opts); // flip windows path separators if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) { str = str.replace(backslash, slash); } // special case for strings ending in enclosure containing path separator if (enclosure.test(str)) { str += slash; } // preserves full path in case of trailing path separator str += 'a'; // remove path parts that are globby do { str = pathPosixDirname(str); } while (isGlob(str) || globby.test(str)); // remove escape chars and return result return str.replace(escaped, '$1'); }
@param {string} str @param {Object} opts @param {boolean} [opts.flipBackslashes=true]
globParent
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function rangeToPattern(start, stop, options) { if (start === stop) { return { pattern: start, count: [], digits: 0 }; } let zipped = zip(start, stop); let digits = zipped.length; let pattern = ''; let count = 0; for (let i = 0; i < digits; i++) { let [startDigit, stopDigit] = zipped[i]; if (startDigit === stopDigit) { pattern += startDigit; } else if (startDigit !== '0' || stopDigit !== '9') { pattern += toCharacterClass(startDigit, stopDigit); } else { count++; } } if (count) { pattern += options.shorthand === true ? '\\d' : '[0-9]'; } return { pattern, count: [count], digits }; }
Convert a range to a regex pattern @param {Number} `start` @param {Number} `stop` @return {String}
rangeToPattern
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function splitToPatterns(min, max, tok, options) { let ranges = splitToRanges(min, max); let tokens = []; let start = min; let prev; for (let i = 0; i < ranges.length; i++) { let max = ranges[i]; let obj = rangeToPattern(String(start), String(max), options); let zeros = ''; if (!tok.isPadded && prev && prev.pattern === obj.pattern) { if (prev.count.length > 1) { prev.count.pop(); } prev.count.push(obj.count[0]); prev.string = prev.pattern + toQuantifier(prev.count); start = max + 1; continue; } if (tok.isPadded) { zeros = padZeros(max, tok, options); } obj.string = zeros + obj.pattern + toQuantifier(obj.count); tokens.push(obj); start = max + 1; prev = obj; } return tokens; }
Convert a range to a regex pattern @param {Number} `start` @param {Number} `stop` @return {String}
splitToPatterns
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
function filterPatterns(arr, comparison, prefix, intersection, options) { let result = []; for (let ele of arr) { let { string } = ele; // only push if _both_ are negative... if (!intersection && !contains(comparison, 'string', string)) { result.push(prefix + string); } // or _both_ are positive if (intersection && contains(comparison, 'string', string)) { result.push(prefix + string); } } return result; }
Convert a range to a regex pattern @param {Number} `start` @param {Number} `stop` @return {String}
filterPatterns
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
braces = (input, options = {}) => { let output = []; if (Array.isArray(input)) { for (let pattern of input) { let result = braces.create(pattern, options); if (Array.isArray(result)) { output.push(...result); } else { output.push(result); } } } else { output = [].concat(braces.create(input, options)); } if (options && options.expand === true && options.nodupes === true) { output = [...new Set(output)]; } return output; }
Expand the given pattern or create a regex-compatible string. ```js const braces = require('braces'); console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)'] console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c'] ``` @param {String} `str` @param {Object} `options` @return {String} @api public
braces
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
braces = (input, options = {}) => { let output = []; if (Array.isArray(input)) { for (let pattern of input) { let result = braces.create(pattern, options); if (Array.isArray(result)) { output.push(...result); } else { output.push(result); } } } else { output = [].concat(braces.create(input, options)); } if (options && options.expand === true && options.nodupes === true) { output = [...new Set(output)]; } return output; }
Expand the given pattern or create a regex-compatible string. ```js const braces = require('braces'); console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)'] console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c'] ``` @param {String} `str` @param {Object} `options` @return {String} @api public
braces
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
scan = (input, options) => { const opts = options || {}; const length = input.length - 1; const scanToEnd = opts.parts === true || opts.scanToEnd === true; const slashes = []; const tokens = []; const parts = []; let str = input; let index = -1; let start = 0; let lastIndex = 0; let isBrace = false; let isBracket = false; let isGlob = false; let isExtglob = false; let isGlobstar = false; let braceEscaped = false; let backslashes = false; let negated = false; let finished = false; let braces = 0; let prev; let code; let token = { value: '', depth: 0, isGlob: false }; const eos = () => index >= length; const peek = () => str.charCodeAt(index + 1); const advance = () => { prev = code; return str.charCodeAt(++index); }; while (index < length) { code = advance(); let next; if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); if (code === CHAR_LEFT_CURLY_BRACE$1) { braceEscaped = true; } continue; } if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE$1) { braces++; while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; advance(); continue; } if (code === CHAR_LEFT_CURLY_BRACE$1) { braces++; continue; } if (braceEscaped !== true && code === CHAR_DOT$1 && (code = advance()) === CHAR_DOT$1) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (braceEscaped !== true && code === CHAR_COMMA$1) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (code === CHAR_RIGHT_CURLY_BRACE$1) { braces--; if (braces === 0) { braceEscaped = false; isBrace = token.isBrace = true; finished = true; break; } } } if (scanToEnd === true) { continue; } break; } if (code === CHAR_FORWARD_SLASH) { slashes.push(index); tokens.push(token); token = { value: '', depth: 0, isGlob: false }; if (finished === true) continue; if (prev === CHAR_DOT$1 && index === start + 1) { start += 2; continue; } lastIndex = index + 1; continue; } if (opts.noext !== true) { const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK; if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES$1) { isGlob = token.isGlob = true; isExtglob = token.isExtglob = true; finished = true; if (scanToEnd === true) { while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); continue; } if (code === CHAR_RIGHT_PARENTHESES$1) { isGlob = token.isGlob = true; finished = true; break; } } continue; } break; } } if (code === CHAR_ASTERISK) { if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (code === CHAR_QUESTION_MARK) { isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (code === CHAR_LEFT_SQUARE_BRACKET$1) { while (eos() !== true && (next = advance())) { if (next === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; advance(); continue; } if (next === CHAR_RIGHT_SQUARE_BRACKET$1) { isBracket = token.isBracket = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } } } if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { negated = token.negated = true; start++; continue; } if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES$1) { while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); continue; } if (code === CHAR_RIGHT_PARENTHESES$1) { isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } } } if (isGlob === true) { finished = true; if (scanToEnd === true) { continue; } break; } } if (opts.noext === true) { isExtglob = false; isGlob = false; } let base = str; let prefix = ''; let glob = ''; if (start > 0) { prefix = str.slice(0, start); str = str.slice(start); lastIndex -= start; } if (base && isGlob === true && lastIndex > 0) { base = str.slice(0, lastIndex); glob = str.slice(lastIndex); } else if (isGlob === true) { base = ''; glob = str; } else { base = str; } if (base && base !== '' && base !== '/' && base !== str) { if (isPathSeparator(base.charCodeAt(base.length - 1))) { base = base.slice(0, -1); } } if (opts.unescape === true) { if (glob) glob = utils$1.removeBackslashes(glob); if (base && backslashes === true) { base = utils$1.removeBackslashes(base); } } const state = { prefix, input, start, base, glob, isBrace, isBracket, isGlob, isExtglob, isGlobstar, negated }; if (opts.tokens === true) { state.maxDepth = 0; if (!isPathSeparator(code)) { tokens.push(token); } state.tokens = tokens; } if (opts.parts === true || opts.tokens === true) { let prevIndex; for (let idx = 0; idx < slashes.length; idx++) { const n = prevIndex ? prevIndex + 1 : start; const i = slashes[idx]; const value = input.slice(n, i); if (opts.tokens) { if (idx === 0 && start !== 0) { tokens[idx].isPrefix = true; tokens[idx].value = prefix; } else { tokens[idx].value = value; } depth(tokens[idx]); state.maxDepth += tokens[idx].depth; } if (idx !== 0 || value !== '') { parts.push(value); } prevIndex = i; } if (prevIndex && prevIndex + 1 < input.length) { const value = input.slice(prevIndex + 1); parts.push(value); if (opts.tokens) { tokens[tokens.length - 1].value = value; depth(tokens[tokens.length - 1]); state.maxDepth += tokens[tokens.length - 1].depth; } } state.slashes = slashes; state.parts = parts; } return state; }
Quickly scans a glob pattern and returns an object with a handful of useful properties, like `isGlob`, `path` (the leading non-glob, if it exists), `glob` (the actual pattern), and `negated` (true if the path starts with `!`). ```js const pm = require('picomatch'); console.log(pm.scan('foo/bar/*.js')); { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' } ``` @param {String} `str` @param {Object} `options` @return {Object} Returns an object with tokens and regex source string. @api public
scan
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
scan = (input, options) => { const opts = options || {}; const length = input.length - 1; const scanToEnd = opts.parts === true || opts.scanToEnd === true; const slashes = []; const tokens = []; const parts = []; let str = input; let index = -1; let start = 0; let lastIndex = 0; let isBrace = false; let isBracket = false; let isGlob = false; let isExtglob = false; let isGlobstar = false; let braceEscaped = false; let backslashes = false; let negated = false; let finished = false; let braces = 0; let prev; let code; let token = { value: '', depth: 0, isGlob: false }; const eos = () => index >= length; const peek = () => str.charCodeAt(index + 1); const advance = () => { prev = code; return str.charCodeAt(++index); }; while (index < length) { code = advance(); let next; if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); if (code === CHAR_LEFT_CURLY_BRACE$1) { braceEscaped = true; } continue; } if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE$1) { braces++; while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; advance(); continue; } if (code === CHAR_LEFT_CURLY_BRACE$1) { braces++; continue; } if (braceEscaped !== true && code === CHAR_DOT$1 && (code = advance()) === CHAR_DOT$1) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (braceEscaped !== true && code === CHAR_COMMA$1) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (code === CHAR_RIGHT_CURLY_BRACE$1) { braces--; if (braces === 0) { braceEscaped = false; isBrace = token.isBrace = true; finished = true; break; } } } if (scanToEnd === true) { continue; } break; } if (code === CHAR_FORWARD_SLASH) { slashes.push(index); tokens.push(token); token = { value: '', depth: 0, isGlob: false }; if (finished === true) continue; if (prev === CHAR_DOT$1 && index === start + 1) { start += 2; continue; } lastIndex = index + 1; continue; } if (opts.noext !== true) { const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK; if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES$1) { isGlob = token.isGlob = true; isExtglob = token.isExtglob = true; finished = true; if (scanToEnd === true) { while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); continue; } if (code === CHAR_RIGHT_PARENTHESES$1) { isGlob = token.isGlob = true; finished = true; break; } } continue; } break; } } if (code === CHAR_ASTERISK) { if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (code === CHAR_QUESTION_MARK) { isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } if (code === CHAR_LEFT_SQUARE_BRACKET$1) { while (eos() !== true && (next = advance())) { if (next === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; advance(); continue; } if (next === CHAR_RIGHT_SQUARE_BRACKET$1) { isBracket = token.isBracket = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } } } if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { negated = token.negated = true; start++; continue; } if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES$1) { while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); continue; } if (code === CHAR_RIGHT_PARENTHESES$1) { isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) { continue; } break; } } } if (isGlob === true) { finished = true; if (scanToEnd === true) { continue; } break; } } if (opts.noext === true) { isExtglob = false; isGlob = false; } let base = str; let prefix = ''; let glob = ''; if (start > 0) { prefix = str.slice(0, start); str = str.slice(start); lastIndex -= start; } if (base && isGlob === true && lastIndex > 0) { base = str.slice(0, lastIndex); glob = str.slice(lastIndex); } else if (isGlob === true) { base = ''; glob = str; } else { base = str; } if (base && base !== '' && base !== '/' && base !== str) { if (isPathSeparator(base.charCodeAt(base.length - 1))) { base = base.slice(0, -1); } } if (opts.unescape === true) { if (glob) glob = utils$1.removeBackslashes(glob); if (base && backslashes === true) { base = utils$1.removeBackslashes(base); } } const state = { prefix, input, start, base, glob, isBrace, isBracket, isGlob, isExtglob, isGlobstar, negated }; if (opts.tokens === true) { state.maxDepth = 0; if (!isPathSeparator(code)) { tokens.push(token); } state.tokens = tokens; } if (opts.parts === true || opts.tokens === true) { let prevIndex; for (let idx = 0; idx < slashes.length; idx++) { const n = prevIndex ? prevIndex + 1 : start; const i = slashes[idx]; const value = input.slice(n, i); if (opts.tokens) { if (idx === 0 && start !== 0) { tokens[idx].isPrefix = true; tokens[idx].value = prefix; } else { tokens[idx].value = value; } depth(tokens[idx]); state.maxDepth += tokens[idx].depth; } if (idx !== 0 || value !== '') { parts.push(value); } prevIndex = i; } if (prevIndex && prevIndex + 1 < input.length) { const value = input.slice(prevIndex + 1); parts.push(value); if (opts.tokens) { tokens[tokens.length - 1].value = value; depth(tokens[tokens.length - 1]); state.maxDepth += tokens[tokens.length - 1].depth; } } state.slashes = slashes; state.parts = parts; } return state; }
Quickly scans a glob pattern and returns an object with a handful of useful properties, like `isGlob`, `path` (the leading non-glob, if it exists), `glob` (the actual pattern), and `negated` (true if the path starts with `!`). ```js const pm = require('picomatch'); console.log(pm.scan('foo/bar/*.js')); { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' } ``` @param {String} `str` @param {Object} `options` @return {Object} Returns an object with tokens and regex source string. @api public
scan
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
advance = () => { prev = code; return str.charCodeAt(++index); }
Quickly scans a glob pattern and returns an object with a handful of useful properties, like `isGlob`, `path` (the leading non-glob, if it exists), `glob` (the actual pattern), and `negated` (true if the path starts with `!`). ```js const pm = require('picomatch'); console.log(pm.scan('foo/bar/*.js')); { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' } ``` @param {String} `str` @param {Object} `options` @return {Object} Returns an object with tokens and regex source string. @api public
advance
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
advance = () => { prev = code; return str.charCodeAt(++index); }
Quickly scans a glob pattern and returns an object with a handful of useful properties, like `isGlob`, `path` (the leading non-glob, if it exists), `glob` (the actual pattern), and `negated` (true if the path starts with `!`). ```js const pm = require('picomatch'); console.log(pm.scan('foo/bar/*.js')); { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' } ``` @param {String} `str` @param {Object} `options` @return {Object} Returns an object with tokens and regex source string. @api public
advance
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
syntaxError = (type, char) => { return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; }
Create the message for a syntax error
syntaxError
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
syntaxError = (type, char) => { return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; }
Create the message for a syntax error
syntaxError
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
parse$3 = (input, options) => { if (typeof input !== 'string') { throw new TypeError('Expected a string'); } input = REPLACEMENTS[input] || input; const opts = Object.assign({}, options); const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1; let len = input.length; if (len > max) { throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } const bos = { type: 'bos', value: '', output: opts.prepend || '' }; const tokens = [bos]; const capture = opts.capture ? '' : '?:'; const win32 = utils$1.isWindows(options); // create constants based on platform, for windows or posix const PLATFORM_CHARS = constants$1.globChars(win32); const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS); const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS; const globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }; const nodot = opts.dot ? '' : NO_DOT; const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; let star = opts.bash === true ? globstar(opts) : STAR; if (opts.capture) { star = `(${star})`; } // minimatch options support if (typeof opts.noext === 'boolean') { opts.noextglob = opts.noext; } const state = { input, index: -1, start: 0, dot: opts.dot === true, consumed: '', output: '', prefix: '', backtrack: false, negated: false, brackets: 0, braces: 0, parens: 0, quotes: 0, globstar: false, tokens }; input = utils$1.removePrefix(input, state); len = input.length; const extglobs = []; const braces = []; const stack = []; let prev = bos; let value; /** * Tokenizing helpers */ const eos = () => state.index === len - 1; const peek = state.peek = (n = 1) => input[state.index + n]; const advance = state.advance = () => input[++state.index]; const remaining = () => input.slice(state.index + 1); const consume = (value = '', num = 0) => { state.consumed += value; state.index += num; }; const append = token => { state.output += token.output != null ? token.output : token.value; consume(token.value); }; const negate = () => { let count = 1; while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) { advance(); state.start++; count++; } if (count % 2 === 0) { return false; } state.negated = true; state.start++; return true; }; const increment = type => { state[type]++; stack.push(type); }; const decrement = type => { state[type]--; stack.pop(); }; /** * Push tokens onto the tokens array. This helper speeds up * tokenizing by 1) helping us avoid backtracking as much as possible, * and 2) helping us avoid creating extra tokens when consecutive * characters are plain text. This improves performance and simplifies * lookbehinds. */ const push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }; const extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }; const extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }; /** * Fast paths */ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { let backslashes = false; let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { if (first === '\\') { backslashes = true; return m; } if (first === '?') { if (esc) { return esc + first + (rest ? QMARK.repeat(rest.length) : ''); } if (index === 0) { return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); } return QMARK.repeat(chars.length); } if (first === '.') { return DOT_LITERAL.repeat(chars.length); } if (first === '*') { if (esc) { return esc + first + (rest ? star : ''); } return star; } return esc ? m : `\\${m}`; }); if (backslashes === true) { if (opts.unescape === true) { output = output.replace(/\\/g, ''); } else { output = output.replace(/\\+/g, m => { return m.length % 2 === 0 ? '\\\\' : m ? '\\' : ''; }); } } if (output === input && opts.contains === true) { state.output = input; return state; } state.output = utils$1.wrapOutput(output, state, options); return state; } /** * Tokenize input until we reach end-of-string */ while (!eos()) { value = advance(); if (value === '\u0000') { continue; } /** * Escaped characters */ if (value === '\\') { const next = peek(); if (next === '/' && opts.bash !== true) { continue; } if (next === '.' || next === ';') { continue; } if (!next) { value += '\\'; push({ type: 'text', value }); continue; } // collapse slashes to reduce potential for exploits const match = /^\\+/.exec(remaining()); let slashes = 0; if (match && match[0].length > 2) { slashes = match[0].length; state.index += slashes; if (slashes % 2 !== 0) { value += '\\'; } } if (opts.unescape === true) { value = advance() || ''; } else { value += advance() || ''; } if (state.brackets === 0) { push({ type: 'text', value }); continue; } } /** * If we're inside a regex character class, continue * until we reach the closing bracket. */ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { if (opts.posix !== false && value === ':') { const inner = prev.value.slice(1); if (inner.includes('[')) { prev.posix = true; if (inner.includes(':')) { const idx = prev.value.lastIndexOf('['); const pre = prev.value.slice(0, idx); const rest = prev.value.slice(idx + 2); const posix = POSIX_REGEX_SOURCE$1[rest]; if (posix) { prev.value = pre + posix; state.backtrack = true; advance(); if (!bos.output && tokens.indexOf(prev) === 1) { bos.output = ONE_CHAR; } continue; } } } } if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') { value = `\\${value}`; } if (value === ']' && (prev.value === '[' || prev.value === '[^')) { value = `\\${value}`; } if (opts.posix === true && value === '!' && prev.value === '[') { value = '^'; } prev.value += value; append({ value }); continue; } /** * If we're inside a quoted string, continue * until we reach the closing double quote. */ if (state.quotes === 1 && value !== '"') { value = utils$1.escapeRegex(value); prev.value += value; append({ value }); continue; } /** * Double quotes */ if (value === '"') { state.quotes = state.quotes === 1 ? 0 : 1; if (opts.keepQuotes === true) { push({ type: 'text', value }); } continue; } /** * Parentheses */ if (value === '(') { increment('parens'); push({ type: 'paren', value }); continue; } if (value === ')') { if (state.parens === 0 && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '(')); } const extglob = extglobs[extglobs.length - 1]; if (extglob && state.parens === extglob.parens + 1) { extglobClose(extglobs.pop()); continue; } push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); decrement('parens'); continue; } /** * Square brackets */ if (value === '[') { if (opts.nobracket === true || !remaining().includes(']')) { if (opts.nobracket !== true && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('closing', ']')); } value = `\\${value}`; } else { increment('brackets'); } push({ type: 'bracket', value }); continue; } if (value === ']') { if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) { push({ type: 'text', value, output: `\\${value}` }); continue; } if (state.brackets === 0) { if (opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '[')); } push({ type: 'text', value, output: `\\${value}` }); continue; } decrement('brackets'); const prevValue = prev.value.slice(1); if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { value = `/${value}`; } prev.value += value; append({ value }); // when literal brackets are explicitly disabled // assume we should match with a regex character class if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) { continue; } const escaped = utils$1.escapeRegex(prev.value); state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled // assume we should escape the brackets to match literal characters if (opts.literalBrackets === true) { state.output += escaped; prev.value = escaped; continue; } // when the user specifies nothing, try to match both prev.value = `(${capture}${escaped}|${prev.value})`; state.output += prev.value; continue; } /** * Braces */ if (value === '{' && opts.nobrace !== true) { increment('braces'); const open = { type: 'brace', value, output: '(', outputIndex: state.output.length, tokensIndex: state.tokens.length }; braces.push(open); push(open); continue; } if (value === '}') { const brace = braces[braces.length - 1]; if (opts.nobrace === true || !brace) { push({ type: 'text', value, output: value }); continue; } let output = ')'; if (brace.dots === true) { const arr = tokens.slice(); const range = []; for (let i = arr.length - 1; i >= 0; i--) { tokens.pop(); if (arr[i].type === 'brace') { break; } if (arr[i].type !== 'dots') { range.unshift(arr[i].value); } } output = expandRange(range, opts); state.backtrack = true; } if (brace.comma !== true && brace.dots !== true) { const out = state.output.slice(0, brace.outputIndex); const toks = state.tokens.slice(brace.tokensIndex); brace.value = brace.output = '\\{'; value = output = `\\}`; state.output = out; for (const t of toks) { state.output += t.output || t.value; } } push({ type: 'brace', value, output }); decrement('braces'); braces.pop(); continue; } /** * Pipes */ if (value === '|') { if (extglobs.length > 0) { extglobs[extglobs.length - 1].conditions++; } push({ type: 'text', value }); continue; } /** * Commas */ if (value === ',') { let output = value; const brace = braces[braces.length - 1]; if (brace && stack[stack.length - 1] === 'braces') { brace.comma = true; output = '|'; } push({ type: 'comma', value, output }); continue; } /** * Slashes */ if (value === '/') { // if the beginning of the glob is "./", advance the start // to the current index, and don't add the "./" characters // to the state. This greatly simplifies lookbehinds when // checking for BOS characters like "!" and "." (not "./") if (prev.type === 'dot' && state.index === state.start + 1) { state.start = state.index + 1; state.consumed = ''; state.output = ''; tokens.pop(); prev = bos; // reset "prev" to the first token continue; } push({ type: 'slash', value, output: SLASH_LITERAL }); continue; } /** * Dots */ if (value === '.') { if (state.braces > 0 && prev.type === 'dot') { if (prev.value === '.') prev.output = DOT_LITERAL; const brace = braces[braces.length - 1]; prev.type = 'dots'; prev.output += value; prev.value += value; brace.dots = true; continue; } if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') { push({ type: 'text', value, output: DOT_LITERAL }); continue; } push({ type: 'dot', value, output: DOT_LITERAL }); continue; } /** * Question marks */ if (value === '?') { const isGroup = prev && prev.value === '('; if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('qmark', value); continue; } if (prev && prev.type === 'paren') { const next = peek(); let output = value; if (next === '<' && !utils$1.supportsLookbehinds()) { throw new Error('Node.js v10 or higher is required for regex lookbehinds'); } if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) { output = `\\${value}`; } push({ type: 'text', value, output }); continue; } if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) { push({ type: 'qmark', value, output: QMARK_NO_DOT }); continue; } push({ type: 'qmark', value, output: QMARK }); continue; } /** * Exclamation */ if (value === '!') { if (opts.noextglob !== true && peek() === '(') { if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) { extglobOpen('negate', value); continue; } } if (opts.nonegate !== true && state.index === 0) { negate(); continue; } } /** * Plus */ if (value === '+') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('plus', value); continue; } if (prev && prev.value === '(' || opts.regex === false) { push({ type: 'plus', value, output: PLUS_LITERAL }); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) { push({ type: 'plus', value }); continue; } push({ type: 'plus', value: PLUS_LITERAL }); continue; } /** * Plain text */ if (value === '@') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { push({ type: 'at', extglob: true, value, output: '' }); continue; } push({ type: 'text', value }); continue; } /** * Plain text */ if (value !== '*') { if (value === '$' || value === '^') { value = `\\${value}`; } const match = REGEX_NON_SPECIAL_CHARS.exec(remaining()); if (match) { value += match[0]; state.index += match[0].length; } push({ type: 'text', value }); continue; } /** * Stars */ if (prev && (prev.type === 'globstar' || prev.star === true)) { prev.type = 'star'; prev.star = true; prev.value += value; prev.output = star; state.backtrack = true; state.globstar = true; consume(value); continue; } let rest = remaining(); if (opts.noextglob !== true && /^\([^?]/.test(rest)) { extglobOpen('star', value); continue; } if (prev.type === 'star') { if (opts.noglobstar === true) { consume(value); continue; } const prior = prev.prev; const before = prior.prev; const isStart = prior.type === 'slash' || prior.type === 'bos'; const afterStar = before && (before.type === 'star' || before.type === 'globstar'); if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) { push({ type: 'star', value, output: '' }); continue; } const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { push({ type: 'star', value, output: '' }); continue; } // strip consecutive `/**/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$1.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$1.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$1.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
parse$3
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
parse$3 = (input, options) => { if (typeof input !== 'string') { throw new TypeError('Expected a string'); } input = REPLACEMENTS[input] || input; const opts = Object.assign({}, options); const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1; let len = input.length; if (len > max) { throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } const bos = { type: 'bos', value: '', output: opts.prepend || '' }; const tokens = [bos]; const capture = opts.capture ? '' : '?:'; const win32 = utils$1.isWindows(options); // create constants based on platform, for windows or posix const PLATFORM_CHARS = constants$1.globChars(win32); const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS); const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS; const globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }; const nodot = opts.dot ? '' : NO_DOT; const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; let star = opts.bash === true ? globstar(opts) : STAR; if (opts.capture) { star = `(${star})`; } // minimatch options support if (typeof opts.noext === 'boolean') { opts.noextglob = opts.noext; } const state = { input, index: -1, start: 0, dot: opts.dot === true, consumed: '', output: '', prefix: '', backtrack: false, negated: false, brackets: 0, braces: 0, parens: 0, quotes: 0, globstar: false, tokens }; input = utils$1.removePrefix(input, state); len = input.length; const extglobs = []; const braces = []; const stack = []; let prev = bos; let value; /** * Tokenizing helpers */ const eos = () => state.index === len - 1; const peek = state.peek = (n = 1) => input[state.index + n]; const advance = state.advance = () => input[++state.index]; const remaining = () => input.slice(state.index + 1); const consume = (value = '', num = 0) => { state.consumed += value; state.index += num; }; const append = token => { state.output += token.output != null ? token.output : token.value; consume(token.value); }; const negate = () => { let count = 1; while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) { advance(); state.start++; count++; } if (count % 2 === 0) { return false; } state.negated = true; state.start++; return true; }; const increment = type => { state[type]++; stack.push(type); }; const decrement = type => { state[type]--; stack.pop(); }; /** * Push tokens onto the tokens array. This helper speeds up * tokenizing by 1) helping us avoid backtracking as much as possible, * and 2) helping us avoid creating extra tokens when consecutive * characters are plain text. This improves performance and simplifies * lookbehinds. */ const push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }; const extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }; const extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }; /** * Fast paths */ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { let backslashes = false; let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { if (first === '\\') { backslashes = true; return m; } if (first === '?') { if (esc) { return esc + first + (rest ? QMARK.repeat(rest.length) : ''); } if (index === 0) { return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); } return QMARK.repeat(chars.length); } if (first === '.') { return DOT_LITERAL.repeat(chars.length); } if (first === '*') { if (esc) { return esc + first + (rest ? star : ''); } return star; } return esc ? m : `\\${m}`; }); if (backslashes === true) { if (opts.unescape === true) { output = output.replace(/\\/g, ''); } else { output = output.replace(/\\+/g, m => { return m.length % 2 === 0 ? '\\\\' : m ? '\\' : ''; }); } } if (output === input && opts.contains === true) { state.output = input; return state; } state.output = utils$1.wrapOutput(output, state, options); return state; } /** * Tokenize input until we reach end-of-string */ while (!eos()) { value = advance(); if (value === '\u0000') { continue; } /** * Escaped characters */ if (value === '\\') { const next = peek(); if (next === '/' && opts.bash !== true) { continue; } if (next === '.' || next === ';') { continue; } if (!next) { value += '\\'; push({ type: 'text', value }); continue; } // collapse slashes to reduce potential for exploits const match = /^\\+/.exec(remaining()); let slashes = 0; if (match && match[0].length > 2) { slashes = match[0].length; state.index += slashes; if (slashes % 2 !== 0) { value += '\\'; } } if (opts.unescape === true) { value = advance() || ''; } else { value += advance() || ''; } if (state.brackets === 0) { push({ type: 'text', value }); continue; } } /** * If we're inside a regex character class, continue * until we reach the closing bracket. */ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { if (opts.posix !== false && value === ':') { const inner = prev.value.slice(1); if (inner.includes('[')) { prev.posix = true; if (inner.includes(':')) { const idx = prev.value.lastIndexOf('['); const pre = prev.value.slice(0, idx); const rest = prev.value.slice(idx + 2); const posix = POSIX_REGEX_SOURCE$1[rest]; if (posix) { prev.value = pre + posix; state.backtrack = true; advance(); if (!bos.output && tokens.indexOf(prev) === 1) { bos.output = ONE_CHAR; } continue; } } } } if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') { value = `\\${value}`; } if (value === ']' && (prev.value === '[' || prev.value === '[^')) { value = `\\${value}`; } if (opts.posix === true && value === '!' && prev.value === '[') { value = '^'; } prev.value += value; append({ value }); continue; } /** * If we're inside a quoted string, continue * until we reach the closing double quote. */ if (state.quotes === 1 && value !== '"') { value = utils$1.escapeRegex(value); prev.value += value; append({ value }); continue; } /** * Double quotes */ if (value === '"') { state.quotes = state.quotes === 1 ? 0 : 1; if (opts.keepQuotes === true) { push({ type: 'text', value }); } continue; } /** * Parentheses */ if (value === '(') { increment('parens'); push({ type: 'paren', value }); continue; } if (value === ')') { if (state.parens === 0 && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '(')); } const extglob = extglobs[extglobs.length - 1]; if (extglob && state.parens === extglob.parens + 1) { extglobClose(extglobs.pop()); continue; } push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); decrement('parens'); continue; } /** * Square brackets */ if (value === '[') { if (opts.nobracket === true || !remaining().includes(']')) { if (opts.nobracket !== true && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('closing', ']')); } value = `\\${value}`; } else { increment('brackets'); } push({ type: 'bracket', value }); continue; } if (value === ']') { if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) { push({ type: 'text', value, output: `\\${value}` }); continue; } if (state.brackets === 0) { if (opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '[')); } push({ type: 'text', value, output: `\\${value}` }); continue; } decrement('brackets'); const prevValue = prev.value.slice(1); if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { value = `/${value}`; } prev.value += value; append({ value }); // when literal brackets are explicitly disabled // assume we should match with a regex character class if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) { continue; } const escaped = utils$1.escapeRegex(prev.value); state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled // assume we should escape the brackets to match literal characters if (opts.literalBrackets === true) { state.output += escaped; prev.value = escaped; continue; } // when the user specifies nothing, try to match both prev.value = `(${capture}${escaped}|${prev.value})`; state.output += prev.value; continue; } /** * Braces */ if (value === '{' && opts.nobrace !== true) { increment('braces'); const open = { type: 'brace', value, output: '(', outputIndex: state.output.length, tokensIndex: state.tokens.length }; braces.push(open); push(open); continue; } if (value === '}') { const brace = braces[braces.length - 1]; if (opts.nobrace === true || !brace) { push({ type: 'text', value, output: value }); continue; } let output = ')'; if (brace.dots === true) { const arr = tokens.slice(); const range = []; for (let i = arr.length - 1; i >= 0; i--) { tokens.pop(); if (arr[i].type === 'brace') { break; } if (arr[i].type !== 'dots') { range.unshift(arr[i].value); } } output = expandRange(range, opts); state.backtrack = true; } if (brace.comma !== true && brace.dots !== true) { const out = state.output.slice(0, brace.outputIndex); const toks = state.tokens.slice(brace.tokensIndex); brace.value = brace.output = '\\{'; value = output = `\\}`; state.output = out; for (const t of toks) { state.output += t.output || t.value; } } push({ type: 'brace', value, output }); decrement('braces'); braces.pop(); continue; } /** * Pipes */ if (value === '|') { if (extglobs.length > 0) { extglobs[extglobs.length - 1].conditions++; } push({ type: 'text', value }); continue; } /** * Commas */ if (value === ',') { let output = value; const brace = braces[braces.length - 1]; if (brace && stack[stack.length - 1] === 'braces') { brace.comma = true; output = '|'; } push({ type: 'comma', value, output }); continue; } /** * Slashes */ if (value === '/') { // if the beginning of the glob is "./", advance the start // to the current index, and don't add the "./" characters // to the state. This greatly simplifies lookbehinds when // checking for BOS characters like "!" and "." (not "./") if (prev.type === 'dot' && state.index === state.start + 1) { state.start = state.index + 1; state.consumed = ''; state.output = ''; tokens.pop(); prev = bos; // reset "prev" to the first token continue; } push({ type: 'slash', value, output: SLASH_LITERAL }); continue; } /** * Dots */ if (value === '.') { if (state.braces > 0 && prev.type === 'dot') { if (prev.value === '.') prev.output = DOT_LITERAL; const brace = braces[braces.length - 1]; prev.type = 'dots'; prev.output += value; prev.value += value; brace.dots = true; continue; } if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') { push({ type: 'text', value, output: DOT_LITERAL }); continue; } push({ type: 'dot', value, output: DOT_LITERAL }); continue; } /** * Question marks */ if (value === '?') { const isGroup = prev && prev.value === '('; if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('qmark', value); continue; } if (prev && prev.type === 'paren') { const next = peek(); let output = value; if (next === '<' && !utils$1.supportsLookbehinds()) { throw new Error('Node.js v10 or higher is required for regex lookbehinds'); } if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) { output = `\\${value}`; } push({ type: 'text', value, output }); continue; } if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) { push({ type: 'qmark', value, output: QMARK_NO_DOT }); continue; } push({ type: 'qmark', value, output: QMARK }); continue; } /** * Exclamation */ if (value === '!') { if (opts.noextglob !== true && peek() === '(') { if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) { extglobOpen('negate', value); continue; } } if (opts.nonegate !== true && state.index === 0) { negate(); continue; } } /** * Plus */ if (value === '+') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('plus', value); continue; } if (prev && prev.value === '(' || opts.regex === false) { push({ type: 'plus', value, output: PLUS_LITERAL }); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) { push({ type: 'plus', value }); continue; } push({ type: 'plus', value: PLUS_LITERAL }); continue; } /** * Plain text */ if (value === '@') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { push({ type: 'at', extglob: true, value, output: '' }); continue; } push({ type: 'text', value }); continue; } /** * Plain text */ if (value !== '*') { if (value === '$' || value === '^') { value = `\\${value}`; } const match = REGEX_NON_SPECIAL_CHARS.exec(remaining()); if (match) { value += match[0]; state.index += match[0].length; } push({ type: 'text', value }); continue; } /** * Stars */ if (prev && (prev.type === 'globstar' || prev.star === true)) { prev.type = 'star'; prev.star = true; prev.value += value; prev.output = star; state.backtrack = true; state.globstar = true; consume(value); continue; } let rest = remaining(); if (opts.noextglob !== true && /^\([^?]/.test(rest)) { extglobOpen('star', value); continue; } if (prev.type === 'star') { if (opts.noglobstar === true) { consume(value); continue; } const prior = prev.prev; const before = prior.prev; const isStart = prior.type === 'slash' || prior.type === 'bos'; const afterStar = before && (before.type === 'star' || before.type === 'globstar'); if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) { push({ type: 'star', value, output: '' }); continue; } const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { push({ type: 'star', value, output: '' }); continue; } // strip consecutive `/**/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$1.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$1.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$1.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
parse$3
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
globstar
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
globstar
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
push
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
push
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobOpen
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobOpen
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobClose
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobClose
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
globstar = opts => { if (opts.noglobstar === true) return star; return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$1.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$1.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$1.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
globstar
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
globstar = opts => { if (opts.noglobstar === true) return star; return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$1.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$1.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$1.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
globstar
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
create = str => { switch (str) { case '*': return `${nodot}${ONE_CHAR}${star}`; case '.*': return `${DOT_LITERAL}${ONE_CHAR}${star}`; case '*.*': return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '*/*': return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; case '**': return nodot + globstar(opts); case '**/*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; case '**/*.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '**/.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; default: { const match = /^(.*?)\.(\w+)$/.exec(str); if (!match) return; const source = create(match[1]); if (!source) return; return source + DOT_LITERAL + match[2]; } } }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$1.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$1.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$1.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
create
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
create = str => { switch (str) { case '*': return `${nodot}${ONE_CHAR}${star}`; case '.*': return `${DOT_LITERAL}${ONE_CHAR}${star}`; case '*.*': return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '*/*': return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; case '**': return nodot + globstar(opts); case '**/*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; case '**/*.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '**/.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; default: { const match = /^(.*?)\.(\w+)$/.exec(str); if (!match) return; const source = create(match[1]); if (!source) return; return source + DOT_LITERAL + match[2]; } } }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$1.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$1.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$1.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
create
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0
picomatch = (glob, options, returnState = false) => { if (Array.isArray(glob)) { const fns = glob.map(input => picomatch(input, options, returnState)); const arrayMatcher = str => { for (const isMatch of fns) { const state = isMatch(str); if (state) return state; } return false; }; return arrayMatcher; } const isState = isObject$2(glob) && glob.tokens && glob.input; if (glob === '' || typeof glob !== 'string' && !isState) { throw new TypeError('Expected pattern to be a non-empty string'); } const opts = options || {}; const posix = utils$1.isWindows(options); const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true); const state = regex.state; delete regex.state; let isIgnored = () => false; if (opts.ignore) { const ignoreOpts = Object.assign(Object.assign({}, options), {}, { ignore: null, onMatch: null, onResult: null }); isIgnored = picomatch(opts.ignore, ignoreOpts, returnState); } const matcher = (input, returnObject = false) => { const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); const result = { glob, state, regex, posix, input, output, match, isMatch }; if (typeof opts.onResult === 'function') { opts.onResult(result); } if (isMatch === false) { result.isMatch = false; return returnObject ? result : false; } if (isIgnored(input)) { if (typeof opts.onIgnore === 'function') { opts.onIgnore(result); } result.isMatch = false; return returnObject ? result : false; } if (typeof opts.onMatch === 'function') { opts.onMatch(result); } return returnObject ? result : true; }; if (returnState) { matcher.state = state; } return matcher; }
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information. ```js const picomatch = require('picomatch'); // picomatch(glob[, options]); const isMatch = picomatch('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` @name picomatch @param {String|Array} `globs` One or more glob patterns. @param {Object=} `options` @return {Function=} Returns a matcher function. @api public
picomatch
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/bin-prettier.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
Apache-2.0