@aiou/eslint-config 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/index.cjs +248 -2914
- package/dist/index.mjs +247 -2912
- package/dts/globs.d.ts +1 -0
- package/dts/typegen.d.ts +62 -17
- package/package.json +3 -4
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FlatConfigComposer } from 'eslint-flat-config-utils';
|
|
2
2
|
import { isPackageExists } from 'local-pkg';
|
|
3
|
-
import
|
|
3
|
+
import pluginComments from '@eslint-community/eslint-plugin-eslint-comments';
|
|
4
4
|
import ignoreGlobs from '@aiou/eslint-ignore';
|
|
5
5
|
import pluginImportNewlines from 'eslint-plugin-import-newlines';
|
|
6
6
|
import pluginImport from 'eslint-plugin-import-x';
|
|
@@ -17,7 +17,6 @@ import pluginProgress from '@aiou/eslint-plugin-progress';
|
|
|
17
17
|
import pluginReact from '@eslint-react/eslint-plugin';
|
|
18
18
|
import pluginReactHooks from 'eslint-plugin-react-hooks';
|
|
19
19
|
import pluginReactRefresh from 'eslint-plugin-react-refresh';
|
|
20
|
-
import pluginSSRFriendly from 'eslint-plugin-ssr-friendly';
|
|
21
20
|
import { configs } from 'eslint-plugin-regexp';
|
|
22
21
|
import pluginStylistic from '@stylistic/eslint-plugin';
|
|
23
22
|
import { createRequire } from 'node:module';
|
|
@@ -31,11 +30,15 @@ import yamlParser from 'yaml-eslint-parser';
|
|
|
31
30
|
const comments = () => {
|
|
32
31
|
const config = [
|
|
33
32
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
plugins: {
|
|
34
|
+
"eslint-comments": pluginComments
|
|
35
|
+
},
|
|
37
36
|
rules: {
|
|
38
|
-
"
|
|
37
|
+
"eslint-comments/disable-enable-pair": "off",
|
|
38
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
39
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
40
|
+
"eslint-comments/no-unlimited-disable": "error",
|
|
41
|
+
"eslint-comments/no-unused-enable": "error"
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
];
|
|
@@ -64,6 +67,7 @@ const GLOB_JSX = "**/*.?([cm])jsx";
|
|
|
64
67
|
const GLOB_JSON = "**/*.json";
|
|
65
68
|
const GLOB_JSON5 = "**/*.json5";
|
|
66
69
|
const GLOB_JSONC = "**/*.jsonc";
|
|
70
|
+
const GLOB_CLAUDE_JSON = "**/.claude/*.json";
|
|
67
71
|
const GLOB_MARKDOWN = "**/*.md";
|
|
68
72
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
69
73
|
const GLOB_WORKFLOW_YAML = "**/.github/**/*.y?(a)ml";
|
|
@@ -121,7 +125,15 @@ const imports = () => {
|
|
|
121
125
|
"unused-imports/no-unused-imports": "error",
|
|
122
126
|
"unused-imports/no-unused-vars": [
|
|
123
127
|
"warn",
|
|
124
|
-
{
|
|
128
|
+
{
|
|
129
|
+
// https://github.com/sweepline/eslint-plugin-unused-imports/issues/105
|
|
130
|
+
caughtErrors: "all",
|
|
131
|
+
caughtErrorsIgnorePattern: "^_",
|
|
132
|
+
vars: "all",
|
|
133
|
+
varsIgnorePattern: "^_",
|
|
134
|
+
args: "after-used",
|
|
135
|
+
argsIgnorePattern: "^_"
|
|
136
|
+
}
|
|
125
137
|
],
|
|
126
138
|
// Enforce newlines inside named import
|
|
127
139
|
"import-newlines/enforce": [
|
|
@@ -262,22 +274,7 @@ const javascript = () => {
|
|
|
262
274
|
// "eqeqeq": ["error", "always", { "null": "ignore" }],
|
|
263
275
|
"func-call-spacing": ["error", "never"],
|
|
264
276
|
"generator-star-spacing": ["error", { before: true, after: true }],
|
|
265
|
-
indent:
|
|
266
|
-
SwitchCase: 1,
|
|
267
|
-
VariableDeclarator: 1,
|
|
268
|
-
outerIIFEBody: 1,
|
|
269
|
-
MemberExpression: 1,
|
|
270
|
-
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
271
|
-
FunctionExpression: { parameters: 1, body: 1 },
|
|
272
|
-
CallExpression: { arguments: 1 },
|
|
273
|
-
ArrayExpression: 1,
|
|
274
|
-
ObjectExpression: 1,
|
|
275
|
-
ImportDeclaration: 1,
|
|
276
|
-
flatTernaryExpressions: false,
|
|
277
|
-
ignoreComments: false,
|
|
278
|
-
ignoredNodes: ["TemplateLiteral *", "JSXElement", "JSXElement > *", "JSXAttribute", "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", "JSXSpreadAttribute", "JSXExpressionContainer", "JSXOpeningElement", "JSXClosingElement", "JSXFragment", "JSXOpeningFragment", "JSXClosingFragment", "JSXText", "JSXEmptyExpression", "JSXSpreadChild"],
|
|
279
|
-
offsetTernaryExpressions: true
|
|
280
|
-
}],
|
|
277
|
+
indent: "off",
|
|
281
278
|
"key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
282
279
|
"keyword-spacing": ["error", { before: true, after: true }],
|
|
283
280
|
"lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
|
|
@@ -438,6 +435,9 @@ const javascript = () => {
|
|
|
438
435
|
"n/no-path-concat": "error",
|
|
439
436
|
"n/process-exit-as-throw": "error",
|
|
440
437
|
"promise/param-names": "error",
|
|
438
|
+
"promise/no-new-statics": "error",
|
|
439
|
+
"promise/no-multiple-resolved": "error",
|
|
440
|
+
"promise/prefer-await-to-then": "off",
|
|
441
441
|
// override
|
|
442
442
|
curly: ["error", "all"],
|
|
443
443
|
"no-unused-vars": "warn",
|
|
@@ -508,6 +508,8 @@ const jsonc = () => {
|
|
|
508
508
|
const config = [
|
|
509
509
|
{
|
|
510
510
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
511
|
+
ignores: [GLOB_CLAUDE_JSON],
|
|
512
|
+
name: "jsonc/setup",
|
|
511
513
|
languageOptions: {
|
|
512
514
|
parser: jsoncParser
|
|
513
515
|
},
|
|
@@ -517,6 +519,7 @@ const jsonc = () => {
|
|
|
517
519
|
},
|
|
518
520
|
{
|
|
519
521
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
522
|
+
ignores: [GLOB_CLAUDE_JSON],
|
|
520
523
|
rules: {
|
|
521
524
|
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
522
525
|
// refs: https://ota-meshi.github.io/eslint-plugin-jsonc/rules/indent.html
|
|
@@ -807,2890 +810,202 @@ const progress = () => {
|
|
|
807
810
|
return config;
|
|
808
811
|
};
|
|
809
812
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
/** Used for built-in method references. */
|
|
823
|
-
var objectProto$b = Object.prototype;
|
|
824
|
-
|
|
825
|
-
/** Used to check objects for own properties. */
|
|
826
|
-
var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* Used to resolve the
|
|
830
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
831
|
-
* of values.
|
|
832
|
-
*/
|
|
833
|
-
var nativeObjectToString$1 = objectProto$b.toString;
|
|
834
|
-
|
|
835
|
-
/** Built-in value references. */
|
|
836
|
-
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
|
|
837
|
-
|
|
838
|
-
/**
|
|
839
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
840
|
-
*
|
|
841
|
-
* @private
|
|
842
|
-
* @param {*} value The value to query.
|
|
843
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
844
|
-
*/
|
|
845
|
-
function getRawTag(value) {
|
|
846
|
-
var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
|
|
847
|
-
tag = value[symToStringTag$1];
|
|
848
|
-
|
|
849
|
-
try {
|
|
850
|
-
value[symToStringTag$1] = undefined;
|
|
851
|
-
var unmasked = true;
|
|
852
|
-
} catch (e) {}
|
|
853
|
-
|
|
854
|
-
var result = nativeObjectToString$1.call(value);
|
|
855
|
-
if (unmasked) {
|
|
856
|
-
if (isOwn) {
|
|
857
|
-
value[symToStringTag$1] = tag;
|
|
858
|
-
} else {
|
|
859
|
-
delete value[symToStringTag$1];
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
return result;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
/** Used for built-in method references. */
|
|
866
|
-
var objectProto$a = Object.prototype;
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* Used to resolve the
|
|
870
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
871
|
-
* of values.
|
|
872
|
-
*/
|
|
873
|
-
var nativeObjectToString = objectProto$a.toString;
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* Converts `value` to a string using `Object.prototype.toString`.
|
|
877
|
-
*
|
|
878
|
-
* @private
|
|
879
|
-
* @param {*} value The value to convert.
|
|
880
|
-
* @returns {string} Returns the converted string.
|
|
881
|
-
*/
|
|
882
|
-
function objectToString(value) {
|
|
883
|
-
return nativeObjectToString.call(value);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
/** `Object#toString` result references. */
|
|
887
|
-
var nullTag = '[object Null]',
|
|
888
|
-
undefinedTag = '[object Undefined]';
|
|
889
|
-
|
|
890
|
-
/** Built-in value references. */
|
|
891
|
-
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
895
|
-
*
|
|
896
|
-
* @private
|
|
897
|
-
* @param {*} value The value to query.
|
|
898
|
-
* @returns {string} Returns the `toStringTag`.
|
|
899
|
-
*/
|
|
900
|
-
function baseGetTag(value) {
|
|
901
|
-
if (value == null) {
|
|
902
|
-
return value === undefined ? undefinedTag : nullTag;
|
|
903
|
-
}
|
|
904
|
-
return (symToStringTag && symToStringTag in Object(value))
|
|
905
|
-
? getRawTag(value)
|
|
906
|
-
: objectToString(value);
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
/**
|
|
910
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
911
|
-
* and has a `typeof` result of "object".
|
|
912
|
-
*
|
|
913
|
-
* @static
|
|
914
|
-
* @memberOf _
|
|
915
|
-
* @since 4.0.0
|
|
916
|
-
* @category Lang
|
|
917
|
-
* @param {*} value The value to check.
|
|
918
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
919
|
-
* @example
|
|
920
|
-
*
|
|
921
|
-
* _.isObjectLike({});
|
|
922
|
-
* // => true
|
|
923
|
-
*
|
|
924
|
-
* _.isObjectLike([1, 2, 3]);
|
|
925
|
-
* // => true
|
|
926
|
-
*
|
|
927
|
-
* _.isObjectLike(_.noop);
|
|
928
|
-
* // => false
|
|
929
|
-
*
|
|
930
|
-
* _.isObjectLike(null);
|
|
931
|
-
* // => false
|
|
932
|
-
*/
|
|
933
|
-
function isObjectLike(value) {
|
|
934
|
-
return value != null && typeof value == 'object';
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
/** `Object#toString` result references. */
|
|
938
|
-
var symbolTag$1 = '[object Symbol]';
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
942
|
-
*
|
|
943
|
-
* @static
|
|
944
|
-
* @memberOf _
|
|
945
|
-
* @since 4.0.0
|
|
946
|
-
* @category Lang
|
|
947
|
-
* @param {*} value The value to check.
|
|
948
|
-
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
949
|
-
* @example
|
|
950
|
-
*
|
|
951
|
-
* _.isSymbol(Symbol.iterator);
|
|
952
|
-
* // => true
|
|
953
|
-
*
|
|
954
|
-
* _.isSymbol('abc');
|
|
955
|
-
* // => false
|
|
956
|
-
*/
|
|
957
|
-
function isSymbol(value) {
|
|
958
|
-
return typeof value == 'symbol' ||
|
|
959
|
-
(isObjectLike(value) && baseGetTag(value) == symbolTag$1);
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
/**
|
|
963
|
-
* A specialized version of `_.map` for arrays without support for iteratee
|
|
964
|
-
* shorthands.
|
|
965
|
-
*
|
|
966
|
-
* @private
|
|
967
|
-
* @param {Array} [array] The array to iterate over.
|
|
968
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
969
|
-
* @returns {Array} Returns the new mapped array.
|
|
970
|
-
*/
|
|
971
|
-
function arrayMap(array, iteratee) {
|
|
972
|
-
var index = -1,
|
|
973
|
-
length = array == null ? 0 : array.length,
|
|
974
|
-
result = Array(length);
|
|
975
|
-
|
|
976
|
-
while (++index < length) {
|
|
977
|
-
result[index] = iteratee(array[index], index, array);
|
|
978
|
-
}
|
|
979
|
-
return result;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
/**
|
|
983
|
-
* Checks if `value` is classified as an `Array` object.
|
|
984
|
-
*
|
|
985
|
-
* @static
|
|
986
|
-
* @memberOf _
|
|
987
|
-
* @since 0.1.0
|
|
988
|
-
* @category Lang
|
|
989
|
-
* @param {*} value The value to check.
|
|
990
|
-
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
991
|
-
* @example
|
|
992
|
-
*
|
|
993
|
-
* _.isArray([1, 2, 3]);
|
|
994
|
-
* // => true
|
|
995
|
-
*
|
|
996
|
-
* _.isArray(document.body.children);
|
|
997
|
-
* // => false
|
|
998
|
-
*
|
|
999
|
-
* _.isArray('abc');
|
|
1000
|
-
* // => false
|
|
1001
|
-
*
|
|
1002
|
-
* _.isArray(_.noop);
|
|
1003
|
-
* // => false
|
|
1004
|
-
*/
|
|
1005
|
-
var isArray = Array.isArray;
|
|
1006
|
-
|
|
1007
|
-
/** Used as references for various `Number` constants. */
|
|
1008
|
-
var INFINITY$1 = 1 / 0;
|
|
1009
|
-
|
|
1010
|
-
/** Used to convert symbols to primitives and strings. */
|
|
1011
|
-
var symbolProto$1 = Symbol ? Symbol.prototype : undefined,
|
|
1012
|
-
symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* The base implementation of `_.toString` which doesn't convert nullish
|
|
1016
|
-
* values to empty strings.
|
|
1017
|
-
*
|
|
1018
|
-
* @private
|
|
1019
|
-
* @param {*} value The value to process.
|
|
1020
|
-
* @returns {string} Returns the string.
|
|
1021
|
-
*/
|
|
1022
|
-
function baseToString(value) {
|
|
1023
|
-
// Exit early for strings to avoid a performance hit in some environments.
|
|
1024
|
-
if (typeof value == 'string') {
|
|
1025
|
-
return value;
|
|
1026
|
-
}
|
|
1027
|
-
if (isArray(value)) {
|
|
1028
|
-
// Recursively convert values (susceptible to call stack limits).
|
|
1029
|
-
return arrayMap(value, baseToString) + '';
|
|
1030
|
-
}
|
|
1031
|
-
if (isSymbol(value)) {
|
|
1032
|
-
return symbolToString ? symbolToString.call(value) : '';
|
|
1033
|
-
}
|
|
1034
|
-
var result = (value + '');
|
|
1035
|
-
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Checks if `value` is the
|
|
1040
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
1041
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
1042
|
-
*
|
|
1043
|
-
* @static
|
|
1044
|
-
* @memberOf _
|
|
1045
|
-
* @since 0.1.0
|
|
1046
|
-
* @category Lang
|
|
1047
|
-
* @param {*} value The value to check.
|
|
1048
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
1049
|
-
* @example
|
|
1050
|
-
*
|
|
1051
|
-
* _.isObject({});
|
|
1052
|
-
* // => true
|
|
1053
|
-
*
|
|
1054
|
-
* _.isObject([1, 2, 3]);
|
|
1055
|
-
* // => true
|
|
1056
|
-
*
|
|
1057
|
-
* _.isObject(_.noop);
|
|
1058
|
-
* // => true
|
|
1059
|
-
*
|
|
1060
|
-
* _.isObject(null);
|
|
1061
|
-
* // => false
|
|
1062
|
-
*/
|
|
1063
|
-
function isObject(value) {
|
|
1064
|
-
var type = typeof value;
|
|
1065
|
-
return value != null && (type == 'object' || type == 'function');
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
/**
|
|
1069
|
-
* This method returns the first argument it receives.
|
|
1070
|
-
*
|
|
1071
|
-
* @static
|
|
1072
|
-
* @since 0.1.0
|
|
1073
|
-
* @memberOf _
|
|
1074
|
-
* @category Util
|
|
1075
|
-
* @param {*} value Any value.
|
|
1076
|
-
* @returns {*} Returns `value`.
|
|
1077
|
-
* @example
|
|
1078
|
-
*
|
|
1079
|
-
* var object = { 'a': 1 };
|
|
1080
|
-
*
|
|
1081
|
-
* console.log(_.identity(object) === object);
|
|
1082
|
-
* // => true
|
|
1083
|
-
*/
|
|
1084
|
-
function identity(value) {
|
|
1085
|
-
return value;
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
/** `Object#toString` result references. */
|
|
1089
|
-
var asyncTag = '[object AsyncFunction]',
|
|
1090
|
-
funcTag$1 = '[object Function]',
|
|
1091
|
-
genTag = '[object GeneratorFunction]',
|
|
1092
|
-
proxyTag = '[object Proxy]';
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* Checks if `value` is classified as a `Function` object.
|
|
1096
|
-
*
|
|
1097
|
-
* @static
|
|
1098
|
-
* @memberOf _
|
|
1099
|
-
* @since 0.1.0
|
|
1100
|
-
* @category Lang
|
|
1101
|
-
* @param {*} value The value to check.
|
|
1102
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
1103
|
-
* @example
|
|
1104
|
-
*
|
|
1105
|
-
* _.isFunction(_);
|
|
1106
|
-
* // => true
|
|
1107
|
-
*
|
|
1108
|
-
* _.isFunction(/abc/);
|
|
1109
|
-
* // => false
|
|
1110
|
-
*/
|
|
1111
|
-
function isFunction(value) {
|
|
1112
|
-
if (!isObject(value)) {
|
|
1113
|
-
return false;
|
|
1114
|
-
}
|
|
1115
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
1116
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
1117
|
-
var tag = baseGetTag(value);
|
|
1118
|
-
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
/** Used to detect overreaching core-js shims. */
|
|
1122
|
-
var coreJsData = root['__core-js_shared__'];
|
|
1123
|
-
|
|
1124
|
-
/** Used to detect methods masquerading as native. */
|
|
1125
|
-
var maskSrcKey = (function() {
|
|
1126
|
-
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
1127
|
-
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
1128
|
-
}());
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
* Checks if `func` has its source masked.
|
|
1132
|
-
*
|
|
1133
|
-
* @private
|
|
1134
|
-
* @param {Function} func The function to check.
|
|
1135
|
-
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
1136
|
-
*/
|
|
1137
|
-
function isMasked(func) {
|
|
1138
|
-
return !!maskSrcKey && (maskSrcKey in func);
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
/** Used for built-in method references. */
|
|
1142
|
-
var funcProto$1 = Function.prototype;
|
|
1143
|
-
|
|
1144
|
-
/** Used to resolve the decompiled source of functions. */
|
|
1145
|
-
var funcToString$1 = funcProto$1.toString;
|
|
1146
|
-
|
|
1147
|
-
/**
|
|
1148
|
-
* Converts `func` to its source code.
|
|
1149
|
-
*
|
|
1150
|
-
* @private
|
|
1151
|
-
* @param {Function} func The function to convert.
|
|
1152
|
-
* @returns {string} Returns the source code.
|
|
1153
|
-
*/
|
|
1154
|
-
function toSource(func) {
|
|
1155
|
-
if (func != null) {
|
|
1156
|
-
try {
|
|
1157
|
-
return funcToString$1.call(func);
|
|
1158
|
-
} catch (e) {}
|
|
1159
|
-
try {
|
|
1160
|
-
return (func + '');
|
|
1161
|
-
} catch (e) {}
|
|
1162
|
-
}
|
|
1163
|
-
return '';
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
/**
|
|
1167
|
-
* Used to match `RegExp`
|
|
1168
|
-
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
1169
|
-
*/
|
|
1170
|
-
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
1171
|
-
|
|
1172
|
-
/** Used to detect host constructors (Safari). */
|
|
1173
|
-
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
1174
|
-
|
|
1175
|
-
/** Used for built-in method references. */
|
|
1176
|
-
var funcProto = Function.prototype,
|
|
1177
|
-
objectProto$9 = Object.prototype;
|
|
1178
|
-
|
|
1179
|
-
/** Used to resolve the decompiled source of functions. */
|
|
1180
|
-
var funcToString = funcProto.toString;
|
|
1181
|
-
|
|
1182
|
-
/** Used to check objects for own properties. */
|
|
1183
|
-
var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
|
1184
|
-
|
|
1185
|
-
/** Used to detect if a method is native. */
|
|
1186
|
-
var reIsNative = RegExp('^' +
|
|
1187
|
-
funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
|
|
1188
|
-
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
1189
|
-
);
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
1193
|
-
*
|
|
1194
|
-
* @private
|
|
1195
|
-
* @param {*} value The value to check.
|
|
1196
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
1197
|
-
* else `false`.
|
|
1198
|
-
*/
|
|
1199
|
-
function baseIsNative(value) {
|
|
1200
|
-
if (!isObject(value) || isMasked(value)) {
|
|
1201
|
-
return false;
|
|
1202
|
-
}
|
|
1203
|
-
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
1204
|
-
return pattern.test(toSource(value));
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
/**
|
|
1208
|
-
* Gets the value at `key` of `object`.
|
|
1209
|
-
*
|
|
1210
|
-
* @private
|
|
1211
|
-
* @param {Object} [object] The object to query.
|
|
1212
|
-
* @param {string} key The key of the property to get.
|
|
1213
|
-
* @returns {*} Returns the property value.
|
|
1214
|
-
*/
|
|
1215
|
-
function getValue(object, key) {
|
|
1216
|
-
return object == null ? undefined : object[key];
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
/**
|
|
1220
|
-
* Gets the native function at `key` of `object`.
|
|
1221
|
-
*
|
|
1222
|
-
* @private
|
|
1223
|
-
* @param {Object} object The object to query.
|
|
1224
|
-
* @param {string} key The key of the method to get.
|
|
1225
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
1226
|
-
*/
|
|
1227
|
-
function getNative(object, key) {
|
|
1228
|
-
var value = getValue(object, key);
|
|
1229
|
-
return baseIsNative(value) ? value : undefined;
|
|
813
|
+
function renameRules(rules, map) {
|
|
814
|
+
return Object.fromEntries(
|
|
815
|
+
Object.entries(rules).map(([key, value]) => {
|
|
816
|
+
for (const [from, to] of Object.entries(map)) {
|
|
817
|
+
if (key.startsWith(`${from}/`)) {
|
|
818
|
+
return [to + key.slice(from.length), value];
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return [key, value];
|
|
822
|
+
})
|
|
823
|
+
);
|
|
1230
824
|
}
|
|
1231
825
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
826
|
+
const react = () => {
|
|
827
|
+
const plugins = pluginReact.configs.all.plugins;
|
|
828
|
+
const config = [
|
|
829
|
+
{
|
|
830
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
831
|
+
languageOptions: {
|
|
832
|
+
parserOptions: {
|
|
833
|
+
ecmaFeatures: {
|
|
834
|
+
jsx: true
|
|
835
|
+
}
|
|
836
|
+
},
|
|
837
|
+
sourceType: "module"
|
|
838
|
+
},
|
|
839
|
+
settings: {
|
|
840
|
+
react: {
|
|
841
|
+
// 'detect' will throw warn on monorepo
|
|
842
|
+
version: "18.0"
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
plugins: {
|
|
846
|
+
react: plugins["@eslint-react"],
|
|
847
|
+
"react-dom": plugins["@eslint-react/dom"],
|
|
848
|
+
"react-hooks": pluginReactHooks,
|
|
849
|
+
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
850
|
+
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
851
|
+
"react-refresh": pluginReactRefresh,
|
|
852
|
+
"react-web-api": plugins["@eslint-react/web-api"]
|
|
853
|
+
},
|
|
854
|
+
rules: {
|
|
855
|
+
...renameRules(plugins["@eslint-react"].configs["recommended-typescript"].rules, { "react-x": "react" }),
|
|
856
|
+
...renameRules(plugins["@eslint-react/dom"].configs.recommended.rules, { "@eslint-react": "react-dom" }),
|
|
857
|
+
...renameRules(pluginReactHooks.configs.recommended.rules, { "@eslint-react": "react-hooks" }),
|
|
858
|
+
...renameRules(plugins["@eslint-react/hooks-extra"].configs.recommended.rules, { "@eslint-react": "react-hooks-extra" }),
|
|
859
|
+
...renameRules(plugins["@eslint-react/naming-convention"].configs.recommended.rules, { "@eslint-react": "react-naming-convention" }),
|
|
860
|
+
...renameRules(plugins["@eslint-react/web-api"].configs.recommended.rules, { "@eslint-react": "react-web-api" }),
|
|
861
|
+
"react/no-prop-types": "error",
|
|
862
|
+
"react/no-nested-component-definitions": "warn",
|
|
863
|
+
"react-dom/no-unknown-property": "off",
|
|
864
|
+
"react/avoid-shorthand-boolean": ["error"],
|
|
865
|
+
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
866
|
+
"react-refresh/only-export-components": "warn",
|
|
867
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "off"
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
files: ["src/components/**/*.{ts,tsx}"],
|
|
872
|
+
rules: {
|
|
873
|
+
"react-naming-convention/filename": ["warn", { rule: "PascalCase" }]
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
files: ["src/hooks/**/use*.{ts,tsx}"],
|
|
878
|
+
rules: {
|
|
879
|
+
"react-naming-convention/filename": ["warn", { rule: "kebab-case" }]
|
|
880
|
+
}
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
files: [
|
|
884
|
+
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
|
885
|
+
`**/*{-entry,entry.}*.${GLOB_SCRIPT_EXT}`,
|
|
886
|
+
GLOB_TEST_SCRIPT,
|
|
887
|
+
GLOB_TEST_DIRS,
|
|
888
|
+
// With next.js pages will export getStaticProps funcs
|
|
889
|
+
// There are some bad cases for not all files are route files
|
|
890
|
+
// RECOMMEND: pages/routes should only contain page files
|
|
891
|
+
GLOB_PAGES_DIRS
|
|
892
|
+
],
|
|
893
|
+
ignores: [
|
|
894
|
+
GLOB_PAGES_COMPONENTS_DIRS
|
|
895
|
+
],
|
|
896
|
+
rules: {
|
|
897
|
+
"react-refresh/only-export-components": "off"
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
];
|
|
901
|
+
return config;
|
|
902
|
+
};
|
|
903
|
+
const ssrReact = () => {
|
|
904
|
+
const config = [
|
|
905
|
+
{
|
|
906
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
907
|
+
languageOptions: {
|
|
908
|
+
parserOptions: {
|
|
909
|
+
ecmaFeatures: {
|
|
910
|
+
jsx: true
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
sourceType: "module"
|
|
914
|
+
},
|
|
915
|
+
settings: {
|
|
916
|
+
react: {
|
|
917
|
+
// 'detect' will throw warn on monorepo
|
|
918
|
+
version: "18.0"
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
rules: {
|
|
922
|
+
"no-restricted-syntax": [
|
|
923
|
+
"error",
|
|
924
|
+
"DebuggerStatement",
|
|
925
|
+
"LabeledStatement",
|
|
926
|
+
"WithStatement",
|
|
927
|
+
{
|
|
928
|
+
selector: "TSEnumDeclaration",
|
|
929
|
+
message: "Don't declare enums"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
selector: "MemberExpression[object.name='window']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='window'])",
|
|
933
|
+
message: `Use 'typeof window !== "undefined" && window.xxx' for safe DOM access`
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
selector: "Identifier[name='window']:not(UnaryExpression[operator='typeof'] > Identifier)",
|
|
937
|
+
message: `Direct window access not allowed. Use 'typeof window !== "undefined"' check first`
|
|
938
|
+
},
|
|
939
|
+
// Document 对象
|
|
940
|
+
{
|
|
941
|
+
selector: "MemberExpression[object.name='document']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='document'])",
|
|
942
|
+
message: `Use 'typeof document !== "undefined" && document.xxx' for safe DOM access`
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
selector: "Identifier[name='document']:not(UnaryExpression[operator='typeof'] > Identifier)",
|
|
946
|
+
message: `Direct document access not allowed. Use 'typeof document !== "undefined"' check first`
|
|
947
|
+
},
|
|
948
|
+
// Navigator 对象
|
|
949
|
+
{
|
|
950
|
+
selector: "MemberExpression[object.name='navigator']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='navigator'])",
|
|
951
|
+
message: `Use 'typeof navigator !== "undefined" && navigator.xxx' for safe DOM access`
|
|
952
|
+
},
|
|
953
|
+
// Location 对象
|
|
954
|
+
{
|
|
955
|
+
selector: "MemberExpression[object.name='location']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='location'])",
|
|
956
|
+
message: `Use 'typeof location !== "undefined" && location.xxx' for safe DOM access`
|
|
957
|
+
},
|
|
958
|
+
// History 对象
|
|
959
|
+
{
|
|
960
|
+
selector: "MemberExpression[object.name='history']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='history'])",
|
|
961
|
+
message: `Use 'typeof history !== "undefined" && history.xxx' for safe DOM access`
|
|
962
|
+
},
|
|
963
|
+
// Storage 对象们
|
|
964
|
+
{
|
|
965
|
+
selector: "MemberExpression[object.name='localStorage']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='localStorage'])",
|
|
966
|
+
message: `Use 'typeof localStorage !== "undefined" && localStorage.xxx' for safe DOM access`
|
|
967
|
+
},
|
|
968
|
+
// Fork from enum
|
|
969
|
+
{
|
|
970
|
+
selector: "TSEnumDeclaration",
|
|
971
|
+
message: "Don't declare enums"
|
|
972
|
+
}
|
|
973
|
+
]
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
files: [
|
|
978
|
+
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
|
979
|
+
// Client entry files not need to be SSR friendly
|
|
980
|
+
`**/*{client-entry,entry.client}*.${GLOB_SCRIPT_EXT}`,
|
|
981
|
+
GLOB_TEST_SCRIPT,
|
|
982
|
+
GLOB_TEST_DIRS
|
|
983
|
+
],
|
|
984
|
+
rules: {
|
|
985
|
+
"no-restricted-syntax": [
|
|
986
|
+
"error",
|
|
987
|
+
"DebuggerStatement",
|
|
988
|
+
"LabeledStatement",
|
|
989
|
+
"WithStatement",
|
|
990
|
+
{
|
|
991
|
+
selector: "TSEnumDeclaration",
|
|
992
|
+
message: "Don't declare enums"
|
|
993
|
+
}
|
|
994
|
+
]
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
];
|
|
998
|
+
return config;
|
|
999
|
+
};
|
|
1248
1000
|
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
function isIndex(value, length) {
|
|
1258
|
-
var type = typeof value;
|
|
1259
|
-
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
1260
|
-
|
|
1261
|
-
return !!length &&
|
|
1262
|
-
(type == 'number' ||
|
|
1263
|
-
(type != 'symbol' && reIsUint.test(value))) &&
|
|
1264
|
-
(value > -1 && value % 1 == 0 && value < length);
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
/**
|
|
1268
|
-
* The base implementation of `assignValue` and `assignMergeValue` without
|
|
1269
|
-
* value checks.
|
|
1270
|
-
*
|
|
1271
|
-
* @private
|
|
1272
|
-
* @param {Object} object The object to modify.
|
|
1273
|
-
* @param {string} key The key of the property to assign.
|
|
1274
|
-
* @param {*} value The value to assign.
|
|
1275
|
-
*/
|
|
1276
|
-
function baseAssignValue(object, key, value) {
|
|
1277
|
-
if (key == '__proto__' && defineProperty) {
|
|
1278
|
-
defineProperty(object, key, {
|
|
1279
|
-
'configurable': true,
|
|
1280
|
-
'enumerable': true,
|
|
1281
|
-
'value': value,
|
|
1282
|
-
'writable': true
|
|
1283
|
-
});
|
|
1284
|
-
} else {
|
|
1285
|
-
object[key] = value;
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
* Performs a
|
|
1291
|
-
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
1292
|
-
* comparison between two values to determine if they are equivalent.
|
|
1293
|
-
*
|
|
1294
|
-
* @static
|
|
1295
|
-
* @memberOf _
|
|
1296
|
-
* @since 4.0.0
|
|
1297
|
-
* @category Lang
|
|
1298
|
-
* @param {*} value The value to compare.
|
|
1299
|
-
* @param {*} other The other value to compare.
|
|
1300
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
1301
|
-
* @example
|
|
1302
|
-
*
|
|
1303
|
-
* var object = { 'a': 1 };
|
|
1304
|
-
* var other = { 'a': 1 };
|
|
1305
|
-
*
|
|
1306
|
-
* _.eq(object, object);
|
|
1307
|
-
* // => true
|
|
1308
|
-
*
|
|
1309
|
-
* _.eq(object, other);
|
|
1310
|
-
* // => false
|
|
1311
|
-
*
|
|
1312
|
-
* _.eq('a', 'a');
|
|
1313
|
-
* // => true
|
|
1314
|
-
*
|
|
1315
|
-
* _.eq('a', Object('a'));
|
|
1316
|
-
* // => false
|
|
1317
|
-
*
|
|
1318
|
-
* _.eq(NaN, NaN);
|
|
1319
|
-
* // => true
|
|
1320
|
-
*/
|
|
1321
|
-
function eq(value, other) {
|
|
1322
|
-
return value === other || (value !== value && other !== other);
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
/** Used as references for various `Number` constants. */
|
|
1326
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* Checks if `value` is a valid array-like length.
|
|
1330
|
-
*
|
|
1331
|
-
* **Note:** This method is loosely based on
|
|
1332
|
-
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
1333
|
-
*
|
|
1334
|
-
* @static
|
|
1335
|
-
* @memberOf _
|
|
1336
|
-
* @since 4.0.0
|
|
1337
|
-
* @category Lang
|
|
1338
|
-
* @param {*} value The value to check.
|
|
1339
|
-
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
1340
|
-
* @example
|
|
1341
|
-
*
|
|
1342
|
-
* _.isLength(3);
|
|
1343
|
-
* // => true
|
|
1344
|
-
*
|
|
1345
|
-
* _.isLength(Number.MIN_VALUE);
|
|
1346
|
-
* // => false
|
|
1347
|
-
*
|
|
1348
|
-
* _.isLength(Infinity);
|
|
1349
|
-
* // => false
|
|
1350
|
-
*
|
|
1351
|
-
* _.isLength('3');
|
|
1352
|
-
* // => false
|
|
1353
|
-
*/
|
|
1354
|
-
function isLength(value) {
|
|
1355
|
-
return typeof value == 'number' &&
|
|
1356
|
-
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
/**
|
|
1360
|
-
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
1361
|
-
* not a function and has a `value.length` that's an integer greater than or
|
|
1362
|
-
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
1363
|
-
*
|
|
1364
|
-
* @static
|
|
1365
|
-
* @memberOf _
|
|
1366
|
-
* @since 4.0.0
|
|
1367
|
-
* @category Lang
|
|
1368
|
-
* @param {*} value The value to check.
|
|
1369
|
-
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
1370
|
-
* @example
|
|
1371
|
-
*
|
|
1372
|
-
* _.isArrayLike([1, 2, 3]);
|
|
1373
|
-
* // => true
|
|
1374
|
-
*
|
|
1375
|
-
* _.isArrayLike(document.body.children);
|
|
1376
|
-
* // => true
|
|
1377
|
-
*
|
|
1378
|
-
* _.isArrayLike('abc');
|
|
1379
|
-
* // => true
|
|
1380
|
-
*
|
|
1381
|
-
* _.isArrayLike(_.noop);
|
|
1382
|
-
* // => false
|
|
1383
|
-
*/
|
|
1384
|
-
function isArrayLike(value) {
|
|
1385
|
-
return value != null && isLength(value.length) && !isFunction(value);
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
/** Used for built-in method references. */
|
|
1389
|
-
var objectProto$8 = Object.prototype;
|
|
1390
|
-
|
|
1391
|
-
/**
|
|
1392
|
-
* Checks if `value` is likely a prototype object.
|
|
1393
|
-
*
|
|
1394
|
-
* @private
|
|
1395
|
-
* @param {*} value The value to check.
|
|
1396
|
-
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
1397
|
-
*/
|
|
1398
|
-
function isPrototype(value) {
|
|
1399
|
-
var Ctor = value && value.constructor,
|
|
1400
|
-
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
|
|
1401
|
-
|
|
1402
|
-
return value === proto;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
/**
|
|
1406
|
-
* The base implementation of `_.times` without support for iteratee shorthands
|
|
1407
|
-
* or max array length checks.
|
|
1408
|
-
*
|
|
1409
|
-
* @private
|
|
1410
|
-
* @param {number} n The number of times to invoke `iteratee`.
|
|
1411
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
1412
|
-
* @returns {Array} Returns the array of results.
|
|
1413
|
-
*/
|
|
1414
|
-
function baseTimes(n, iteratee) {
|
|
1415
|
-
var index = -1,
|
|
1416
|
-
result = Array(n);
|
|
1417
|
-
|
|
1418
|
-
while (++index < n) {
|
|
1419
|
-
result[index] = iteratee(index);
|
|
1420
|
-
}
|
|
1421
|
-
return result;
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
/** `Object#toString` result references. */
|
|
1425
|
-
var argsTag$2 = '[object Arguments]';
|
|
1426
|
-
|
|
1427
|
-
/**
|
|
1428
|
-
* The base implementation of `_.isArguments`.
|
|
1429
|
-
*
|
|
1430
|
-
* @private
|
|
1431
|
-
* @param {*} value The value to check.
|
|
1432
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1433
|
-
*/
|
|
1434
|
-
function baseIsArguments(value) {
|
|
1435
|
-
return isObjectLike(value) && baseGetTag(value) == argsTag$2;
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
/** Used for built-in method references. */
|
|
1439
|
-
var objectProto$7 = Object.prototype;
|
|
1440
|
-
|
|
1441
|
-
/** Used to check objects for own properties. */
|
|
1442
|
-
var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
|
|
1443
|
-
|
|
1444
|
-
/** Built-in value references. */
|
|
1445
|
-
var propertyIsEnumerable$1 = objectProto$7.propertyIsEnumerable;
|
|
1446
|
-
|
|
1447
|
-
/**
|
|
1448
|
-
* Checks if `value` is likely an `arguments` object.
|
|
1449
|
-
*
|
|
1450
|
-
* @static
|
|
1451
|
-
* @memberOf _
|
|
1452
|
-
* @since 0.1.0
|
|
1453
|
-
* @category Lang
|
|
1454
|
-
* @param {*} value The value to check.
|
|
1455
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1456
|
-
* else `false`.
|
|
1457
|
-
* @example
|
|
1458
|
-
*
|
|
1459
|
-
* _.isArguments(function() { return arguments; }());
|
|
1460
|
-
* // => true
|
|
1461
|
-
*
|
|
1462
|
-
* _.isArguments([1, 2, 3]);
|
|
1463
|
-
* // => false
|
|
1464
|
-
*/
|
|
1465
|
-
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
1466
|
-
return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') &&
|
|
1467
|
-
!propertyIsEnumerable$1.call(value, 'callee');
|
|
1468
|
-
};
|
|
1469
|
-
|
|
1470
|
-
/**
|
|
1471
|
-
* This method returns `false`.
|
|
1472
|
-
*
|
|
1473
|
-
* @static
|
|
1474
|
-
* @memberOf _
|
|
1475
|
-
* @since 4.13.0
|
|
1476
|
-
* @category Util
|
|
1477
|
-
* @returns {boolean} Returns `false`.
|
|
1478
|
-
* @example
|
|
1479
|
-
*
|
|
1480
|
-
* _.times(2, _.stubFalse);
|
|
1481
|
-
* // => [false, false]
|
|
1482
|
-
*/
|
|
1483
|
-
function stubFalse() {
|
|
1484
|
-
return false;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
/** Detect free variable `exports`. */
|
|
1488
|
-
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1489
|
-
|
|
1490
|
-
/** Detect free variable `module`. */
|
|
1491
|
-
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
|
|
1492
|
-
|
|
1493
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1494
|
-
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
1495
|
-
|
|
1496
|
-
/** Built-in value references. */
|
|
1497
|
-
var Buffer = moduleExports$1 ? root.Buffer : undefined;
|
|
1498
|
-
|
|
1499
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1500
|
-
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
1501
|
-
|
|
1502
|
-
/**
|
|
1503
|
-
* Checks if `value` is a buffer.
|
|
1504
|
-
*
|
|
1505
|
-
* @static
|
|
1506
|
-
* @memberOf _
|
|
1507
|
-
* @since 4.3.0
|
|
1508
|
-
* @category Lang
|
|
1509
|
-
* @param {*} value The value to check.
|
|
1510
|
-
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
1511
|
-
* @example
|
|
1512
|
-
*
|
|
1513
|
-
* _.isBuffer(new Buffer(2));
|
|
1514
|
-
* // => true
|
|
1515
|
-
*
|
|
1516
|
-
* _.isBuffer(new Uint8Array(2));
|
|
1517
|
-
* // => false
|
|
1518
|
-
*/
|
|
1519
|
-
var isBuffer = nativeIsBuffer || stubFalse;
|
|
1520
|
-
|
|
1521
|
-
/** `Object#toString` result references. */
|
|
1522
|
-
var argsTag$1 = '[object Arguments]',
|
|
1523
|
-
arrayTag$1 = '[object Array]',
|
|
1524
|
-
boolTag$1 = '[object Boolean]',
|
|
1525
|
-
dateTag$1 = '[object Date]',
|
|
1526
|
-
errorTag$1 = '[object Error]',
|
|
1527
|
-
funcTag = '[object Function]',
|
|
1528
|
-
mapTag$2 = '[object Map]',
|
|
1529
|
-
numberTag$1 = '[object Number]',
|
|
1530
|
-
objectTag$2 = '[object Object]',
|
|
1531
|
-
regexpTag$1 = '[object RegExp]',
|
|
1532
|
-
setTag$2 = '[object Set]',
|
|
1533
|
-
stringTag$1 = '[object String]',
|
|
1534
|
-
weakMapTag$1 = '[object WeakMap]';
|
|
1535
|
-
|
|
1536
|
-
var arrayBufferTag$1 = '[object ArrayBuffer]',
|
|
1537
|
-
dataViewTag$2 = '[object DataView]',
|
|
1538
|
-
float32Tag = '[object Float32Array]',
|
|
1539
|
-
float64Tag = '[object Float64Array]',
|
|
1540
|
-
int8Tag = '[object Int8Array]',
|
|
1541
|
-
int16Tag = '[object Int16Array]',
|
|
1542
|
-
int32Tag = '[object Int32Array]',
|
|
1543
|
-
uint8Tag = '[object Uint8Array]',
|
|
1544
|
-
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
1545
|
-
uint16Tag = '[object Uint16Array]',
|
|
1546
|
-
uint32Tag = '[object Uint32Array]';
|
|
1547
|
-
|
|
1548
|
-
/** Used to identify `toStringTag` values of typed arrays. */
|
|
1549
|
-
var typedArrayTags = {};
|
|
1550
|
-
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
1551
|
-
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
1552
|
-
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
1553
|
-
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
1554
|
-
typedArrayTags[uint32Tag] = true;
|
|
1555
|
-
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
|
|
1556
|
-
typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
|
|
1557
|
-
typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
|
|
1558
|
-
typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
|
|
1559
|
-
typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
|
|
1560
|
-
typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
|
|
1561
|
-
typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] =
|
|
1562
|
-
typedArrayTags[weakMapTag$1] = false;
|
|
1563
|
-
|
|
1564
|
-
/**
|
|
1565
|
-
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
1566
|
-
*
|
|
1567
|
-
* @private
|
|
1568
|
-
* @param {*} value The value to check.
|
|
1569
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1570
|
-
*/
|
|
1571
|
-
function baseIsTypedArray(value) {
|
|
1572
|
-
return isObjectLike(value) &&
|
|
1573
|
-
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
/**
|
|
1577
|
-
* The base implementation of `_.unary` without support for storing metadata.
|
|
1578
|
-
*
|
|
1579
|
-
* @private
|
|
1580
|
-
* @param {Function} func The function to cap arguments for.
|
|
1581
|
-
* @returns {Function} Returns the new capped function.
|
|
1582
|
-
*/
|
|
1583
|
-
function baseUnary(func) {
|
|
1584
|
-
return function(value) {
|
|
1585
|
-
return func(value);
|
|
1586
|
-
};
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
/** Detect free variable `exports`. */
|
|
1590
|
-
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1591
|
-
|
|
1592
|
-
/** Detect free variable `module`. */
|
|
1593
|
-
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
1594
|
-
|
|
1595
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1596
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1597
|
-
|
|
1598
|
-
/** Detect free variable `process` from Node.js. */
|
|
1599
|
-
var freeProcess = moduleExports && freeGlobal.process;
|
|
1600
|
-
|
|
1601
|
-
/** Used to access faster Node.js helpers. */
|
|
1602
|
-
var nodeUtil = (function() {
|
|
1603
|
-
try {
|
|
1604
|
-
// Use `util.types` for Node.js 10+.
|
|
1605
|
-
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
1606
|
-
|
|
1607
|
-
if (types) {
|
|
1608
|
-
return types;
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
// Legacy `process.binding('util')` for Node.js < 10.
|
|
1612
|
-
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
1613
|
-
} catch (e) {}
|
|
1614
|
-
}());
|
|
1615
|
-
|
|
1616
|
-
/* Node.js helper references. */
|
|
1617
|
-
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
1618
|
-
|
|
1619
|
-
/**
|
|
1620
|
-
* Checks if `value` is classified as a typed array.
|
|
1621
|
-
*
|
|
1622
|
-
* @static
|
|
1623
|
-
* @memberOf _
|
|
1624
|
-
* @since 3.0.0
|
|
1625
|
-
* @category Lang
|
|
1626
|
-
* @param {*} value The value to check.
|
|
1627
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1628
|
-
* @example
|
|
1629
|
-
*
|
|
1630
|
-
* _.isTypedArray(new Uint8Array);
|
|
1631
|
-
* // => true
|
|
1632
|
-
*
|
|
1633
|
-
* _.isTypedArray([]);
|
|
1634
|
-
* // => false
|
|
1635
|
-
*/
|
|
1636
|
-
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
1637
|
-
|
|
1638
|
-
/** Used for built-in method references. */
|
|
1639
|
-
var objectProto$6 = Object.prototype;
|
|
1640
|
-
|
|
1641
|
-
/** Used to check objects for own properties. */
|
|
1642
|
-
var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
|
|
1643
|
-
|
|
1644
|
-
/**
|
|
1645
|
-
* Creates an array of the enumerable property names of the array-like `value`.
|
|
1646
|
-
*
|
|
1647
|
-
* @private
|
|
1648
|
-
* @param {*} value The value to query.
|
|
1649
|
-
* @param {boolean} inherited Specify returning inherited property names.
|
|
1650
|
-
* @returns {Array} Returns the array of property names.
|
|
1651
|
-
*/
|
|
1652
|
-
function arrayLikeKeys(value, inherited) {
|
|
1653
|
-
var isArr = isArray(value),
|
|
1654
|
-
isArg = !isArr && isArguments(value),
|
|
1655
|
-
isBuff = !isArr && !isArg && isBuffer(value),
|
|
1656
|
-
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
1657
|
-
skipIndexes = isArr || isArg || isBuff || isType,
|
|
1658
|
-
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
1659
|
-
length = result.length;
|
|
1660
|
-
|
|
1661
|
-
for (var key in value) {
|
|
1662
|
-
if ((inherited || hasOwnProperty$5.call(value, key)) &&
|
|
1663
|
-
!(skipIndexes && (
|
|
1664
|
-
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1665
|
-
key == 'length' ||
|
|
1666
|
-
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1667
|
-
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
1668
|
-
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1669
|
-
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
1670
|
-
// Skip index properties.
|
|
1671
|
-
isIndex(key, length)
|
|
1672
|
-
))) {
|
|
1673
|
-
result.push(key);
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
return result;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
/**
|
|
1680
|
-
* Creates a unary function that invokes `func` with its argument transformed.
|
|
1681
|
-
*
|
|
1682
|
-
* @private
|
|
1683
|
-
* @param {Function} func The function to wrap.
|
|
1684
|
-
* @param {Function} transform The argument transform.
|
|
1685
|
-
* @returns {Function} Returns the new function.
|
|
1686
|
-
*/
|
|
1687
|
-
function overArg(func, transform) {
|
|
1688
|
-
return function(arg) {
|
|
1689
|
-
return func(transform(arg));
|
|
1690
|
-
};
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1694
|
-
var nativeKeys = overArg(Object.keys, Object);
|
|
1695
|
-
|
|
1696
|
-
/** Used for built-in method references. */
|
|
1697
|
-
var objectProto$5 = Object.prototype;
|
|
1698
|
-
|
|
1699
|
-
/** Used to check objects for own properties. */
|
|
1700
|
-
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
1701
|
-
|
|
1702
|
-
/**
|
|
1703
|
-
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
1704
|
-
*
|
|
1705
|
-
* @private
|
|
1706
|
-
* @param {Object} object The object to query.
|
|
1707
|
-
* @returns {Array} Returns the array of property names.
|
|
1708
|
-
*/
|
|
1709
|
-
function baseKeys(object) {
|
|
1710
|
-
if (!isPrototype(object)) {
|
|
1711
|
-
return nativeKeys(object);
|
|
1712
|
-
}
|
|
1713
|
-
var result = [];
|
|
1714
|
-
for (var key in Object(object)) {
|
|
1715
|
-
if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
|
|
1716
|
-
result.push(key);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
return result;
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
/**
|
|
1723
|
-
* Creates an array of the own enumerable property names of `object`.
|
|
1724
|
-
*
|
|
1725
|
-
* **Note:** Non-object values are coerced to objects. See the
|
|
1726
|
-
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
1727
|
-
* for more details.
|
|
1728
|
-
*
|
|
1729
|
-
* @static
|
|
1730
|
-
* @since 0.1.0
|
|
1731
|
-
* @memberOf _
|
|
1732
|
-
* @category Object
|
|
1733
|
-
* @param {Object} object The object to query.
|
|
1734
|
-
* @returns {Array} Returns the array of property names.
|
|
1735
|
-
* @example
|
|
1736
|
-
*
|
|
1737
|
-
* function Foo() {
|
|
1738
|
-
* this.a = 1;
|
|
1739
|
-
* this.b = 2;
|
|
1740
|
-
* }
|
|
1741
|
-
*
|
|
1742
|
-
* Foo.prototype.c = 3;
|
|
1743
|
-
*
|
|
1744
|
-
* _.keys(new Foo);
|
|
1745
|
-
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
1746
|
-
*
|
|
1747
|
-
* _.keys('hi');
|
|
1748
|
-
* // => ['0', '1']
|
|
1749
|
-
*/
|
|
1750
|
-
function keys(object) {
|
|
1751
|
-
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
/** Used to match property names within property paths. */
|
|
1755
|
-
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|
1756
|
-
reIsPlainProp = /^\w*$/;
|
|
1757
|
-
|
|
1758
|
-
/**
|
|
1759
|
-
* Checks if `value` is a property name and not a property path.
|
|
1760
|
-
*
|
|
1761
|
-
* @private
|
|
1762
|
-
* @param {*} value The value to check.
|
|
1763
|
-
* @param {Object} [object] The object to query keys on.
|
|
1764
|
-
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
1765
|
-
*/
|
|
1766
|
-
function isKey(value, object) {
|
|
1767
|
-
if (isArray(value)) {
|
|
1768
|
-
return false;
|
|
1769
|
-
}
|
|
1770
|
-
var type = typeof value;
|
|
1771
|
-
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
|
1772
|
-
value == null || isSymbol(value)) {
|
|
1773
|
-
return true;
|
|
1774
|
-
}
|
|
1775
|
-
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
|
1776
|
-
(object != null && value in Object(object));
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
/* Built-in method references that are verified to be native. */
|
|
1780
|
-
var nativeCreate = getNative(Object, 'create');
|
|
1781
|
-
|
|
1782
|
-
/**
|
|
1783
|
-
* Removes all key-value entries from the hash.
|
|
1784
|
-
*
|
|
1785
|
-
* @private
|
|
1786
|
-
* @name clear
|
|
1787
|
-
* @memberOf Hash
|
|
1788
|
-
*/
|
|
1789
|
-
function hashClear() {
|
|
1790
|
-
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
1791
|
-
this.size = 0;
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
/**
|
|
1795
|
-
* Removes `key` and its value from the hash.
|
|
1796
|
-
*
|
|
1797
|
-
* @private
|
|
1798
|
-
* @name delete
|
|
1799
|
-
* @memberOf Hash
|
|
1800
|
-
* @param {Object} hash The hash to modify.
|
|
1801
|
-
* @param {string} key The key of the value to remove.
|
|
1802
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1803
|
-
*/
|
|
1804
|
-
function hashDelete(key) {
|
|
1805
|
-
var result = this.has(key) && delete this.__data__[key];
|
|
1806
|
-
this.size -= result ? 1 : 0;
|
|
1807
|
-
return result;
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
1811
|
-
var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
|
|
1812
|
-
|
|
1813
|
-
/** Used for built-in method references. */
|
|
1814
|
-
var objectProto$4 = Object.prototype;
|
|
1815
|
-
|
|
1816
|
-
/** Used to check objects for own properties. */
|
|
1817
|
-
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
1818
|
-
|
|
1819
|
-
/**
|
|
1820
|
-
* Gets the hash value for `key`.
|
|
1821
|
-
*
|
|
1822
|
-
* @private
|
|
1823
|
-
* @name get
|
|
1824
|
-
* @memberOf Hash
|
|
1825
|
-
* @param {string} key The key of the value to get.
|
|
1826
|
-
* @returns {*} Returns the entry value.
|
|
1827
|
-
*/
|
|
1828
|
-
function hashGet(key) {
|
|
1829
|
-
var data = this.__data__;
|
|
1830
|
-
if (nativeCreate) {
|
|
1831
|
-
var result = data[key];
|
|
1832
|
-
return result === HASH_UNDEFINED$2 ? undefined : result;
|
|
1833
|
-
}
|
|
1834
|
-
return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
/** Used for built-in method references. */
|
|
1838
|
-
var objectProto$3 = Object.prototype;
|
|
1839
|
-
|
|
1840
|
-
/** Used to check objects for own properties. */
|
|
1841
|
-
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
1842
|
-
|
|
1843
|
-
/**
|
|
1844
|
-
* Checks if a hash value for `key` exists.
|
|
1845
|
-
*
|
|
1846
|
-
* @private
|
|
1847
|
-
* @name has
|
|
1848
|
-
* @memberOf Hash
|
|
1849
|
-
* @param {string} key The key of the entry to check.
|
|
1850
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1851
|
-
*/
|
|
1852
|
-
function hashHas(key) {
|
|
1853
|
-
var data = this.__data__;
|
|
1854
|
-
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$2.call(data, key);
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1857
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
1858
|
-
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
1859
|
-
|
|
1860
|
-
/**
|
|
1861
|
-
* Sets the hash `key` to `value`.
|
|
1862
|
-
*
|
|
1863
|
-
* @private
|
|
1864
|
-
* @name set
|
|
1865
|
-
* @memberOf Hash
|
|
1866
|
-
* @param {string} key The key of the value to set.
|
|
1867
|
-
* @param {*} value The value to set.
|
|
1868
|
-
* @returns {Object} Returns the hash instance.
|
|
1869
|
-
*/
|
|
1870
|
-
function hashSet(key, value) {
|
|
1871
|
-
var data = this.__data__;
|
|
1872
|
-
this.size += this.has(key) ? 0 : 1;
|
|
1873
|
-
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
|
|
1874
|
-
return this;
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
/**
|
|
1878
|
-
* Creates a hash object.
|
|
1879
|
-
*
|
|
1880
|
-
* @private
|
|
1881
|
-
* @constructor
|
|
1882
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
1883
|
-
*/
|
|
1884
|
-
function Hash(entries) {
|
|
1885
|
-
var index = -1,
|
|
1886
|
-
length = entries == null ? 0 : entries.length;
|
|
1887
|
-
|
|
1888
|
-
this.clear();
|
|
1889
|
-
while (++index < length) {
|
|
1890
|
-
var entry = entries[index];
|
|
1891
|
-
this.set(entry[0], entry[1]);
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
// Add methods to `Hash`.
|
|
1896
|
-
Hash.prototype.clear = hashClear;
|
|
1897
|
-
Hash.prototype['delete'] = hashDelete;
|
|
1898
|
-
Hash.prototype.get = hashGet;
|
|
1899
|
-
Hash.prototype.has = hashHas;
|
|
1900
|
-
Hash.prototype.set = hashSet;
|
|
1901
|
-
|
|
1902
|
-
/**
|
|
1903
|
-
* Removes all key-value entries from the list cache.
|
|
1904
|
-
*
|
|
1905
|
-
* @private
|
|
1906
|
-
* @name clear
|
|
1907
|
-
* @memberOf ListCache
|
|
1908
|
-
*/
|
|
1909
|
-
function listCacheClear() {
|
|
1910
|
-
this.__data__ = [];
|
|
1911
|
-
this.size = 0;
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
/**
|
|
1915
|
-
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
1916
|
-
*
|
|
1917
|
-
* @private
|
|
1918
|
-
* @param {Array} array The array to inspect.
|
|
1919
|
-
* @param {*} key The key to search for.
|
|
1920
|
-
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
1921
|
-
*/
|
|
1922
|
-
function assocIndexOf(array, key) {
|
|
1923
|
-
var length = array.length;
|
|
1924
|
-
while (length--) {
|
|
1925
|
-
if (eq(array[length][0], key)) {
|
|
1926
|
-
return length;
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
return -1;
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
/** Used for built-in method references. */
|
|
1933
|
-
var arrayProto = Array.prototype;
|
|
1934
|
-
|
|
1935
|
-
/** Built-in value references. */
|
|
1936
|
-
var splice = arrayProto.splice;
|
|
1937
|
-
|
|
1938
|
-
/**
|
|
1939
|
-
* Removes `key` and its value from the list cache.
|
|
1940
|
-
*
|
|
1941
|
-
* @private
|
|
1942
|
-
* @name delete
|
|
1943
|
-
* @memberOf ListCache
|
|
1944
|
-
* @param {string} key The key of the value to remove.
|
|
1945
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1946
|
-
*/
|
|
1947
|
-
function listCacheDelete(key) {
|
|
1948
|
-
var data = this.__data__,
|
|
1949
|
-
index = assocIndexOf(data, key);
|
|
1950
|
-
|
|
1951
|
-
if (index < 0) {
|
|
1952
|
-
return false;
|
|
1953
|
-
}
|
|
1954
|
-
var lastIndex = data.length - 1;
|
|
1955
|
-
if (index == lastIndex) {
|
|
1956
|
-
data.pop();
|
|
1957
|
-
} else {
|
|
1958
|
-
splice.call(data, index, 1);
|
|
1959
|
-
}
|
|
1960
|
-
--this.size;
|
|
1961
|
-
return true;
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
/**
|
|
1965
|
-
* Gets the list cache value for `key`.
|
|
1966
|
-
*
|
|
1967
|
-
* @private
|
|
1968
|
-
* @name get
|
|
1969
|
-
* @memberOf ListCache
|
|
1970
|
-
* @param {string} key The key of the value to get.
|
|
1971
|
-
* @returns {*} Returns the entry value.
|
|
1972
|
-
*/
|
|
1973
|
-
function listCacheGet(key) {
|
|
1974
|
-
var data = this.__data__,
|
|
1975
|
-
index = assocIndexOf(data, key);
|
|
1976
|
-
|
|
1977
|
-
return index < 0 ? undefined : data[index][1];
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
/**
|
|
1981
|
-
* Checks if a list cache value for `key` exists.
|
|
1982
|
-
*
|
|
1983
|
-
* @private
|
|
1984
|
-
* @name has
|
|
1985
|
-
* @memberOf ListCache
|
|
1986
|
-
* @param {string} key The key of the entry to check.
|
|
1987
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1988
|
-
*/
|
|
1989
|
-
function listCacheHas(key) {
|
|
1990
|
-
return assocIndexOf(this.__data__, key) > -1;
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
/**
|
|
1994
|
-
* Sets the list cache `key` to `value`.
|
|
1995
|
-
*
|
|
1996
|
-
* @private
|
|
1997
|
-
* @name set
|
|
1998
|
-
* @memberOf ListCache
|
|
1999
|
-
* @param {string} key The key of the value to set.
|
|
2000
|
-
* @param {*} value The value to set.
|
|
2001
|
-
* @returns {Object} Returns the list cache instance.
|
|
2002
|
-
*/
|
|
2003
|
-
function listCacheSet(key, value) {
|
|
2004
|
-
var data = this.__data__,
|
|
2005
|
-
index = assocIndexOf(data, key);
|
|
2006
|
-
|
|
2007
|
-
if (index < 0) {
|
|
2008
|
-
++this.size;
|
|
2009
|
-
data.push([key, value]);
|
|
2010
|
-
} else {
|
|
2011
|
-
data[index][1] = value;
|
|
2012
|
-
}
|
|
2013
|
-
return this;
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
/**
|
|
2017
|
-
* Creates an list cache object.
|
|
2018
|
-
*
|
|
2019
|
-
* @private
|
|
2020
|
-
* @constructor
|
|
2021
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
2022
|
-
*/
|
|
2023
|
-
function ListCache(entries) {
|
|
2024
|
-
var index = -1,
|
|
2025
|
-
length = entries == null ? 0 : entries.length;
|
|
2026
|
-
|
|
2027
|
-
this.clear();
|
|
2028
|
-
while (++index < length) {
|
|
2029
|
-
var entry = entries[index];
|
|
2030
|
-
this.set(entry[0], entry[1]);
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
// Add methods to `ListCache`.
|
|
2035
|
-
ListCache.prototype.clear = listCacheClear;
|
|
2036
|
-
ListCache.prototype['delete'] = listCacheDelete;
|
|
2037
|
-
ListCache.prototype.get = listCacheGet;
|
|
2038
|
-
ListCache.prototype.has = listCacheHas;
|
|
2039
|
-
ListCache.prototype.set = listCacheSet;
|
|
2040
|
-
|
|
2041
|
-
/* Built-in method references that are verified to be native. */
|
|
2042
|
-
var Map = getNative(root, 'Map');
|
|
2043
|
-
|
|
2044
|
-
/**
|
|
2045
|
-
* Removes all key-value entries from the map.
|
|
2046
|
-
*
|
|
2047
|
-
* @private
|
|
2048
|
-
* @name clear
|
|
2049
|
-
* @memberOf MapCache
|
|
2050
|
-
*/
|
|
2051
|
-
function mapCacheClear() {
|
|
2052
|
-
this.size = 0;
|
|
2053
|
-
this.__data__ = {
|
|
2054
|
-
'hash': new Hash,
|
|
2055
|
-
'map': new (Map || ListCache),
|
|
2056
|
-
'string': new Hash
|
|
2057
|
-
};
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
/**
|
|
2061
|
-
* Checks if `value` is suitable for use as unique object key.
|
|
2062
|
-
*
|
|
2063
|
-
* @private
|
|
2064
|
-
* @param {*} value The value to check.
|
|
2065
|
-
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
2066
|
-
*/
|
|
2067
|
-
function isKeyable(value) {
|
|
2068
|
-
var type = typeof value;
|
|
2069
|
-
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
2070
|
-
? (value !== '__proto__')
|
|
2071
|
-
: (value === null);
|
|
2072
|
-
}
|
|
2073
|
-
|
|
2074
|
-
/**
|
|
2075
|
-
* Gets the data for `map`.
|
|
2076
|
-
*
|
|
2077
|
-
* @private
|
|
2078
|
-
* @param {Object} map The map to query.
|
|
2079
|
-
* @param {string} key The reference key.
|
|
2080
|
-
* @returns {*} Returns the map data.
|
|
2081
|
-
*/
|
|
2082
|
-
function getMapData(map, key) {
|
|
2083
|
-
var data = map.__data__;
|
|
2084
|
-
return isKeyable(key)
|
|
2085
|
-
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
2086
|
-
: data.map;
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
/**
|
|
2090
|
-
* Removes `key` and its value from the map.
|
|
2091
|
-
*
|
|
2092
|
-
* @private
|
|
2093
|
-
* @name delete
|
|
2094
|
-
* @memberOf MapCache
|
|
2095
|
-
* @param {string} key The key of the value to remove.
|
|
2096
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
2097
|
-
*/
|
|
2098
|
-
function mapCacheDelete(key) {
|
|
2099
|
-
var result = getMapData(this, key)['delete'](key);
|
|
2100
|
-
this.size -= result ? 1 : 0;
|
|
2101
|
-
return result;
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
|
-
/**
|
|
2105
|
-
* Gets the map value for `key`.
|
|
2106
|
-
*
|
|
2107
|
-
* @private
|
|
2108
|
-
* @name get
|
|
2109
|
-
* @memberOf MapCache
|
|
2110
|
-
* @param {string} key The key of the value to get.
|
|
2111
|
-
* @returns {*} Returns the entry value.
|
|
2112
|
-
*/
|
|
2113
|
-
function mapCacheGet(key) {
|
|
2114
|
-
return getMapData(this, key).get(key);
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
|
-
/**
|
|
2118
|
-
* Checks if a map value for `key` exists.
|
|
2119
|
-
*
|
|
2120
|
-
* @private
|
|
2121
|
-
* @name has
|
|
2122
|
-
* @memberOf MapCache
|
|
2123
|
-
* @param {string} key The key of the entry to check.
|
|
2124
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
2125
|
-
*/
|
|
2126
|
-
function mapCacheHas(key) {
|
|
2127
|
-
return getMapData(this, key).has(key);
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
/**
|
|
2131
|
-
* Sets the map `key` to `value`.
|
|
2132
|
-
*
|
|
2133
|
-
* @private
|
|
2134
|
-
* @name set
|
|
2135
|
-
* @memberOf MapCache
|
|
2136
|
-
* @param {string} key The key of the value to set.
|
|
2137
|
-
* @param {*} value The value to set.
|
|
2138
|
-
* @returns {Object} Returns the map cache instance.
|
|
2139
|
-
*/
|
|
2140
|
-
function mapCacheSet(key, value) {
|
|
2141
|
-
var data = getMapData(this, key),
|
|
2142
|
-
size = data.size;
|
|
2143
|
-
|
|
2144
|
-
data.set(key, value);
|
|
2145
|
-
this.size += data.size == size ? 0 : 1;
|
|
2146
|
-
return this;
|
|
2147
|
-
}
|
|
2148
|
-
|
|
2149
|
-
/**
|
|
2150
|
-
* Creates a map cache object to store key-value pairs.
|
|
2151
|
-
*
|
|
2152
|
-
* @private
|
|
2153
|
-
* @constructor
|
|
2154
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
2155
|
-
*/
|
|
2156
|
-
function MapCache(entries) {
|
|
2157
|
-
var index = -1,
|
|
2158
|
-
length = entries == null ? 0 : entries.length;
|
|
2159
|
-
|
|
2160
|
-
this.clear();
|
|
2161
|
-
while (++index < length) {
|
|
2162
|
-
var entry = entries[index];
|
|
2163
|
-
this.set(entry[0], entry[1]);
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
// Add methods to `MapCache`.
|
|
2168
|
-
MapCache.prototype.clear = mapCacheClear;
|
|
2169
|
-
MapCache.prototype['delete'] = mapCacheDelete;
|
|
2170
|
-
MapCache.prototype.get = mapCacheGet;
|
|
2171
|
-
MapCache.prototype.has = mapCacheHas;
|
|
2172
|
-
MapCache.prototype.set = mapCacheSet;
|
|
2173
|
-
|
|
2174
|
-
/** Error message constants. */
|
|
2175
|
-
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
2176
|
-
|
|
2177
|
-
/**
|
|
2178
|
-
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
2179
|
-
* provided, it determines the cache key for storing the result based on the
|
|
2180
|
-
* arguments provided to the memoized function. By default, the first argument
|
|
2181
|
-
* provided to the memoized function is used as the map cache key. The `func`
|
|
2182
|
-
* is invoked with the `this` binding of the memoized function.
|
|
2183
|
-
*
|
|
2184
|
-
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
2185
|
-
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
2186
|
-
* constructor with one whose instances implement the
|
|
2187
|
-
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
2188
|
-
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
2189
|
-
*
|
|
2190
|
-
* @static
|
|
2191
|
-
* @memberOf _
|
|
2192
|
-
* @since 0.1.0
|
|
2193
|
-
* @category Function
|
|
2194
|
-
* @param {Function} func The function to have its output memoized.
|
|
2195
|
-
* @param {Function} [resolver] The function to resolve the cache key.
|
|
2196
|
-
* @returns {Function} Returns the new memoized function.
|
|
2197
|
-
* @example
|
|
2198
|
-
*
|
|
2199
|
-
* var object = { 'a': 1, 'b': 2 };
|
|
2200
|
-
* var other = { 'c': 3, 'd': 4 };
|
|
2201
|
-
*
|
|
2202
|
-
* var values = _.memoize(_.values);
|
|
2203
|
-
* values(object);
|
|
2204
|
-
* // => [1, 2]
|
|
2205
|
-
*
|
|
2206
|
-
* values(other);
|
|
2207
|
-
* // => [3, 4]
|
|
2208
|
-
*
|
|
2209
|
-
* object.a = 2;
|
|
2210
|
-
* values(object);
|
|
2211
|
-
* // => [1, 2]
|
|
2212
|
-
*
|
|
2213
|
-
* // Modify the result cache.
|
|
2214
|
-
* values.cache.set(object, ['a', 'b']);
|
|
2215
|
-
* values(object);
|
|
2216
|
-
* // => ['a', 'b']
|
|
2217
|
-
*
|
|
2218
|
-
* // Replace `_.memoize.Cache`.
|
|
2219
|
-
* _.memoize.Cache = WeakMap;
|
|
2220
|
-
*/
|
|
2221
|
-
function memoize(func, resolver) {
|
|
2222
|
-
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
|
2223
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
2224
|
-
}
|
|
2225
|
-
var memoized = function() {
|
|
2226
|
-
var args = arguments,
|
|
2227
|
-
key = resolver ? resolver.apply(this, args) : args[0],
|
|
2228
|
-
cache = memoized.cache;
|
|
2229
|
-
|
|
2230
|
-
if (cache.has(key)) {
|
|
2231
|
-
return cache.get(key);
|
|
2232
|
-
}
|
|
2233
|
-
var result = func.apply(this, args);
|
|
2234
|
-
memoized.cache = cache.set(key, result) || cache;
|
|
2235
|
-
return result;
|
|
2236
|
-
};
|
|
2237
|
-
memoized.cache = new (memoize.Cache || MapCache);
|
|
2238
|
-
return memoized;
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
// Expose `MapCache`.
|
|
2242
|
-
memoize.Cache = MapCache;
|
|
2243
|
-
|
|
2244
|
-
/** Used as the maximum memoize cache size. */
|
|
2245
|
-
var MAX_MEMOIZE_SIZE = 500;
|
|
2246
|
-
|
|
2247
|
-
/**
|
|
2248
|
-
* A specialized version of `_.memoize` which clears the memoized function's
|
|
2249
|
-
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
2250
|
-
*
|
|
2251
|
-
* @private
|
|
2252
|
-
* @param {Function} func The function to have its output memoized.
|
|
2253
|
-
* @returns {Function} Returns the new memoized function.
|
|
2254
|
-
*/
|
|
2255
|
-
function memoizeCapped(func) {
|
|
2256
|
-
var result = memoize(func, function(key) {
|
|
2257
|
-
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
2258
|
-
cache.clear();
|
|
2259
|
-
}
|
|
2260
|
-
return key;
|
|
2261
|
-
});
|
|
2262
|
-
|
|
2263
|
-
var cache = result.cache;
|
|
2264
|
-
return result;
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
/** Used to match property names within property paths. */
|
|
2268
|
-
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
2269
|
-
|
|
2270
|
-
/** Used to match backslashes in property paths. */
|
|
2271
|
-
var reEscapeChar = /\\(\\)?/g;
|
|
2272
|
-
|
|
2273
|
-
/**
|
|
2274
|
-
* Converts `string` to a property path array.
|
|
2275
|
-
*
|
|
2276
|
-
* @private
|
|
2277
|
-
* @param {string} string The string to convert.
|
|
2278
|
-
* @returns {Array} Returns the property path array.
|
|
2279
|
-
*/
|
|
2280
|
-
var stringToPath = memoizeCapped(function(string) {
|
|
2281
|
-
var result = [];
|
|
2282
|
-
if (string.charCodeAt(0) === 46 /* . */) {
|
|
2283
|
-
result.push('');
|
|
2284
|
-
}
|
|
2285
|
-
string.replace(rePropName, function(match, number, quote, subString) {
|
|
2286
|
-
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
|
2287
|
-
});
|
|
2288
|
-
return result;
|
|
2289
|
-
});
|
|
2290
|
-
|
|
2291
|
-
/**
|
|
2292
|
-
* Converts `value` to a string. An empty string is returned for `null`
|
|
2293
|
-
* and `undefined` values. The sign of `-0` is preserved.
|
|
2294
|
-
*
|
|
2295
|
-
* @static
|
|
2296
|
-
* @memberOf _
|
|
2297
|
-
* @since 4.0.0
|
|
2298
|
-
* @category Lang
|
|
2299
|
-
* @param {*} value The value to convert.
|
|
2300
|
-
* @returns {string} Returns the converted string.
|
|
2301
|
-
* @example
|
|
2302
|
-
*
|
|
2303
|
-
* _.toString(null);
|
|
2304
|
-
* // => ''
|
|
2305
|
-
*
|
|
2306
|
-
* _.toString(-0);
|
|
2307
|
-
* // => '-0'
|
|
2308
|
-
*
|
|
2309
|
-
* _.toString([1, 2, 3]);
|
|
2310
|
-
* // => '1,2,3'
|
|
2311
|
-
*/
|
|
2312
|
-
function toString(value) {
|
|
2313
|
-
return value == null ? '' : baseToString(value);
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
/**
|
|
2317
|
-
* Casts `value` to a path array if it's not one.
|
|
2318
|
-
*
|
|
2319
|
-
* @private
|
|
2320
|
-
* @param {*} value The value to inspect.
|
|
2321
|
-
* @param {Object} [object] The object to query keys on.
|
|
2322
|
-
* @returns {Array} Returns the cast property path array.
|
|
2323
|
-
*/
|
|
2324
|
-
function castPath(value, object) {
|
|
2325
|
-
if (isArray(value)) {
|
|
2326
|
-
return value;
|
|
2327
|
-
}
|
|
2328
|
-
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
/** Used as references for various `Number` constants. */
|
|
2332
|
-
var INFINITY = 1 / 0;
|
|
2333
|
-
|
|
2334
|
-
/**
|
|
2335
|
-
* Converts `value` to a string key if it's not a string or symbol.
|
|
2336
|
-
*
|
|
2337
|
-
* @private
|
|
2338
|
-
* @param {*} value The value to inspect.
|
|
2339
|
-
* @returns {string|symbol} Returns the key.
|
|
2340
|
-
*/
|
|
2341
|
-
function toKey(value) {
|
|
2342
|
-
if (typeof value == 'string' || isSymbol(value)) {
|
|
2343
|
-
return value;
|
|
2344
|
-
}
|
|
2345
|
-
var result = (value + '');
|
|
2346
|
-
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
2347
|
-
}
|
|
2348
|
-
|
|
2349
|
-
/**
|
|
2350
|
-
* The base implementation of `_.get` without support for default values.
|
|
2351
|
-
*
|
|
2352
|
-
* @private
|
|
2353
|
-
* @param {Object} object The object to query.
|
|
2354
|
-
* @param {Array|string} path The path of the property to get.
|
|
2355
|
-
* @returns {*} Returns the resolved value.
|
|
2356
|
-
*/
|
|
2357
|
-
function baseGet(object, path) {
|
|
2358
|
-
path = castPath(path, object);
|
|
2359
|
-
|
|
2360
|
-
var index = 0,
|
|
2361
|
-
length = path.length;
|
|
2362
|
-
|
|
2363
|
-
while (object != null && index < length) {
|
|
2364
|
-
object = object[toKey(path[index++])];
|
|
2365
|
-
}
|
|
2366
|
-
return (index && index == length) ? object : undefined;
|
|
2367
|
-
}
|
|
2368
|
-
|
|
2369
|
-
/**
|
|
2370
|
-
* Gets the value at `path` of `object`. If the resolved value is
|
|
2371
|
-
* `undefined`, the `defaultValue` is returned in its place.
|
|
2372
|
-
*
|
|
2373
|
-
* @static
|
|
2374
|
-
* @memberOf _
|
|
2375
|
-
* @since 3.7.0
|
|
2376
|
-
* @category Object
|
|
2377
|
-
* @param {Object} object The object to query.
|
|
2378
|
-
* @param {Array|string} path The path of the property to get.
|
|
2379
|
-
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|
2380
|
-
* @returns {*} Returns the resolved value.
|
|
2381
|
-
* @example
|
|
2382
|
-
*
|
|
2383
|
-
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
2384
|
-
*
|
|
2385
|
-
* _.get(object, 'a[0].b.c');
|
|
2386
|
-
* // => 3
|
|
2387
|
-
*
|
|
2388
|
-
* _.get(object, ['a', '0', 'b', 'c']);
|
|
2389
|
-
* // => 3
|
|
2390
|
-
*
|
|
2391
|
-
* _.get(object, 'a.b.c', 'default');
|
|
2392
|
-
* // => 'default'
|
|
2393
|
-
*/
|
|
2394
|
-
function get(object, path, defaultValue) {
|
|
2395
|
-
var result = object == null ? undefined : baseGet(object, path);
|
|
2396
|
-
return result === undefined ? defaultValue : result;
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
/**
|
|
2400
|
-
* Appends the elements of `values` to `array`.
|
|
2401
|
-
*
|
|
2402
|
-
* @private
|
|
2403
|
-
* @param {Array} array The array to modify.
|
|
2404
|
-
* @param {Array} values The values to append.
|
|
2405
|
-
* @returns {Array} Returns `array`.
|
|
2406
|
-
*/
|
|
2407
|
-
function arrayPush(array, values) {
|
|
2408
|
-
var index = -1,
|
|
2409
|
-
length = values.length,
|
|
2410
|
-
offset = array.length;
|
|
2411
|
-
|
|
2412
|
-
while (++index < length) {
|
|
2413
|
-
array[offset + index] = values[index];
|
|
2414
|
-
}
|
|
2415
|
-
return array;
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
/**
|
|
2419
|
-
* Removes all key-value entries from the stack.
|
|
2420
|
-
*
|
|
2421
|
-
* @private
|
|
2422
|
-
* @name clear
|
|
2423
|
-
* @memberOf Stack
|
|
2424
|
-
*/
|
|
2425
|
-
function stackClear() {
|
|
2426
|
-
this.__data__ = new ListCache;
|
|
2427
|
-
this.size = 0;
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
/**
|
|
2431
|
-
* Removes `key` and its value from the stack.
|
|
2432
|
-
*
|
|
2433
|
-
* @private
|
|
2434
|
-
* @name delete
|
|
2435
|
-
* @memberOf Stack
|
|
2436
|
-
* @param {string} key The key of the value to remove.
|
|
2437
|
-
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
2438
|
-
*/
|
|
2439
|
-
function stackDelete(key) {
|
|
2440
|
-
var data = this.__data__,
|
|
2441
|
-
result = data['delete'](key);
|
|
2442
|
-
|
|
2443
|
-
this.size = data.size;
|
|
2444
|
-
return result;
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
/**
|
|
2448
|
-
* Gets the stack value for `key`.
|
|
2449
|
-
*
|
|
2450
|
-
* @private
|
|
2451
|
-
* @name get
|
|
2452
|
-
* @memberOf Stack
|
|
2453
|
-
* @param {string} key The key of the value to get.
|
|
2454
|
-
* @returns {*} Returns the entry value.
|
|
2455
|
-
*/
|
|
2456
|
-
function stackGet(key) {
|
|
2457
|
-
return this.__data__.get(key);
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
/**
|
|
2461
|
-
* Checks if a stack value for `key` exists.
|
|
2462
|
-
*
|
|
2463
|
-
* @private
|
|
2464
|
-
* @name has
|
|
2465
|
-
* @memberOf Stack
|
|
2466
|
-
* @param {string} key The key of the entry to check.
|
|
2467
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
2468
|
-
*/
|
|
2469
|
-
function stackHas(key) {
|
|
2470
|
-
return this.__data__.has(key);
|
|
2471
|
-
}
|
|
2472
|
-
|
|
2473
|
-
/** Used as the size to enable large array optimizations. */
|
|
2474
|
-
var LARGE_ARRAY_SIZE = 200;
|
|
2475
|
-
|
|
2476
|
-
/**
|
|
2477
|
-
* Sets the stack `key` to `value`.
|
|
2478
|
-
*
|
|
2479
|
-
* @private
|
|
2480
|
-
* @name set
|
|
2481
|
-
* @memberOf Stack
|
|
2482
|
-
* @param {string} key The key of the value to set.
|
|
2483
|
-
* @param {*} value The value to set.
|
|
2484
|
-
* @returns {Object} Returns the stack cache instance.
|
|
2485
|
-
*/
|
|
2486
|
-
function stackSet(key, value) {
|
|
2487
|
-
var data = this.__data__;
|
|
2488
|
-
if (data instanceof ListCache) {
|
|
2489
|
-
var pairs = data.__data__;
|
|
2490
|
-
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
2491
|
-
pairs.push([key, value]);
|
|
2492
|
-
this.size = ++data.size;
|
|
2493
|
-
return this;
|
|
2494
|
-
}
|
|
2495
|
-
data = this.__data__ = new MapCache(pairs);
|
|
2496
|
-
}
|
|
2497
|
-
data.set(key, value);
|
|
2498
|
-
this.size = data.size;
|
|
2499
|
-
return this;
|
|
2500
|
-
}
|
|
2501
|
-
|
|
2502
|
-
/**
|
|
2503
|
-
* Creates a stack cache object to store key-value pairs.
|
|
2504
|
-
*
|
|
2505
|
-
* @private
|
|
2506
|
-
* @constructor
|
|
2507
|
-
* @param {Array} [entries] The key-value pairs to cache.
|
|
2508
|
-
*/
|
|
2509
|
-
function Stack(entries) {
|
|
2510
|
-
var data = this.__data__ = new ListCache(entries);
|
|
2511
|
-
this.size = data.size;
|
|
2512
|
-
}
|
|
2513
|
-
|
|
2514
|
-
// Add methods to `Stack`.
|
|
2515
|
-
Stack.prototype.clear = stackClear;
|
|
2516
|
-
Stack.prototype['delete'] = stackDelete;
|
|
2517
|
-
Stack.prototype.get = stackGet;
|
|
2518
|
-
Stack.prototype.has = stackHas;
|
|
2519
|
-
Stack.prototype.set = stackSet;
|
|
2520
|
-
|
|
2521
|
-
/**
|
|
2522
|
-
* A specialized version of `_.filter` for arrays without support for
|
|
2523
|
-
* iteratee shorthands.
|
|
2524
|
-
*
|
|
2525
|
-
* @private
|
|
2526
|
-
* @param {Array} [array] The array to iterate over.
|
|
2527
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
2528
|
-
* @returns {Array} Returns the new filtered array.
|
|
2529
|
-
*/
|
|
2530
|
-
function arrayFilter(array, predicate) {
|
|
2531
|
-
var index = -1,
|
|
2532
|
-
length = array == null ? 0 : array.length,
|
|
2533
|
-
resIndex = 0,
|
|
2534
|
-
result = [];
|
|
2535
|
-
|
|
2536
|
-
while (++index < length) {
|
|
2537
|
-
var value = array[index];
|
|
2538
|
-
if (predicate(value, index, array)) {
|
|
2539
|
-
result[resIndex++] = value;
|
|
2540
|
-
}
|
|
2541
|
-
}
|
|
2542
|
-
return result;
|
|
2543
|
-
}
|
|
2544
|
-
|
|
2545
|
-
/**
|
|
2546
|
-
* This method returns a new empty array.
|
|
2547
|
-
*
|
|
2548
|
-
* @static
|
|
2549
|
-
* @memberOf _
|
|
2550
|
-
* @since 4.13.0
|
|
2551
|
-
* @category Util
|
|
2552
|
-
* @returns {Array} Returns the new empty array.
|
|
2553
|
-
* @example
|
|
2554
|
-
*
|
|
2555
|
-
* var arrays = _.times(2, _.stubArray);
|
|
2556
|
-
*
|
|
2557
|
-
* console.log(arrays);
|
|
2558
|
-
* // => [[], []]
|
|
2559
|
-
*
|
|
2560
|
-
* console.log(arrays[0] === arrays[1]);
|
|
2561
|
-
* // => false
|
|
2562
|
-
*/
|
|
2563
|
-
function stubArray() {
|
|
2564
|
-
return [];
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
|
-
/** Used for built-in method references. */
|
|
2568
|
-
var objectProto$2 = Object.prototype;
|
|
2569
|
-
|
|
2570
|
-
/** Built-in value references. */
|
|
2571
|
-
var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
|
|
2572
|
-
|
|
2573
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
2574
|
-
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
2575
|
-
|
|
2576
|
-
/**
|
|
2577
|
-
* Creates an array of the own enumerable symbols of `object`.
|
|
2578
|
-
*
|
|
2579
|
-
* @private
|
|
2580
|
-
* @param {Object} object The object to query.
|
|
2581
|
-
* @returns {Array} Returns the array of symbols.
|
|
2582
|
-
*/
|
|
2583
|
-
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
|
2584
|
-
if (object == null) {
|
|
2585
|
-
return [];
|
|
2586
|
-
}
|
|
2587
|
-
object = Object(object);
|
|
2588
|
-
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
|
2589
|
-
return propertyIsEnumerable.call(object, symbol);
|
|
2590
|
-
});
|
|
2591
|
-
};
|
|
2592
|
-
|
|
2593
|
-
/**
|
|
2594
|
-
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
|
2595
|
-
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
|
2596
|
-
* symbols of `object`.
|
|
2597
|
-
*
|
|
2598
|
-
* @private
|
|
2599
|
-
* @param {Object} object The object to query.
|
|
2600
|
-
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
2601
|
-
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
|
2602
|
-
* @returns {Array} Returns the array of property names and symbols.
|
|
2603
|
-
*/
|
|
2604
|
-
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
|
2605
|
-
var result = keysFunc(object);
|
|
2606
|
-
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
|
2607
|
-
}
|
|
2608
|
-
|
|
2609
|
-
/**
|
|
2610
|
-
* Creates an array of own enumerable property names and symbols of `object`.
|
|
2611
|
-
*
|
|
2612
|
-
* @private
|
|
2613
|
-
* @param {Object} object The object to query.
|
|
2614
|
-
* @returns {Array} Returns the array of property names and symbols.
|
|
2615
|
-
*/
|
|
2616
|
-
function getAllKeys(object) {
|
|
2617
|
-
return baseGetAllKeys(object, keys, getSymbols);
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
|
-
/* Built-in method references that are verified to be native. */
|
|
2621
|
-
var DataView = getNative(root, 'DataView');
|
|
2622
|
-
|
|
2623
|
-
/* Built-in method references that are verified to be native. */
|
|
2624
|
-
var Promise$1 = getNative(root, 'Promise');
|
|
2625
|
-
|
|
2626
|
-
/* Built-in method references that are verified to be native. */
|
|
2627
|
-
var Set = getNative(root, 'Set');
|
|
2628
|
-
|
|
2629
|
-
/** `Object#toString` result references. */
|
|
2630
|
-
var mapTag$1 = '[object Map]',
|
|
2631
|
-
objectTag$1 = '[object Object]',
|
|
2632
|
-
promiseTag = '[object Promise]',
|
|
2633
|
-
setTag$1 = '[object Set]',
|
|
2634
|
-
weakMapTag = '[object WeakMap]';
|
|
2635
|
-
|
|
2636
|
-
var dataViewTag$1 = '[object DataView]';
|
|
2637
|
-
|
|
2638
|
-
/** Used to detect maps, sets, and weakmaps. */
|
|
2639
|
-
var dataViewCtorString = toSource(DataView),
|
|
2640
|
-
mapCtorString = toSource(Map),
|
|
2641
|
-
promiseCtorString = toSource(Promise$1),
|
|
2642
|
-
setCtorString = toSource(Set),
|
|
2643
|
-
weakMapCtorString = toSource(WeakMap);
|
|
2644
|
-
|
|
2645
|
-
/**
|
|
2646
|
-
* Gets the `toStringTag` of `value`.
|
|
2647
|
-
*
|
|
2648
|
-
* @private
|
|
2649
|
-
* @param {*} value The value to query.
|
|
2650
|
-
* @returns {string} Returns the `toStringTag`.
|
|
2651
|
-
*/
|
|
2652
|
-
var getTag = baseGetTag;
|
|
2653
|
-
|
|
2654
|
-
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
2655
|
-
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
|
|
2656
|
-
(Map && getTag(new Map) != mapTag$1) ||
|
|
2657
|
-
(Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
|
|
2658
|
-
(Set && getTag(new Set) != setTag$1) ||
|
|
2659
|
-
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|
2660
|
-
getTag = function(value) {
|
|
2661
|
-
var result = baseGetTag(value),
|
|
2662
|
-
Ctor = result == objectTag$1 ? value.constructor : undefined,
|
|
2663
|
-
ctorString = Ctor ? toSource(Ctor) : '';
|
|
2664
|
-
|
|
2665
|
-
if (ctorString) {
|
|
2666
|
-
switch (ctorString) {
|
|
2667
|
-
case dataViewCtorString: return dataViewTag$1;
|
|
2668
|
-
case mapCtorString: return mapTag$1;
|
|
2669
|
-
case promiseCtorString: return promiseTag;
|
|
2670
|
-
case setCtorString: return setTag$1;
|
|
2671
|
-
case weakMapCtorString: return weakMapTag;
|
|
2672
|
-
}
|
|
2673
|
-
}
|
|
2674
|
-
return result;
|
|
2675
|
-
};
|
|
2676
|
-
}
|
|
2677
|
-
|
|
2678
|
-
var getTag$1 = getTag;
|
|
2679
|
-
|
|
2680
|
-
/** Built-in value references. */
|
|
2681
|
-
var Uint8Array = root.Uint8Array;
|
|
2682
|
-
|
|
2683
|
-
/** Used to stand-in for `undefined` hash values. */
|
|
2684
|
-
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
2685
|
-
|
|
2686
|
-
/**
|
|
2687
|
-
* Adds `value` to the array cache.
|
|
2688
|
-
*
|
|
2689
|
-
* @private
|
|
2690
|
-
* @name add
|
|
2691
|
-
* @memberOf SetCache
|
|
2692
|
-
* @alias push
|
|
2693
|
-
* @param {*} value The value to cache.
|
|
2694
|
-
* @returns {Object} Returns the cache instance.
|
|
2695
|
-
*/
|
|
2696
|
-
function setCacheAdd(value) {
|
|
2697
|
-
this.__data__.set(value, HASH_UNDEFINED);
|
|
2698
|
-
return this;
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
|
-
/**
|
|
2702
|
-
* Checks if `value` is in the array cache.
|
|
2703
|
-
*
|
|
2704
|
-
* @private
|
|
2705
|
-
* @name has
|
|
2706
|
-
* @memberOf SetCache
|
|
2707
|
-
* @param {*} value The value to search for.
|
|
2708
|
-
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
2709
|
-
*/
|
|
2710
|
-
function setCacheHas(value) {
|
|
2711
|
-
return this.__data__.has(value);
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
/**
|
|
2715
|
-
*
|
|
2716
|
-
* Creates an array cache object to store unique values.
|
|
2717
|
-
*
|
|
2718
|
-
* @private
|
|
2719
|
-
* @constructor
|
|
2720
|
-
* @param {Array} [values] The values to cache.
|
|
2721
|
-
*/
|
|
2722
|
-
function SetCache(values) {
|
|
2723
|
-
var index = -1,
|
|
2724
|
-
length = values == null ? 0 : values.length;
|
|
2725
|
-
|
|
2726
|
-
this.__data__ = new MapCache;
|
|
2727
|
-
while (++index < length) {
|
|
2728
|
-
this.add(values[index]);
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
// Add methods to `SetCache`.
|
|
2733
|
-
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
2734
|
-
SetCache.prototype.has = setCacheHas;
|
|
2735
|
-
|
|
2736
|
-
/**
|
|
2737
|
-
* A specialized version of `_.some` for arrays without support for iteratee
|
|
2738
|
-
* shorthands.
|
|
2739
|
-
*
|
|
2740
|
-
* @private
|
|
2741
|
-
* @param {Array} [array] The array to iterate over.
|
|
2742
|
-
* @param {Function} predicate The function invoked per iteration.
|
|
2743
|
-
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
2744
|
-
* else `false`.
|
|
2745
|
-
*/
|
|
2746
|
-
function arraySome(array, predicate) {
|
|
2747
|
-
var index = -1,
|
|
2748
|
-
length = array == null ? 0 : array.length;
|
|
2749
|
-
|
|
2750
|
-
while (++index < length) {
|
|
2751
|
-
if (predicate(array[index], index, array)) {
|
|
2752
|
-
return true;
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
return false;
|
|
2756
|
-
}
|
|
2757
|
-
|
|
2758
|
-
/**
|
|
2759
|
-
* Checks if a `cache` value for `key` exists.
|
|
2760
|
-
*
|
|
2761
|
-
* @private
|
|
2762
|
-
* @param {Object} cache The cache to query.
|
|
2763
|
-
* @param {string} key The key of the entry to check.
|
|
2764
|
-
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
2765
|
-
*/
|
|
2766
|
-
function cacheHas(cache, key) {
|
|
2767
|
-
return cache.has(key);
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2770
|
-
/** Used to compose bitmasks for value comparisons. */
|
|
2771
|
-
var COMPARE_PARTIAL_FLAG$5 = 1,
|
|
2772
|
-
COMPARE_UNORDERED_FLAG$3 = 2;
|
|
2773
|
-
|
|
2774
|
-
/**
|
|
2775
|
-
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
2776
|
-
* partial deep comparisons.
|
|
2777
|
-
*
|
|
2778
|
-
* @private
|
|
2779
|
-
* @param {Array} array The array to compare.
|
|
2780
|
-
* @param {Array} other The other array to compare.
|
|
2781
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
2782
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
2783
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
2784
|
-
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|
2785
|
-
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
2786
|
-
*/
|
|
2787
|
-
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
|
2788
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
|
|
2789
|
-
arrLength = array.length,
|
|
2790
|
-
othLength = other.length;
|
|
2791
|
-
|
|
2792
|
-
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
2793
|
-
return false;
|
|
2794
|
-
}
|
|
2795
|
-
// Check that cyclic values are equal.
|
|
2796
|
-
var arrStacked = stack.get(array);
|
|
2797
|
-
var othStacked = stack.get(other);
|
|
2798
|
-
if (arrStacked && othStacked) {
|
|
2799
|
-
return arrStacked == other && othStacked == array;
|
|
2800
|
-
}
|
|
2801
|
-
var index = -1,
|
|
2802
|
-
result = true,
|
|
2803
|
-
seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined;
|
|
2804
|
-
|
|
2805
|
-
stack.set(array, other);
|
|
2806
|
-
stack.set(other, array);
|
|
2807
|
-
|
|
2808
|
-
// Ignore non-index properties.
|
|
2809
|
-
while (++index < arrLength) {
|
|
2810
|
-
var arrValue = array[index],
|
|
2811
|
-
othValue = other[index];
|
|
2812
|
-
|
|
2813
|
-
if (customizer) {
|
|
2814
|
-
var compared = isPartial
|
|
2815
|
-
? customizer(othValue, arrValue, index, other, array, stack)
|
|
2816
|
-
: customizer(arrValue, othValue, index, array, other, stack);
|
|
2817
|
-
}
|
|
2818
|
-
if (compared !== undefined) {
|
|
2819
|
-
if (compared) {
|
|
2820
|
-
continue;
|
|
2821
|
-
}
|
|
2822
|
-
result = false;
|
|
2823
|
-
break;
|
|
2824
|
-
}
|
|
2825
|
-
// Recursively compare arrays (susceptible to call stack limits).
|
|
2826
|
-
if (seen) {
|
|
2827
|
-
if (!arraySome(other, function(othValue, othIndex) {
|
|
2828
|
-
if (!cacheHas(seen, othIndex) &&
|
|
2829
|
-
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
2830
|
-
return seen.push(othIndex);
|
|
2831
|
-
}
|
|
2832
|
-
})) {
|
|
2833
|
-
result = false;
|
|
2834
|
-
break;
|
|
2835
|
-
}
|
|
2836
|
-
} else if (!(
|
|
2837
|
-
arrValue === othValue ||
|
|
2838
|
-
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
|
2839
|
-
)) {
|
|
2840
|
-
result = false;
|
|
2841
|
-
break;
|
|
2842
|
-
}
|
|
2843
|
-
}
|
|
2844
|
-
stack['delete'](array);
|
|
2845
|
-
stack['delete'](other);
|
|
2846
|
-
return result;
|
|
2847
|
-
}
|
|
2848
|
-
|
|
2849
|
-
/**
|
|
2850
|
-
* Converts `map` to its key-value pairs.
|
|
2851
|
-
*
|
|
2852
|
-
* @private
|
|
2853
|
-
* @param {Object} map The map to convert.
|
|
2854
|
-
* @returns {Array} Returns the key-value pairs.
|
|
2855
|
-
*/
|
|
2856
|
-
function mapToArray(map) {
|
|
2857
|
-
var index = -1,
|
|
2858
|
-
result = Array(map.size);
|
|
2859
|
-
|
|
2860
|
-
map.forEach(function(value, key) {
|
|
2861
|
-
result[++index] = [key, value];
|
|
2862
|
-
});
|
|
2863
|
-
return result;
|
|
2864
|
-
}
|
|
2865
|
-
|
|
2866
|
-
/**
|
|
2867
|
-
* Converts `set` to an array of its values.
|
|
2868
|
-
*
|
|
2869
|
-
* @private
|
|
2870
|
-
* @param {Object} set The set to convert.
|
|
2871
|
-
* @returns {Array} Returns the values.
|
|
2872
|
-
*/
|
|
2873
|
-
function setToArray(set) {
|
|
2874
|
-
var index = -1,
|
|
2875
|
-
result = Array(set.size);
|
|
2876
|
-
|
|
2877
|
-
set.forEach(function(value) {
|
|
2878
|
-
result[++index] = value;
|
|
2879
|
-
});
|
|
2880
|
-
return result;
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
/** Used to compose bitmasks for value comparisons. */
|
|
2884
|
-
var COMPARE_PARTIAL_FLAG$4 = 1,
|
|
2885
|
-
COMPARE_UNORDERED_FLAG$2 = 2;
|
|
2886
|
-
|
|
2887
|
-
/** `Object#toString` result references. */
|
|
2888
|
-
var boolTag = '[object Boolean]',
|
|
2889
|
-
dateTag = '[object Date]',
|
|
2890
|
-
errorTag = '[object Error]',
|
|
2891
|
-
mapTag = '[object Map]',
|
|
2892
|
-
numberTag = '[object Number]',
|
|
2893
|
-
regexpTag = '[object RegExp]',
|
|
2894
|
-
setTag = '[object Set]',
|
|
2895
|
-
stringTag = '[object String]',
|
|
2896
|
-
symbolTag = '[object Symbol]';
|
|
2897
|
-
|
|
2898
|
-
var arrayBufferTag = '[object ArrayBuffer]',
|
|
2899
|
-
dataViewTag = '[object DataView]';
|
|
2900
|
-
|
|
2901
|
-
/** Used to convert symbols to primitives and strings. */
|
|
2902
|
-
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
2903
|
-
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
2904
|
-
|
|
2905
|
-
/**
|
|
2906
|
-
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
2907
|
-
* the same `toStringTag`.
|
|
2908
|
-
*
|
|
2909
|
-
* **Note:** This function only supports comparing values with tags of
|
|
2910
|
-
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
2911
|
-
*
|
|
2912
|
-
* @private
|
|
2913
|
-
* @param {Object} object The object to compare.
|
|
2914
|
-
* @param {Object} other The other object to compare.
|
|
2915
|
-
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
2916
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
2917
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
2918
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
2919
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
2920
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
2921
|
-
*/
|
|
2922
|
-
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
2923
|
-
switch (tag) {
|
|
2924
|
-
case dataViewTag:
|
|
2925
|
-
if ((object.byteLength != other.byteLength) ||
|
|
2926
|
-
(object.byteOffset != other.byteOffset)) {
|
|
2927
|
-
return false;
|
|
2928
|
-
}
|
|
2929
|
-
object = object.buffer;
|
|
2930
|
-
other = other.buffer;
|
|
2931
|
-
|
|
2932
|
-
case arrayBufferTag:
|
|
2933
|
-
if ((object.byteLength != other.byteLength) ||
|
|
2934
|
-
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
|
2935
|
-
return false;
|
|
2936
|
-
}
|
|
2937
|
-
return true;
|
|
2938
|
-
|
|
2939
|
-
case boolTag:
|
|
2940
|
-
case dateTag:
|
|
2941
|
-
case numberTag:
|
|
2942
|
-
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
|
2943
|
-
// Invalid dates are coerced to `NaN`.
|
|
2944
|
-
return eq(+object, +other);
|
|
2945
|
-
|
|
2946
|
-
case errorTag:
|
|
2947
|
-
return object.name == other.name && object.message == other.message;
|
|
2948
|
-
|
|
2949
|
-
case regexpTag:
|
|
2950
|
-
case stringTag:
|
|
2951
|
-
// Coerce regexes to strings and treat strings, primitives and objects,
|
|
2952
|
-
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
|
2953
|
-
// for more details.
|
|
2954
|
-
return object == (other + '');
|
|
2955
|
-
|
|
2956
|
-
case mapTag:
|
|
2957
|
-
var convert = mapToArray;
|
|
2958
|
-
|
|
2959
|
-
case setTag:
|
|
2960
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
|
|
2961
|
-
convert || (convert = setToArray);
|
|
2962
|
-
|
|
2963
|
-
if (object.size != other.size && !isPartial) {
|
|
2964
|
-
return false;
|
|
2965
|
-
}
|
|
2966
|
-
// Assume cyclic values are equal.
|
|
2967
|
-
var stacked = stack.get(object);
|
|
2968
|
-
if (stacked) {
|
|
2969
|
-
return stacked == other;
|
|
2970
|
-
}
|
|
2971
|
-
bitmask |= COMPARE_UNORDERED_FLAG$2;
|
|
2972
|
-
|
|
2973
|
-
// Recursively compare objects (susceptible to call stack limits).
|
|
2974
|
-
stack.set(object, other);
|
|
2975
|
-
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
2976
|
-
stack['delete'](object);
|
|
2977
|
-
return result;
|
|
2978
|
-
|
|
2979
|
-
case symbolTag:
|
|
2980
|
-
if (symbolValueOf) {
|
|
2981
|
-
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
2982
|
-
}
|
|
2983
|
-
}
|
|
2984
|
-
return false;
|
|
2985
|
-
}
|
|
2986
|
-
|
|
2987
|
-
/** Used to compose bitmasks for value comparisons. */
|
|
2988
|
-
var COMPARE_PARTIAL_FLAG$3 = 1;
|
|
2989
|
-
|
|
2990
|
-
/** Used for built-in method references. */
|
|
2991
|
-
var objectProto$1 = Object.prototype;
|
|
2992
|
-
|
|
2993
|
-
/** Used to check objects for own properties. */
|
|
2994
|
-
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
2995
|
-
|
|
2996
|
-
/**
|
|
2997
|
-
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
2998
|
-
* partial deep comparisons.
|
|
2999
|
-
*
|
|
3000
|
-
* @private
|
|
3001
|
-
* @param {Object} object The object to compare.
|
|
3002
|
-
* @param {Object} other The other object to compare.
|
|
3003
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
3004
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
3005
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
3006
|
-
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|
3007
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
3008
|
-
*/
|
|
3009
|
-
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
|
3010
|
-
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
|
|
3011
|
-
objProps = getAllKeys(object),
|
|
3012
|
-
objLength = objProps.length,
|
|
3013
|
-
othProps = getAllKeys(other),
|
|
3014
|
-
othLength = othProps.length;
|
|
3015
|
-
|
|
3016
|
-
if (objLength != othLength && !isPartial) {
|
|
3017
|
-
return false;
|
|
3018
|
-
}
|
|
3019
|
-
var index = objLength;
|
|
3020
|
-
while (index--) {
|
|
3021
|
-
var key = objProps[index];
|
|
3022
|
-
if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
|
|
3023
|
-
return false;
|
|
3024
|
-
}
|
|
3025
|
-
}
|
|
3026
|
-
// Check that cyclic values are equal.
|
|
3027
|
-
var objStacked = stack.get(object);
|
|
3028
|
-
var othStacked = stack.get(other);
|
|
3029
|
-
if (objStacked && othStacked) {
|
|
3030
|
-
return objStacked == other && othStacked == object;
|
|
3031
|
-
}
|
|
3032
|
-
var result = true;
|
|
3033
|
-
stack.set(object, other);
|
|
3034
|
-
stack.set(other, object);
|
|
3035
|
-
|
|
3036
|
-
var skipCtor = isPartial;
|
|
3037
|
-
while (++index < objLength) {
|
|
3038
|
-
key = objProps[index];
|
|
3039
|
-
var objValue = object[key],
|
|
3040
|
-
othValue = other[key];
|
|
3041
|
-
|
|
3042
|
-
if (customizer) {
|
|
3043
|
-
var compared = isPartial
|
|
3044
|
-
? customizer(othValue, objValue, key, other, object, stack)
|
|
3045
|
-
: customizer(objValue, othValue, key, object, other, stack);
|
|
3046
|
-
}
|
|
3047
|
-
// Recursively compare objects (susceptible to call stack limits).
|
|
3048
|
-
if (!(compared === undefined
|
|
3049
|
-
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
|
3050
|
-
: compared
|
|
3051
|
-
)) {
|
|
3052
|
-
result = false;
|
|
3053
|
-
break;
|
|
3054
|
-
}
|
|
3055
|
-
skipCtor || (skipCtor = key == 'constructor');
|
|
3056
|
-
}
|
|
3057
|
-
if (result && !skipCtor) {
|
|
3058
|
-
var objCtor = object.constructor,
|
|
3059
|
-
othCtor = other.constructor;
|
|
3060
|
-
|
|
3061
|
-
// Non `Object` object instances with different constructors are not equal.
|
|
3062
|
-
if (objCtor != othCtor &&
|
|
3063
|
-
('constructor' in object && 'constructor' in other) &&
|
|
3064
|
-
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
|
3065
|
-
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|
3066
|
-
result = false;
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
stack['delete'](object);
|
|
3070
|
-
stack['delete'](other);
|
|
3071
|
-
return result;
|
|
3072
|
-
}
|
|
3073
|
-
|
|
3074
|
-
/** Used to compose bitmasks for value comparisons. */
|
|
3075
|
-
var COMPARE_PARTIAL_FLAG$2 = 1;
|
|
3076
|
-
|
|
3077
|
-
/** `Object#toString` result references. */
|
|
3078
|
-
var argsTag = '[object Arguments]',
|
|
3079
|
-
arrayTag = '[object Array]',
|
|
3080
|
-
objectTag = '[object Object]';
|
|
3081
|
-
|
|
3082
|
-
/** Used for built-in method references. */
|
|
3083
|
-
var objectProto = Object.prototype;
|
|
3084
|
-
|
|
3085
|
-
/** Used to check objects for own properties. */
|
|
3086
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
3087
|
-
|
|
3088
|
-
/**
|
|
3089
|
-
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
3090
|
-
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
3091
|
-
* references to be compared.
|
|
3092
|
-
*
|
|
3093
|
-
* @private
|
|
3094
|
-
* @param {Object} object The object to compare.
|
|
3095
|
-
* @param {Object} other The other object to compare.
|
|
3096
|
-
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
|
3097
|
-
* @param {Function} customizer The function to customize comparisons.
|
|
3098
|
-
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
3099
|
-
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|
3100
|
-
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
3101
|
-
*/
|
|
3102
|
-
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
|
3103
|
-
var objIsArr = isArray(object),
|
|
3104
|
-
othIsArr = isArray(other),
|
|
3105
|
-
objTag = objIsArr ? arrayTag : getTag$1(object),
|
|
3106
|
-
othTag = othIsArr ? arrayTag : getTag$1(other);
|
|
3107
|
-
|
|
3108
|
-
objTag = objTag == argsTag ? objectTag : objTag;
|
|
3109
|
-
othTag = othTag == argsTag ? objectTag : othTag;
|
|
3110
|
-
|
|
3111
|
-
var objIsObj = objTag == objectTag,
|
|
3112
|
-
othIsObj = othTag == objectTag,
|
|
3113
|
-
isSameTag = objTag == othTag;
|
|
3114
|
-
|
|
3115
|
-
if (isSameTag && isBuffer(object)) {
|
|
3116
|
-
if (!isBuffer(other)) {
|
|
3117
|
-
return false;
|
|
3118
|
-
}
|
|
3119
|
-
objIsArr = true;
|
|
3120
|
-
objIsObj = false;
|
|
3121
|
-
}
|
|
3122
|
-
if (isSameTag && !objIsObj) {
|
|
3123
|
-
stack || (stack = new Stack);
|
|
3124
|
-
return (objIsArr || isTypedArray(object))
|
|
3125
|
-
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
|
3126
|
-
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
3127
|
-
}
|
|
3128
|
-
if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
|
|
3129
|
-
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
3130
|
-
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
3131
|
-
|
|
3132
|
-
if (objIsWrapped || othIsWrapped) {
|
|
3133
|
-
var objUnwrapped = objIsWrapped ? object.value() : object,
|
|
3134
|
-
othUnwrapped = othIsWrapped ? other.value() : other;
|
|
3135
|
-
|
|
3136
|
-
stack || (stack = new Stack);
|
|
3137
|
-
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
3138
|
-
}
|
|
3139
|
-
}
|
|
3140
|
-
if (!isSameTag) {
|
|
3141
|
-
return false;
|
|
3142
|
-
}
|
|
3143
|
-
stack || (stack = new Stack);
|
|
3144
|
-
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
|
3145
|
-
}
|
|
3146
|
-
|
|
3147
|
-
/**
|
|
3148
|
-
* The base implementation of `_.isEqual` which supports partial comparisons
|
|
3149
|
-
* and tracks traversed objects.
|
|
3150
|
-
*
|
|
3151
|
-
* @private
|
|
3152
|
-
* @param {*} value The value to compare.
|
|
3153
|
-
* @param {*} other The other value to compare.
|
|
3154
|
-
* @param {boolean} bitmask The bitmask flags.
|
|
3155
|
-
* 1 - Unordered comparison
|
|
3156
|
-
* 2 - Partial comparison
|
|
3157
|
-
* @param {Function} [customizer] The function to customize comparisons.
|
|
3158
|
-
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
|
3159
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
3160
|
-
*/
|
|
3161
|
-
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
3162
|
-
if (value === other) {
|
|
3163
|
-
return true;
|
|
3164
|
-
}
|
|
3165
|
-
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
|
3166
|
-
return value !== value && other !== other;
|
|
3167
|
-
}
|
|
3168
|
-
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
3169
|
-
}
|
|
3170
|
-
|
|
3171
|
-
/** Used to compose bitmasks for value comparisons. */
|
|
3172
|
-
var COMPARE_PARTIAL_FLAG$1 = 1,
|
|
3173
|
-
COMPARE_UNORDERED_FLAG$1 = 2;
|
|
3174
|
-
|
|
3175
|
-
/**
|
|
3176
|
-
* The base implementation of `_.isMatch` without support for iteratee shorthands.
|
|
3177
|
-
*
|
|
3178
|
-
* @private
|
|
3179
|
-
* @param {Object} object The object to inspect.
|
|
3180
|
-
* @param {Object} source The object of property values to match.
|
|
3181
|
-
* @param {Array} matchData The property names, values, and compare flags to match.
|
|
3182
|
-
* @param {Function} [customizer] The function to customize comparisons.
|
|
3183
|
-
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
|
3184
|
-
*/
|
|
3185
|
-
function baseIsMatch(object, source, matchData, customizer) {
|
|
3186
|
-
var index = matchData.length,
|
|
3187
|
-
length = index,
|
|
3188
|
-
noCustomizer = !customizer;
|
|
3189
|
-
|
|
3190
|
-
if (object == null) {
|
|
3191
|
-
return !length;
|
|
3192
|
-
}
|
|
3193
|
-
object = Object(object);
|
|
3194
|
-
while (index--) {
|
|
3195
|
-
var data = matchData[index];
|
|
3196
|
-
if ((noCustomizer && data[2])
|
|
3197
|
-
? data[1] !== object[data[0]]
|
|
3198
|
-
: !(data[0] in object)
|
|
3199
|
-
) {
|
|
3200
|
-
return false;
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
while (++index < length) {
|
|
3204
|
-
data = matchData[index];
|
|
3205
|
-
var key = data[0],
|
|
3206
|
-
objValue = object[key],
|
|
3207
|
-
srcValue = data[1];
|
|
3208
|
-
|
|
3209
|
-
if (noCustomizer && data[2]) {
|
|
3210
|
-
if (objValue === undefined && !(key in object)) {
|
|
3211
|
-
return false;
|
|
3212
|
-
}
|
|
3213
|
-
} else {
|
|
3214
|
-
var stack = new Stack;
|
|
3215
|
-
if (customizer) {
|
|
3216
|
-
var result = customizer(objValue, srcValue, key, object, source, stack);
|
|
3217
|
-
}
|
|
3218
|
-
if (!(result === undefined
|
|
3219
|
-
? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
|
|
3220
|
-
: result
|
|
3221
|
-
)) {
|
|
3222
|
-
return false;
|
|
3223
|
-
}
|
|
3224
|
-
}
|
|
3225
|
-
}
|
|
3226
|
-
return true;
|
|
3227
|
-
}
|
|
3228
|
-
|
|
3229
|
-
/**
|
|
3230
|
-
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
|
3231
|
-
*
|
|
3232
|
-
* @private
|
|
3233
|
-
* @param {*} value The value to check.
|
|
3234
|
-
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
|
3235
|
-
* equality comparisons, else `false`.
|
|
3236
|
-
*/
|
|
3237
|
-
function isStrictComparable(value) {
|
|
3238
|
-
return value === value && !isObject(value);
|
|
3239
|
-
}
|
|
3240
|
-
|
|
3241
|
-
/**
|
|
3242
|
-
* Gets the property names, values, and compare flags of `object`.
|
|
3243
|
-
*
|
|
3244
|
-
* @private
|
|
3245
|
-
* @param {Object} object The object to query.
|
|
3246
|
-
* @returns {Array} Returns the match data of `object`.
|
|
3247
|
-
*/
|
|
3248
|
-
function getMatchData(object) {
|
|
3249
|
-
var result = keys(object),
|
|
3250
|
-
length = result.length;
|
|
3251
|
-
|
|
3252
|
-
while (length--) {
|
|
3253
|
-
var key = result[length],
|
|
3254
|
-
value = object[key];
|
|
3255
|
-
|
|
3256
|
-
result[length] = [key, value, isStrictComparable(value)];
|
|
3257
|
-
}
|
|
3258
|
-
return result;
|
|
3259
|
-
}
|
|
3260
|
-
|
|
3261
|
-
/**
|
|
3262
|
-
* A specialized version of `matchesProperty` for source values suitable
|
|
3263
|
-
* for strict equality comparisons, i.e. `===`.
|
|
3264
|
-
*
|
|
3265
|
-
* @private
|
|
3266
|
-
* @param {string} key The key of the property to get.
|
|
3267
|
-
* @param {*} srcValue The value to match.
|
|
3268
|
-
* @returns {Function} Returns the new spec function.
|
|
3269
|
-
*/
|
|
3270
|
-
function matchesStrictComparable(key, srcValue) {
|
|
3271
|
-
return function(object) {
|
|
3272
|
-
if (object == null) {
|
|
3273
|
-
return false;
|
|
3274
|
-
}
|
|
3275
|
-
return object[key] === srcValue &&
|
|
3276
|
-
(srcValue !== undefined || (key in Object(object)));
|
|
3277
|
-
};
|
|
3278
|
-
}
|
|
3279
|
-
|
|
3280
|
-
/**
|
|
3281
|
-
* The base implementation of `_.matches` which doesn't clone `source`.
|
|
3282
|
-
*
|
|
3283
|
-
* @private
|
|
3284
|
-
* @param {Object} source The object of property values to match.
|
|
3285
|
-
* @returns {Function} Returns the new spec function.
|
|
3286
|
-
*/
|
|
3287
|
-
function baseMatches(source) {
|
|
3288
|
-
var matchData = getMatchData(source);
|
|
3289
|
-
if (matchData.length == 1 && matchData[0][2]) {
|
|
3290
|
-
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
|
3291
|
-
}
|
|
3292
|
-
return function(object) {
|
|
3293
|
-
return object === source || baseIsMatch(object, source, matchData);
|
|
3294
|
-
};
|
|
3295
|
-
}
|
|
3296
|
-
|
|
3297
|
-
/**
|
|
3298
|
-
* The base implementation of `_.hasIn` without support for deep paths.
|
|
3299
|
-
*
|
|
3300
|
-
* @private
|
|
3301
|
-
* @param {Object} [object] The object to query.
|
|
3302
|
-
* @param {Array|string} key The key to check.
|
|
3303
|
-
* @returns {boolean} Returns `true` if `key` exists, else `false`.
|
|
3304
|
-
*/
|
|
3305
|
-
function baseHasIn(object, key) {
|
|
3306
|
-
return object != null && key in Object(object);
|
|
3307
|
-
}
|
|
3308
|
-
|
|
3309
|
-
/**
|
|
3310
|
-
* Checks if `path` exists on `object`.
|
|
3311
|
-
*
|
|
3312
|
-
* @private
|
|
3313
|
-
* @param {Object} object The object to query.
|
|
3314
|
-
* @param {Array|string} path The path to check.
|
|
3315
|
-
* @param {Function} hasFunc The function to check properties.
|
|
3316
|
-
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|
3317
|
-
*/
|
|
3318
|
-
function hasPath(object, path, hasFunc) {
|
|
3319
|
-
path = castPath(path, object);
|
|
3320
|
-
|
|
3321
|
-
var index = -1,
|
|
3322
|
-
length = path.length,
|
|
3323
|
-
result = false;
|
|
3324
|
-
|
|
3325
|
-
while (++index < length) {
|
|
3326
|
-
var key = toKey(path[index]);
|
|
3327
|
-
if (!(result = object != null && hasFunc(object, key))) {
|
|
3328
|
-
break;
|
|
3329
|
-
}
|
|
3330
|
-
object = object[key];
|
|
3331
|
-
}
|
|
3332
|
-
if (result || ++index != length) {
|
|
3333
|
-
return result;
|
|
3334
|
-
}
|
|
3335
|
-
length = object == null ? 0 : object.length;
|
|
3336
|
-
return !!length && isLength(length) && isIndex(key, length) &&
|
|
3337
|
-
(isArray(object) || isArguments(object));
|
|
3338
|
-
}
|
|
3339
|
-
|
|
3340
|
-
/**
|
|
3341
|
-
* Checks if `path` is a direct or inherited property of `object`.
|
|
3342
|
-
*
|
|
3343
|
-
* @static
|
|
3344
|
-
* @memberOf _
|
|
3345
|
-
* @since 4.0.0
|
|
3346
|
-
* @category Object
|
|
3347
|
-
* @param {Object} object The object to query.
|
|
3348
|
-
* @param {Array|string} path The path to check.
|
|
3349
|
-
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|
3350
|
-
* @example
|
|
3351
|
-
*
|
|
3352
|
-
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
|
3353
|
-
*
|
|
3354
|
-
* _.hasIn(object, 'a');
|
|
3355
|
-
* // => true
|
|
3356
|
-
*
|
|
3357
|
-
* _.hasIn(object, 'a.b');
|
|
3358
|
-
* // => true
|
|
3359
|
-
*
|
|
3360
|
-
* _.hasIn(object, ['a', 'b']);
|
|
3361
|
-
* // => true
|
|
3362
|
-
*
|
|
3363
|
-
* _.hasIn(object, 'b');
|
|
3364
|
-
* // => false
|
|
3365
|
-
*/
|
|
3366
|
-
function hasIn(object, path) {
|
|
3367
|
-
return object != null && hasPath(object, path, baseHasIn);
|
|
3368
|
-
}
|
|
3369
|
-
|
|
3370
|
-
/** Used to compose bitmasks for value comparisons. */
|
|
3371
|
-
var COMPARE_PARTIAL_FLAG = 1,
|
|
3372
|
-
COMPARE_UNORDERED_FLAG = 2;
|
|
3373
|
-
|
|
3374
|
-
/**
|
|
3375
|
-
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
|
3376
|
-
*
|
|
3377
|
-
* @private
|
|
3378
|
-
* @param {string} path The path of the property to get.
|
|
3379
|
-
* @param {*} srcValue The value to match.
|
|
3380
|
-
* @returns {Function} Returns the new spec function.
|
|
3381
|
-
*/
|
|
3382
|
-
function baseMatchesProperty(path, srcValue) {
|
|
3383
|
-
if (isKey(path) && isStrictComparable(srcValue)) {
|
|
3384
|
-
return matchesStrictComparable(toKey(path), srcValue);
|
|
3385
|
-
}
|
|
3386
|
-
return function(object) {
|
|
3387
|
-
var objValue = get(object, path);
|
|
3388
|
-
return (objValue === undefined && objValue === srcValue)
|
|
3389
|
-
? hasIn(object, path)
|
|
3390
|
-
: baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
|
3391
|
-
};
|
|
3392
|
-
}
|
|
3393
|
-
|
|
3394
|
-
/**
|
|
3395
|
-
* The base implementation of `_.property` without support for deep paths.
|
|
3396
|
-
*
|
|
3397
|
-
* @private
|
|
3398
|
-
* @param {string} key The key of the property to get.
|
|
3399
|
-
* @returns {Function} Returns the new accessor function.
|
|
3400
|
-
*/
|
|
3401
|
-
function baseProperty(key) {
|
|
3402
|
-
return function(object) {
|
|
3403
|
-
return object == null ? undefined : object[key];
|
|
3404
|
-
};
|
|
3405
|
-
}
|
|
3406
|
-
|
|
3407
|
-
/**
|
|
3408
|
-
* A specialized version of `baseProperty` which supports deep paths.
|
|
3409
|
-
*
|
|
3410
|
-
* @private
|
|
3411
|
-
* @param {Array|string} path The path of the property to get.
|
|
3412
|
-
* @returns {Function} Returns the new accessor function.
|
|
3413
|
-
*/
|
|
3414
|
-
function basePropertyDeep(path) {
|
|
3415
|
-
return function(object) {
|
|
3416
|
-
return baseGet(object, path);
|
|
3417
|
-
};
|
|
3418
|
-
}
|
|
3419
|
-
|
|
3420
|
-
/**
|
|
3421
|
-
* Creates a function that returns the value at `path` of a given object.
|
|
3422
|
-
*
|
|
3423
|
-
* @static
|
|
3424
|
-
* @memberOf _
|
|
3425
|
-
* @since 2.4.0
|
|
3426
|
-
* @category Util
|
|
3427
|
-
* @param {Array|string} path The path of the property to get.
|
|
3428
|
-
* @returns {Function} Returns the new accessor function.
|
|
3429
|
-
* @example
|
|
3430
|
-
*
|
|
3431
|
-
* var objects = [
|
|
3432
|
-
* { 'a': { 'b': 2 } },
|
|
3433
|
-
* { 'a': { 'b': 1 } }
|
|
3434
|
-
* ];
|
|
3435
|
-
*
|
|
3436
|
-
* _.map(objects, _.property('a.b'));
|
|
3437
|
-
* // => [2, 1]
|
|
3438
|
-
*
|
|
3439
|
-
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
|
|
3440
|
-
* // => [1, 2]
|
|
3441
|
-
*/
|
|
3442
|
-
function property(path) {
|
|
3443
|
-
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
|
|
3444
|
-
}
|
|
3445
|
-
|
|
3446
|
-
/**
|
|
3447
|
-
* The base implementation of `_.iteratee`.
|
|
3448
|
-
*
|
|
3449
|
-
* @private
|
|
3450
|
-
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
|
3451
|
-
* @returns {Function} Returns the iteratee.
|
|
3452
|
-
*/
|
|
3453
|
-
function baseIteratee(value) {
|
|
3454
|
-
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
|
3455
|
-
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
|
3456
|
-
if (typeof value == 'function') {
|
|
3457
|
-
return value;
|
|
3458
|
-
}
|
|
3459
|
-
if (value == null) {
|
|
3460
|
-
return identity;
|
|
3461
|
-
}
|
|
3462
|
-
if (typeof value == 'object') {
|
|
3463
|
-
return isArray(value)
|
|
3464
|
-
? baseMatchesProperty(value[0], value[1])
|
|
3465
|
-
: baseMatches(value);
|
|
3466
|
-
}
|
|
3467
|
-
return property(value);
|
|
3468
|
-
}
|
|
3469
|
-
|
|
3470
|
-
/**
|
|
3471
|
-
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
|
3472
|
-
*
|
|
3473
|
-
* @private
|
|
3474
|
-
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
3475
|
-
* @returns {Function} Returns the new base function.
|
|
3476
|
-
*/
|
|
3477
|
-
function createBaseFor(fromRight) {
|
|
3478
|
-
return function(object, iteratee, keysFunc) {
|
|
3479
|
-
var index = -1,
|
|
3480
|
-
iterable = Object(object),
|
|
3481
|
-
props = keysFunc(object),
|
|
3482
|
-
length = props.length;
|
|
3483
|
-
|
|
3484
|
-
while (length--) {
|
|
3485
|
-
var key = props[fromRight ? length : ++index];
|
|
3486
|
-
if (iteratee(iterable[key], key, iterable) === false) {
|
|
3487
|
-
break;
|
|
3488
|
-
}
|
|
3489
|
-
}
|
|
3490
|
-
return object;
|
|
3491
|
-
};
|
|
3492
|
-
}
|
|
3493
|
-
|
|
3494
|
-
/**
|
|
3495
|
-
* The base implementation of `baseForOwn` which iterates over `object`
|
|
3496
|
-
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
|
3497
|
-
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
3498
|
-
*
|
|
3499
|
-
* @private
|
|
3500
|
-
* @param {Object} object The object to iterate over.
|
|
3501
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
3502
|
-
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
3503
|
-
* @returns {Object} Returns `object`.
|
|
3504
|
-
*/
|
|
3505
|
-
var baseFor = createBaseFor();
|
|
3506
|
-
|
|
3507
|
-
/**
|
|
3508
|
-
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
|
3509
|
-
*
|
|
3510
|
-
* @private
|
|
3511
|
-
* @param {Object} object The object to iterate over.
|
|
3512
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
3513
|
-
* @returns {Object} Returns `object`.
|
|
3514
|
-
*/
|
|
3515
|
-
function baseForOwn(object, iteratee) {
|
|
3516
|
-
return object && baseFor(object, iteratee, keys);
|
|
3517
|
-
}
|
|
3518
|
-
|
|
3519
|
-
/**
|
|
3520
|
-
* Creates an object with the same keys as `object` and values generated
|
|
3521
|
-
* by running each own enumerable string keyed property of `object` thru
|
|
3522
|
-
* `iteratee`. The iteratee is invoked with three arguments:
|
|
3523
|
-
* (value, key, object).
|
|
3524
|
-
*
|
|
3525
|
-
* @static
|
|
3526
|
-
* @memberOf _
|
|
3527
|
-
* @since 2.4.0
|
|
3528
|
-
* @category Object
|
|
3529
|
-
* @param {Object} object The object to iterate over.
|
|
3530
|
-
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
3531
|
-
* @returns {Object} Returns the new mapped object.
|
|
3532
|
-
* @see _.mapKeys
|
|
3533
|
-
* @example
|
|
3534
|
-
*
|
|
3535
|
-
* var users = {
|
|
3536
|
-
* 'fred': { 'user': 'fred', 'age': 40 },
|
|
3537
|
-
* 'pebbles': { 'user': 'pebbles', 'age': 1 }
|
|
3538
|
-
* };
|
|
3539
|
-
*
|
|
3540
|
-
* _.mapValues(users, function(o) { return o.age; });
|
|
3541
|
-
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
|
3542
|
-
*
|
|
3543
|
-
* // The `_.property` iteratee shorthand.
|
|
3544
|
-
* _.mapValues(users, 'age');
|
|
3545
|
-
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
|
3546
|
-
*/
|
|
3547
|
-
function mapValues(object, iteratee) {
|
|
3548
|
-
var result = {};
|
|
3549
|
-
iteratee = baseIteratee(iteratee);
|
|
3550
|
-
|
|
3551
|
-
baseForOwn(object, function(value, key, object) {
|
|
3552
|
-
baseAssignValue(result, key, iteratee(value, key, object));
|
|
3553
|
-
});
|
|
3554
|
-
return result;
|
|
3555
|
-
}
|
|
3556
|
-
|
|
3557
|
-
function renameRules(rules, map) {
|
|
3558
|
-
return Object.fromEntries(
|
|
3559
|
-
Object.entries(rules).map(([key, value]) => {
|
|
3560
|
-
for (const [from, to] of Object.entries(map)) {
|
|
3561
|
-
if (key.startsWith(`${from}/`)) {
|
|
3562
|
-
return [to + key.slice(from.length), value];
|
|
3563
|
-
}
|
|
3564
|
-
}
|
|
3565
|
-
return [key, value];
|
|
3566
|
-
})
|
|
3567
|
-
);
|
|
3568
|
-
}
|
|
3569
|
-
|
|
3570
|
-
const react = () => {
|
|
3571
|
-
const plugins = pluginReact.configs.all.plugins;
|
|
3572
|
-
const config = [
|
|
3573
|
-
{
|
|
3574
|
-
files: [GLOB_JSX, GLOB_TSX],
|
|
3575
|
-
languageOptions: {
|
|
3576
|
-
parserOptions: {
|
|
3577
|
-
ecmaFeatures: {
|
|
3578
|
-
jsx: true
|
|
3579
|
-
}
|
|
3580
|
-
},
|
|
3581
|
-
sourceType: "module"
|
|
3582
|
-
},
|
|
3583
|
-
settings: {
|
|
3584
|
-
react: {
|
|
3585
|
-
// 'detect' will throw warn on monorepo
|
|
3586
|
-
version: "18.0"
|
|
3587
|
-
}
|
|
3588
|
-
},
|
|
3589
|
-
plugins: {
|
|
3590
|
-
react: plugins["@eslint-react"],
|
|
3591
|
-
"react-dom": plugins["@eslint-react/dom"],
|
|
3592
|
-
"react-hooks": pluginReactHooks,
|
|
3593
|
-
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
3594
|
-
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
3595
|
-
"react-refresh": pluginReactRefresh,
|
|
3596
|
-
"react-web-api": plugins["@eslint-react/web-api"]
|
|
3597
|
-
},
|
|
3598
|
-
rules: {
|
|
3599
|
-
...renameRules(plugins["@eslint-react"].configs["recommended-typescript"].rules, { "@eslint-react": "react" }),
|
|
3600
|
-
...renameRules(plugins["@eslint-react/dom"].configs.recommended.rules, { "@eslint-react": "react-dom" }),
|
|
3601
|
-
...renameRules(pluginReactHooks.configs.recommended.rules, { "@eslint-react": "react-hooks" }),
|
|
3602
|
-
...renameRules(plugins["@eslint-react/hooks-extra"].configs.recommended.rules, { "@eslint-react": "react-hooks-extra" }),
|
|
3603
|
-
...renameRules(plugins["@eslint-react/naming-convention"].configs.recommended.rules, { "@eslint-react": "react-naming-convention" }),
|
|
3604
|
-
...renameRules(plugins["@eslint-react/web-api"].configs.recommended.rules, { "@eslint-react": "react-web-api" }),
|
|
3605
|
-
"react/no-prop-types": "error",
|
|
3606
|
-
"react-dom/no-unknown-property": "off",
|
|
3607
|
-
"react/avoid-shorthand-boolean": ["error"],
|
|
3608
|
-
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
3609
|
-
"react-refresh/only-export-components": "warn"
|
|
3610
|
-
}
|
|
3611
|
-
},
|
|
3612
|
-
{
|
|
3613
|
-
files: ["src/components/**/*.{ts,tsx}"],
|
|
3614
|
-
rules: {
|
|
3615
|
-
"react-naming-convention/filename": ["warn", { rule: "PascalCase" }]
|
|
3616
|
-
}
|
|
3617
|
-
},
|
|
3618
|
-
{
|
|
3619
|
-
files: ["src/hooks/**/use*.{ts,tsx}"],
|
|
3620
|
-
rules: {
|
|
3621
|
-
"react-naming-convention/filename": ["warn", { rule: "kebab-case" }]
|
|
3622
|
-
}
|
|
3623
|
-
},
|
|
3624
|
-
{
|
|
3625
|
-
files: [
|
|
3626
|
-
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
|
3627
|
-
`**/*{-entry,entry.}*.${GLOB_SCRIPT_EXT}`,
|
|
3628
|
-
GLOB_TEST_SCRIPT,
|
|
3629
|
-
GLOB_TEST_DIRS,
|
|
3630
|
-
// With next.js pages will export getStaticProps funcs
|
|
3631
|
-
// There are some bad cases for not all files are route files
|
|
3632
|
-
// RECOMMEND: pages/routes should only contain page files
|
|
3633
|
-
GLOB_PAGES_DIRS
|
|
3634
|
-
],
|
|
3635
|
-
ignores: [
|
|
3636
|
-
GLOB_PAGES_COMPONENTS_DIRS
|
|
3637
|
-
],
|
|
3638
|
-
rules: {
|
|
3639
|
-
"react-refresh/only-export-components": "off"
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
];
|
|
3643
|
-
return config;
|
|
3644
|
-
};
|
|
3645
|
-
const ssrReact = () => {
|
|
3646
|
-
const config = [
|
|
3647
|
-
{
|
|
3648
|
-
files: [GLOB_JSX, GLOB_TSX],
|
|
3649
|
-
languageOptions: {
|
|
3650
|
-
parserOptions: {
|
|
3651
|
-
ecmaFeatures: {
|
|
3652
|
-
jsx: true
|
|
3653
|
-
}
|
|
3654
|
-
},
|
|
3655
|
-
sourceType: "module"
|
|
3656
|
-
},
|
|
3657
|
-
settings: {
|
|
3658
|
-
react: {
|
|
3659
|
-
// 'detect' will throw warn on monorepo
|
|
3660
|
-
version: "18.0"
|
|
3661
|
-
}
|
|
3662
|
-
},
|
|
3663
|
-
plugins: {
|
|
3664
|
-
"ssr-friendly": pluginSSRFriendly
|
|
3665
|
-
},
|
|
3666
|
-
rules: {
|
|
3667
|
-
...pluginSSRFriendly.configs.recommended.rules
|
|
3668
|
-
}
|
|
3669
|
-
},
|
|
3670
|
-
{
|
|
3671
|
-
files: [
|
|
3672
|
-
`**/*config*.${GLOB_SCRIPT_EXT}`,
|
|
3673
|
-
// Client entry files not need to be SSR friendly
|
|
3674
|
-
`**/*{client-entry,entry.client}*.${GLOB_SCRIPT_EXT}`,
|
|
3675
|
-
GLOB_TEST_SCRIPT,
|
|
3676
|
-
GLOB_TEST_DIRS
|
|
3677
|
-
],
|
|
3678
|
-
rules: {
|
|
3679
|
-
...mapValues(pluginSSRFriendly.configs.recommended.rules, () => "off")
|
|
3680
|
-
}
|
|
3681
|
-
}
|
|
3682
|
-
];
|
|
3683
|
-
return config;
|
|
3684
|
-
};
|
|
3685
|
-
|
|
3686
|
-
const regexp = () => {
|
|
3687
|
-
const config = [
|
|
3688
|
-
{
|
|
3689
|
-
...configs["flat/recommended"]
|
|
3690
|
-
}
|
|
3691
|
-
];
|
|
3692
|
-
return config;
|
|
3693
|
-
};
|
|
1001
|
+
const regexp = () => {
|
|
1002
|
+
const config = [
|
|
1003
|
+
{
|
|
1004
|
+
...configs["flat/recommended"]
|
|
1005
|
+
}
|
|
1006
|
+
];
|
|
1007
|
+
return config;
|
|
1008
|
+
};
|
|
3694
1009
|
|
|
3695
1010
|
const stylistic = () => {
|
|
3696
1011
|
const config = pluginStylistic.configs.customize({
|
|
@@ -3713,7 +1028,7 @@ const stylistic = () => {
|
|
|
3713
1028
|
rules: {
|
|
3714
1029
|
...off,
|
|
3715
1030
|
...config.rules,
|
|
3716
|
-
"@stylistic/quotes": ["error", "single"],
|
|
1031
|
+
"@stylistic/quotes": ["error", "single", { avoidEscape: true }],
|
|
3717
1032
|
"@stylistic/quote-props": ["error", "as-needed"],
|
|
3718
1033
|
"@stylistic/array-bracket-spacing": ["error", "never"],
|
|
3719
1034
|
// https://eslint.org/docs/latest/rules/brace-style#1tbs
|
|
@@ -3724,6 +1039,7 @@ const stylistic = () => {
|
|
|
3724
1039
|
"comma-dangle": "off",
|
|
3725
1040
|
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
|
3726
1041
|
"@stylistic/key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
1042
|
+
"@stylistic/multiline-ternary": ["error", "always-multiline"],
|
|
3727
1043
|
"@stylistic/indent": ["error", 2, {
|
|
3728
1044
|
SwitchCase: 1,
|
|
3729
1045
|
VariableDeclarator: 1,
|
|
@@ -3735,7 +1051,7 @@ const stylistic = () => {
|
|
|
3735
1051
|
ArrayExpression: 1,
|
|
3736
1052
|
ObjectExpression: 1,
|
|
3737
1053
|
ImportDeclaration: 1,
|
|
3738
|
-
flatTernaryExpressions:
|
|
1054
|
+
flatTernaryExpressions: true,
|
|
3739
1055
|
ignoreComments: false,
|
|
3740
1056
|
ignoredNodes: [
|
|
3741
1057
|
"TemplateLiteral *",
|
|
@@ -3865,11 +1181,12 @@ const typescript = () => {
|
|
|
3865
1181
|
"import/no-named-as-default-member": "off",
|
|
3866
1182
|
"import/no-named-as-default": "off",
|
|
3867
1183
|
// TS
|
|
1184
|
+
"no-var": "error",
|
|
3868
1185
|
"no-useless-constructor": "off",
|
|
3869
1186
|
"@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
3870
1187
|
"@typescript-eslint/consistent-type-imports": [
|
|
3871
1188
|
"error",
|
|
3872
|
-
{ prefer: "type-imports", disallowTypeAnnotations: false }
|
|
1189
|
+
{ prefer: "type-imports", disallowTypeAnnotations: false, fixStyle: "separate-type-imports" }
|
|
3873
1190
|
],
|
|
3874
1191
|
// Limit `interface` define object types, users could override with *.d.ts declare
|
|
3875
1192
|
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
@@ -3882,8 +1199,7 @@ const typescript = () => {
|
|
|
3882
1199
|
// When .ts files compiled to .mjs, will throw require is not found
|
|
3883
1200
|
// use createRequire instead
|
|
3884
1201
|
"@typescript-eslint/no-require-imports": "error",
|
|
3885
|
-
|
|
3886
|
-
"etc/no-t": "error",
|
|
1202
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
3887
1203
|
/**
|
|
3888
1204
|
* refs:
|
|
3889
1205
|
* 1. https://ncjamieson.com/dont-export-const-enums/
|
|
@@ -3891,20 +1207,29 @@ const typescript = () => {
|
|
|
3891
1207
|
*/
|
|
3892
1208
|
"no-restricted-syntax": [
|
|
3893
1209
|
"error",
|
|
1210
|
+
"DebuggerStatement",
|
|
1211
|
+
"LabeledStatement",
|
|
1212
|
+
"WithStatement",
|
|
3894
1213
|
{
|
|
3895
1214
|
selector: "TSEnumDeclaration",
|
|
3896
1215
|
message: "Don't declare enums"
|
|
3897
1216
|
}
|
|
3898
1217
|
],
|
|
1218
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
1219
|
+
// https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful,
|
|
1220
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
1221
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
1222
|
+
// https://www.npmjs.com/package/eslint-plugin-etc
|
|
1223
|
+
"etc/no-t": "error",
|
|
3899
1224
|
// required tsconfig.json
|
|
3900
|
-
// 'etc/no-misused-generics': 'error',
|
|
1225
|
+
// 'etc/no-misused-generics'f: 'error',
|
|
3901
1226
|
// Overrides JS
|
|
3902
1227
|
// original no-undef not compatiable with typescript
|
|
3903
1228
|
// refs: https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
3904
1229
|
"no-undef": "off",
|
|
3905
1230
|
"no-unused-vars": "off",
|
|
3906
1231
|
"no-redeclare": "off",
|
|
3907
|
-
"@typescript-eslint/no-redeclare": "error",
|
|
1232
|
+
"@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
|
|
3908
1233
|
"no-dupe-class-members": "off",
|
|
3909
1234
|
"@typescript-eslint/no-dupe-class-members": "error",
|
|
3910
1235
|
"no-use-before-define": "off",
|
|
@@ -3914,6 +1239,12 @@ const typescript = () => {
|
|
|
3914
1239
|
],
|
|
3915
1240
|
"no-loss-of-precision": "off",
|
|
3916
1241
|
"@typescript-eslint/no-loss-of-precision": "error",
|
|
1242
|
+
"no-unused-expressions": "off",
|
|
1243
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
1244
|
+
allowShortCircuit: true,
|
|
1245
|
+
allowTernary: true,
|
|
1246
|
+
allowTaggedTemplates: true
|
|
1247
|
+
}],
|
|
3917
1248
|
// off
|
|
3918
1249
|
"@typescript-eslint/camelcase": "off",
|
|
3919
1250
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
@@ -3930,7 +1261,11 @@ const typescript = () => {
|
|
|
3930
1261
|
"@typescript-eslint/no-var-requires": "off",
|
|
3931
1262
|
// https://www.npmjs.com/package/eslint-plugin-unused-imports
|
|
3932
1263
|
"@typescript-eslint/no-unused-vars": "off",
|
|
3933
|
-
"no-void": ["error", { allowAsStatement: true }]
|
|
1264
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
1265
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
1266
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
1267
|
+
"@typescript-eslint/no-useless-constructor": "off",
|
|
1268
|
+
"@typescript-eslint/triple-slash-reference": "off"
|
|
3934
1269
|
}
|
|
3935
1270
|
},
|
|
3936
1271
|
{
|