@tmagic/stage 1.5.5 → 1.5.6
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/dist/tmagic-stage.js +17 -18
- package/dist/tmagic-stage.umd.cjs +2552 -76
- package/package.json +3 -12
- package/src/ActionManager.ts +2 -3
- package/src/DragResizeHelper.ts +1 -1
- package/src/StageCore.ts +2 -2
- package/src/StageDragResize.ts +1 -1
- package/src/StageMask.ts +1 -1
- package/src/StageMultiDragResize.ts +1 -1
- package/src/StageRender.ts +2 -2
- package/src/TargetShadow.ts +1 -1
- package/src/types.ts +1 -1
- package/src/util.ts +1 -1
- package/types/index.d.ts +1 -2
|
@@ -1,8 +1,2484 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('events'), require('@tmagic/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'events', '@tmagic/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicStage = {}, global.EventEmitter, global.
|
|
5
|
-
})(this, (function (exports, EventEmitter,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('events'), require('@tmagic/core'), require('keycon'), require('moveable-helper'), require('moveable'), require('@scena/guides')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'events', '@tmagic/core', 'keycon', 'moveable-helper', 'moveable', '@scena/guides'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicStage = {}, global.EventEmitter, global.core, global.KeyController, global.MoveableHelper, global.Moveable, global.Guides));
|
|
5
|
+
})(this, (function (exports, EventEmitter, core, KeyController, MoveableHelper, Moveable, Guides) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/** Detect free variable `global` from Node.js. */
|
|
8
|
+
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
9
|
+
|
|
10
|
+
/** Detect free variable `self`. */
|
|
11
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
12
|
+
|
|
13
|
+
/** Used as a reference to the global object. */
|
|
14
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
15
|
+
|
|
16
|
+
/** Built-in value references. */
|
|
17
|
+
var Symbol$1 = root.Symbol;
|
|
18
|
+
|
|
19
|
+
/** Used for built-in method references. */
|
|
20
|
+
var objectProto$9 = Object.prototype;
|
|
21
|
+
|
|
22
|
+
/** Used to check objects for own properties. */
|
|
23
|
+
var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Used to resolve the
|
|
27
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
28
|
+
* of values.
|
|
29
|
+
*/
|
|
30
|
+
var nativeObjectToString$1 = objectProto$9.toString;
|
|
31
|
+
|
|
32
|
+
/** Built-in value references. */
|
|
33
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
37
|
+
*
|
|
38
|
+
* @private
|
|
39
|
+
* @param {*} value The value to query.
|
|
40
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
41
|
+
*/
|
|
42
|
+
function getRawTag(value) {
|
|
43
|
+
var isOwn = hasOwnProperty$7.call(value, symToStringTag$1),
|
|
44
|
+
tag = value[symToStringTag$1];
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
value[symToStringTag$1] = undefined;
|
|
48
|
+
var unmasked = true;
|
|
49
|
+
} catch (e) {}
|
|
50
|
+
|
|
51
|
+
var result = nativeObjectToString$1.call(value);
|
|
52
|
+
if (unmasked) {
|
|
53
|
+
if (isOwn) {
|
|
54
|
+
value[symToStringTag$1] = tag;
|
|
55
|
+
} else {
|
|
56
|
+
delete value[symToStringTag$1];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Used for built-in method references. */
|
|
63
|
+
var objectProto$8 = Object.prototype;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Used to resolve the
|
|
67
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
68
|
+
* of values.
|
|
69
|
+
*/
|
|
70
|
+
var nativeObjectToString = objectProto$8.toString;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
* @param {*} value The value to convert.
|
|
77
|
+
* @returns {string} Returns the converted string.
|
|
78
|
+
*/
|
|
79
|
+
function objectToString(value) {
|
|
80
|
+
return nativeObjectToString.call(value);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** `Object#toString` result references. */
|
|
84
|
+
var nullTag = '[object Null]',
|
|
85
|
+
undefinedTag = '[object Undefined]';
|
|
86
|
+
|
|
87
|
+
/** Built-in value references. */
|
|
88
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
92
|
+
*
|
|
93
|
+
* @private
|
|
94
|
+
* @param {*} value The value to query.
|
|
95
|
+
* @returns {string} Returns the `toStringTag`.
|
|
96
|
+
*/
|
|
97
|
+
function baseGetTag(value) {
|
|
98
|
+
if (value == null) {
|
|
99
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
100
|
+
}
|
|
101
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
102
|
+
? getRawTag(value)
|
|
103
|
+
: objectToString(value);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
108
|
+
* and has a `typeof` result of "object".
|
|
109
|
+
*
|
|
110
|
+
* @static
|
|
111
|
+
* @memberOf _
|
|
112
|
+
* @since 4.0.0
|
|
113
|
+
* @category Lang
|
|
114
|
+
* @param {*} value The value to check.
|
|
115
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
116
|
+
* @example
|
|
117
|
+
*
|
|
118
|
+
* _.isObjectLike({});
|
|
119
|
+
* // => true
|
|
120
|
+
*
|
|
121
|
+
* _.isObjectLike([1, 2, 3]);
|
|
122
|
+
* // => true
|
|
123
|
+
*
|
|
124
|
+
* _.isObjectLike(_.noop);
|
|
125
|
+
* // => false
|
|
126
|
+
*
|
|
127
|
+
* _.isObjectLike(null);
|
|
128
|
+
* // => false
|
|
129
|
+
*/
|
|
130
|
+
function isObjectLike(value) {
|
|
131
|
+
return value != null && typeof value == 'object';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** `Object#toString` result references. */
|
|
135
|
+
var symbolTag = '[object Symbol]';
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
139
|
+
*
|
|
140
|
+
* @static
|
|
141
|
+
* @memberOf _
|
|
142
|
+
* @since 4.0.0
|
|
143
|
+
* @category Lang
|
|
144
|
+
* @param {*} value The value to check.
|
|
145
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
146
|
+
* @example
|
|
147
|
+
*
|
|
148
|
+
* _.isSymbol(Symbol.iterator);
|
|
149
|
+
* // => true
|
|
150
|
+
*
|
|
151
|
+
* _.isSymbol('abc');
|
|
152
|
+
* // => false
|
|
153
|
+
*/
|
|
154
|
+
function isSymbol(value) {
|
|
155
|
+
return typeof value == 'symbol' ||
|
|
156
|
+
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Checks if `value` is classified as an `Array` object.
|
|
161
|
+
*
|
|
162
|
+
* @static
|
|
163
|
+
* @memberOf _
|
|
164
|
+
* @since 0.1.0
|
|
165
|
+
* @category Lang
|
|
166
|
+
* @param {*} value The value to check.
|
|
167
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
168
|
+
* @example
|
|
169
|
+
*
|
|
170
|
+
* _.isArray([1, 2, 3]);
|
|
171
|
+
* // => true
|
|
172
|
+
*
|
|
173
|
+
* _.isArray(document.body.children);
|
|
174
|
+
* // => false
|
|
175
|
+
*
|
|
176
|
+
* _.isArray('abc');
|
|
177
|
+
* // => false
|
|
178
|
+
*
|
|
179
|
+
* _.isArray(_.noop);
|
|
180
|
+
* // => false
|
|
181
|
+
*/
|
|
182
|
+
var isArray = Array.isArray;
|
|
183
|
+
|
|
184
|
+
/** Used to match a single whitespace character. */
|
|
185
|
+
var reWhitespace = /\s/;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
189
|
+
* character of `string`.
|
|
190
|
+
*
|
|
191
|
+
* @private
|
|
192
|
+
* @param {string} string The string to inspect.
|
|
193
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
194
|
+
*/
|
|
195
|
+
function trimmedEndIndex(string) {
|
|
196
|
+
var index = string.length;
|
|
197
|
+
|
|
198
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
199
|
+
return index;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Used to match leading whitespace. */
|
|
203
|
+
var reTrimStart = /^\s+/;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The base implementation of `_.trim`.
|
|
207
|
+
*
|
|
208
|
+
* @private
|
|
209
|
+
* @param {string} string The string to trim.
|
|
210
|
+
* @returns {string} Returns the trimmed string.
|
|
211
|
+
*/
|
|
212
|
+
function baseTrim(string) {
|
|
213
|
+
return string
|
|
214
|
+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
215
|
+
: string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Checks if `value` is the
|
|
220
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
221
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
222
|
+
*
|
|
223
|
+
* @static
|
|
224
|
+
* @memberOf _
|
|
225
|
+
* @since 0.1.0
|
|
226
|
+
* @category Lang
|
|
227
|
+
* @param {*} value The value to check.
|
|
228
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
229
|
+
* @example
|
|
230
|
+
*
|
|
231
|
+
* _.isObject({});
|
|
232
|
+
* // => true
|
|
233
|
+
*
|
|
234
|
+
* _.isObject([1, 2, 3]);
|
|
235
|
+
* // => true
|
|
236
|
+
*
|
|
237
|
+
* _.isObject(_.noop);
|
|
238
|
+
* // => true
|
|
239
|
+
*
|
|
240
|
+
* _.isObject(null);
|
|
241
|
+
* // => false
|
|
242
|
+
*/
|
|
243
|
+
function isObject(value) {
|
|
244
|
+
var type = typeof value;
|
|
245
|
+
return value != null && (type == 'object' || type == 'function');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Used as references for various `Number` constants. */
|
|
249
|
+
var NAN = 0 / 0;
|
|
250
|
+
|
|
251
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
252
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
253
|
+
|
|
254
|
+
/** Used to detect binary string values. */
|
|
255
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
256
|
+
|
|
257
|
+
/** Used to detect octal string values. */
|
|
258
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
259
|
+
|
|
260
|
+
/** Built-in method references without a dependency on `root`. */
|
|
261
|
+
var freeParseInt = parseInt;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Converts `value` to a number.
|
|
265
|
+
*
|
|
266
|
+
* @static
|
|
267
|
+
* @memberOf _
|
|
268
|
+
* @since 4.0.0
|
|
269
|
+
* @category Lang
|
|
270
|
+
* @param {*} value The value to process.
|
|
271
|
+
* @returns {number} Returns the number.
|
|
272
|
+
* @example
|
|
273
|
+
*
|
|
274
|
+
* _.toNumber(3.2);
|
|
275
|
+
* // => 3.2
|
|
276
|
+
*
|
|
277
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
278
|
+
* // => 5e-324
|
|
279
|
+
*
|
|
280
|
+
* _.toNumber(Infinity);
|
|
281
|
+
* // => Infinity
|
|
282
|
+
*
|
|
283
|
+
* _.toNumber('3.2');
|
|
284
|
+
* // => 3.2
|
|
285
|
+
*/
|
|
286
|
+
function toNumber(value) {
|
|
287
|
+
if (typeof value == 'number') {
|
|
288
|
+
return value;
|
|
289
|
+
}
|
|
290
|
+
if (isSymbol(value)) {
|
|
291
|
+
return NAN;
|
|
292
|
+
}
|
|
293
|
+
if (isObject(value)) {
|
|
294
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
295
|
+
value = isObject(other) ? (other + '') : other;
|
|
296
|
+
}
|
|
297
|
+
if (typeof value != 'string') {
|
|
298
|
+
return value === 0 ? value : +value;
|
|
299
|
+
}
|
|
300
|
+
value = baseTrim(value);
|
|
301
|
+
var isBinary = reIsBinary.test(value);
|
|
302
|
+
return (isBinary || reIsOctal.test(value))
|
|
303
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
304
|
+
: (reIsBadHex.test(value) ? NAN : +value);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* This method returns the first argument it receives.
|
|
309
|
+
*
|
|
310
|
+
* @static
|
|
311
|
+
* @since 0.1.0
|
|
312
|
+
* @memberOf _
|
|
313
|
+
* @category Util
|
|
314
|
+
* @param {*} value Any value.
|
|
315
|
+
* @returns {*} Returns `value`.
|
|
316
|
+
* @example
|
|
317
|
+
*
|
|
318
|
+
* var object = { 'a': 1 };
|
|
319
|
+
*
|
|
320
|
+
* console.log(_.identity(object) === object);
|
|
321
|
+
* // => true
|
|
322
|
+
*/
|
|
323
|
+
function identity(value) {
|
|
324
|
+
return value;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** `Object#toString` result references. */
|
|
328
|
+
var asyncTag = '[object AsyncFunction]',
|
|
329
|
+
funcTag$1 = '[object Function]',
|
|
330
|
+
genTag = '[object GeneratorFunction]',
|
|
331
|
+
proxyTag = '[object Proxy]';
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Checks if `value` is classified as a `Function` object.
|
|
335
|
+
*
|
|
336
|
+
* @static
|
|
337
|
+
* @memberOf _
|
|
338
|
+
* @since 0.1.0
|
|
339
|
+
* @category Lang
|
|
340
|
+
* @param {*} value The value to check.
|
|
341
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
342
|
+
* @example
|
|
343
|
+
*
|
|
344
|
+
* _.isFunction(_);
|
|
345
|
+
* // => true
|
|
346
|
+
*
|
|
347
|
+
* _.isFunction(/abc/);
|
|
348
|
+
* // => false
|
|
349
|
+
*/
|
|
350
|
+
function isFunction(value) {
|
|
351
|
+
if (!isObject(value)) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
355
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
356
|
+
var tag = baseGetTag(value);
|
|
357
|
+
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Used to detect overreaching core-js shims. */
|
|
361
|
+
var coreJsData = root['__core-js_shared__'];
|
|
362
|
+
|
|
363
|
+
/** Used to detect methods masquerading as native. */
|
|
364
|
+
var maskSrcKey = (function() {
|
|
365
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
366
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
367
|
+
}());
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Checks if `func` has its source masked.
|
|
371
|
+
*
|
|
372
|
+
* @private
|
|
373
|
+
* @param {Function} func The function to check.
|
|
374
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
375
|
+
*/
|
|
376
|
+
function isMasked(func) {
|
|
377
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** Used for built-in method references. */
|
|
381
|
+
var funcProto$2 = Function.prototype;
|
|
382
|
+
|
|
383
|
+
/** Used to resolve the decompiled source of functions. */
|
|
384
|
+
var funcToString$2 = funcProto$2.toString;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Converts `func` to its source code.
|
|
388
|
+
*
|
|
389
|
+
* @private
|
|
390
|
+
* @param {Function} func The function to convert.
|
|
391
|
+
* @returns {string} Returns the source code.
|
|
392
|
+
*/
|
|
393
|
+
function toSource(func) {
|
|
394
|
+
if (func != null) {
|
|
395
|
+
try {
|
|
396
|
+
return funcToString$2.call(func);
|
|
397
|
+
} catch (e) {}
|
|
398
|
+
try {
|
|
399
|
+
return (func + '');
|
|
400
|
+
} catch (e) {}
|
|
401
|
+
}
|
|
402
|
+
return '';
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Used to match `RegExp`
|
|
407
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
408
|
+
*/
|
|
409
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
410
|
+
|
|
411
|
+
/** Used to detect host constructors (Safari). */
|
|
412
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
413
|
+
|
|
414
|
+
/** Used for built-in method references. */
|
|
415
|
+
var funcProto$1 = Function.prototype,
|
|
416
|
+
objectProto$7 = Object.prototype;
|
|
417
|
+
|
|
418
|
+
/** Used to resolve the decompiled source of functions. */
|
|
419
|
+
var funcToString$1 = funcProto$1.toString;
|
|
420
|
+
|
|
421
|
+
/** Used to check objects for own properties. */
|
|
422
|
+
var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
|
|
423
|
+
|
|
424
|
+
/** Used to detect if a method is native. */
|
|
425
|
+
var reIsNative = RegExp('^' +
|
|
426
|
+
funcToString$1.call(hasOwnProperty$6).replace(reRegExpChar, '\\$&')
|
|
427
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
432
|
+
*
|
|
433
|
+
* @private
|
|
434
|
+
* @param {*} value The value to check.
|
|
435
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
436
|
+
* else `false`.
|
|
437
|
+
*/
|
|
438
|
+
function baseIsNative(value) {
|
|
439
|
+
if (!isObject(value) || isMasked(value)) {
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
443
|
+
return pattern.test(toSource(value));
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Gets the value at `key` of `object`.
|
|
448
|
+
*
|
|
449
|
+
* @private
|
|
450
|
+
* @param {Object} [object] The object to query.
|
|
451
|
+
* @param {string} key The key of the property to get.
|
|
452
|
+
* @returns {*} Returns the property value.
|
|
453
|
+
*/
|
|
454
|
+
function getValue(object, key) {
|
|
455
|
+
return object == null ? undefined : object[key];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Gets the native function at `key` of `object`.
|
|
460
|
+
*
|
|
461
|
+
* @private
|
|
462
|
+
* @param {Object} object The object to query.
|
|
463
|
+
* @param {string} key The key of the method to get.
|
|
464
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
465
|
+
*/
|
|
466
|
+
function getNative(object, key) {
|
|
467
|
+
var value = getValue(object, key);
|
|
468
|
+
return baseIsNative(value) ? value : undefined;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** Built-in value references. */
|
|
472
|
+
var objectCreate = Object.create;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* The base implementation of `_.create` without support for assigning
|
|
476
|
+
* properties to the created object.
|
|
477
|
+
*
|
|
478
|
+
* @private
|
|
479
|
+
* @param {Object} proto The object to inherit from.
|
|
480
|
+
* @returns {Object} Returns the new object.
|
|
481
|
+
*/
|
|
482
|
+
var baseCreate = (function() {
|
|
483
|
+
function object() {}
|
|
484
|
+
return function(proto) {
|
|
485
|
+
if (!isObject(proto)) {
|
|
486
|
+
return {};
|
|
487
|
+
}
|
|
488
|
+
if (objectCreate) {
|
|
489
|
+
return objectCreate(proto);
|
|
490
|
+
}
|
|
491
|
+
object.prototype = proto;
|
|
492
|
+
var result = new object;
|
|
493
|
+
object.prototype = undefined;
|
|
494
|
+
return result;
|
|
495
|
+
};
|
|
496
|
+
}());
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* A faster alternative to `Function#apply`, this function invokes `func`
|
|
500
|
+
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|
501
|
+
*
|
|
502
|
+
* @private
|
|
503
|
+
* @param {Function} func The function to invoke.
|
|
504
|
+
* @param {*} thisArg The `this` binding of `func`.
|
|
505
|
+
* @param {Array} args The arguments to invoke `func` with.
|
|
506
|
+
* @returns {*} Returns the result of `func`.
|
|
507
|
+
*/
|
|
508
|
+
function apply(func, thisArg, args) {
|
|
509
|
+
switch (args.length) {
|
|
510
|
+
case 0: return func.call(thisArg);
|
|
511
|
+
case 1: return func.call(thisArg, args[0]);
|
|
512
|
+
case 2: return func.call(thisArg, args[0], args[1]);
|
|
513
|
+
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|
514
|
+
}
|
|
515
|
+
return func.apply(thisArg, args);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Copies the values of `source` to `array`.
|
|
520
|
+
*
|
|
521
|
+
* @private
|
|
522
|
+
* @param {Array} source The array to copy values from.
|
|
523
|
+
* @param {Array} [array=[]] The array to copy values to.
|
|
524
|
+
* @returns {Array} Returns `array`.
|
|
525
|
+
*/
|
|
526
|
+
function copyArray(source, array) {
|
|
527
|
+
var index = -1,
|
|
528
|
+
length = source.length;
|
|
529
|
+
|
|
530
|
+
array || (array = Array(length));
|
|
531
|
+
while (++index < length) {
|
|
532
|
+
array[index] = source[index];
|
|
533
|
+
}
|
|
534
|
+
return array;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
|
538
|
+
var HOT_COUNT = 800,
|
|
539
|
+
HOT_SPAN = 16;
|
|
540
|
+
|
|
541
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
542
|
+
var nativeNow = Date.now;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Creates a function that'll short out and invoke `identity` instead
|
|
546
|
+
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
|
547
|
+
* milliseconds.
|
|
548
|
+
*
|
|
549
|
+
* @private
|
|
550
|
+
* @param {Function} func The function to restrict.
|
|
551
|
+
* @returns {Function} Returns the new shortable function.
|
|
552
|
+
*/
|
|
553
|
+
function shortOut(func) {
|
|
554
|
+
var count = 0,
|
|
555
|
+
lastCalled = 0;
|
|
556
|
+
|
|
557
|
+
return function() {
|
|
558
|
+
var stamp = nativeNow(),
|
|
559
|
+
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
560
|
+
|
|
561
|
+
lastCalled = stamp;
|
|
562
|
+
if (remaining > 0) {
|
|
563
|
+
if (++count >= HOT_COUNT) {
|
|
564
|
+
return arguments[0];
|
|
565
|
+
}
|
|
566
|
+
} else {
|
|
567
|
+
count = 0;
|
|
568
|
+
}
|
|
569
|
+
return func.apply(undefined, arguments);
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Creates a function that returns `value`.
|
|
575
|
+
*
|
|
576
|
+
* @static
|
|
577
|
+
* @memberOf _
|
|
578
|
+
* @since 2.4.0
|
|
579
|
+
* @category Util
|
|
580
|
+
* @param {*} value The value to return from the new function.
|
|
581
|
+
* @returns {Function} Returns the new constant function.
|
|
582
|
+
* @example
|
|
583
|
+
*
|
|
584
|
+
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
|
585
|
+
*
|
|
586
|
+
* console.log(objects);
|
|
587
|
+
* // => [{ 'a': 1 }, { 'a': 1 }]
|
|
588
|
+
*
|
|
589
|
+
* console.log(objects[0] === objects[1]);
|
|
590
|
+
* // => true
|
|
591
|
+
*/
|
|
592
|
+
function constant(value) {
|
|
593
|
+
return function() {
|
|
594
|
+
return value;
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
var defineProperty = (function() {
|
|
599
|
+
try {
|
|
600
|
+
var func = getNative(Object, 'defineProperty');
|
|
601
|
+
func({}, '', {});
|
|
602
|
+
return func;
|
|
603
|
+
} catch (e) {}
|
|
604
|
+
}());
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* The base implementation of `setToString` without support for hot loop shorting.
|
|
608
|
+
*
|
|
609
|
+
* @private
|
|
610
|
+
* @param {Function} func The function to modify.
|
|
611
|
+
* @param {Function} string The `toString` result.
|
|
612
|
+
* @returns {Function} Returns `func`.
|
|
613
|
+
*/
|
|
614
|
+
var baseSetToString = !defineProperty ? identity : function(func, string) {
|
|
615
|
+
return defineProperty(func, 'toString', {
|
|
616
|
+
'configurable': true,
|
|
617
|
+
'enumerable': false,
|
|
618
|
+
'value': constant(string),
|
|
619
|
+
'writable': true
|
|
620
|
+
});
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Sets the `toString` method of `func` to return `string`.
|
|
625
|
+
*
|
|
626
|
+
* @private
|
|
627
|
+
* @param {Function} func The function to modify.
|
|
628
|
+
* @param {Function} string The `toString` result.
|
|
629
|
+
* @returns {Function} Returns `func`.
|
|
630
|
+
*/
|
|
631
|
+
var setToString = shortOut(baseSetToString);
|
|
632
|
+
|
|
633
|
+
/** Used as references for various `Number` constants. */
|
|
634
|
+
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
635
|
+
|
|
636
|
+
/** Used to detect unsigned integer values. */
|
|
637
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Checks if `value` is a valid array-like index.
|
|
641
|
+
*
|
|
642
|
+
* @private
|
|
643
|
+
* @param {*} value The value to check.
|
|
644
|
+
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
645
|
+
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
646
|
+
*/
|
|
647
|
+
function isIndex(value, length) {
|
|
648
|
+
var type = typeof value;
|
|
649
|
+
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
650
|
+
|
|
651
|
+
return !!length &&
|
|
652
|
+
(type == 'number' ||
|
|
653
|
+
(type != 'symbol' && reIsUint.test(value))) &&
|
|
654
|
+
(value > -1 && value % 1 == 0 && value < length);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* The base implementation of `assignValue` and `assignMergeValue` without
|
|
659
|
+
* value checks.
|
|
660
|
+
*
|
|
661
|
+
* @private
|
|
662
|
+
* @param {Object} object The object to modify.
|
|
663
|
+
* @param {string} key The key of the property to assign.
|
|
664
|
+
* @param {*} value The value to assign.
|
|
665
|
+
*/
|
|
666
|
+
function baseAssignValue(object, key, value) {
|
|
667
|
+
if (key == '__proto__' && defineProperty) {
|
|
668
|
+
defineProperty(object, key, {
|
|
669
|
+
'configurable': true,
|
|
670
|
+
'enumerable': true,
|
|
671
|
+
'value': value,
|
|
672
|
+
'writable': true
|
|
673
|
+
});
|
|
674
|
+
} else {
|
|
675
|
+
object[key] = value;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Performs a
|
|
681
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
682
|
+
* comparison between two values to determine if they are equivalent.
|
|
683
|
+
*
|
|
684
|
+
* @static
|
|
685
|
+
* @memberOf _
|
|
686
|
+
* @since 4.0.0
|
|
687
|
+
* @category Lang
|
|
688
|
+
* @param {*} value The value to compare.
|
|
689
|
+
* @param {*} other The other value to compare.
|
|
690
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
691
|
+
* @example
|
|
692
|
+
*
|
|
693
|
+
* var object = { 'a': 1 };
|
|
694
|
+
* var other = { 'a': 1 };
|
|
695
|
+
*
|
|
696
|
+
* _.eq(object, object);
|
|
697
|
+
* // => true
|
|
698
|
+
*
|
|
699
|
+
* _.eq(object, other);
|
|
700
|
+
* // => false
|
|
701
|
+
*
|
|
702
|
+
* _.eq('a', 'a');
|
|
703
|
+
* // => true
|
|
704
|
+
*
|
|
705
|
+
* _.eq('a', Object('a'));
|
|
706
|
+
* // => false
|
|
707
|
+
*
|
|
708
|
+
* _.eq(NaN, NaN);
|
|
709
|
+
* // => true
|
|
710
|
+
*/
|
|
711
|
+
function eq(value, other) {
|
|
712
|
+
return value === other || (value !== value && other !== other);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/** Used for built-in method references. */
|
|
716
|
+
var objectProto$6 = Object.prototype;
|
|
717
|
+
|
|
718
|
+
/** Used to check objects for own properties. */
|
|
719
|
+
var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Assigns `value` to `key` of `object` if the existing value is not equivalent
|
|
723
|
+
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
724
|
+
* for equality comparisons.
|
|
725
|
+
*
|
|
726
|
+
* @private
|
|
727
|
+
* @param {Object} object The object to modify.
|
|
728
|
+
* @param {string} key The key of the property to assign.
|
|
729
|
+
* @param {*} value The value to assign.
|
|
730
|
+
*/
|
|
731
|
+
function assignValue(object, key, value) {
|
|
732
|
+
var objValue = object[key];
|
|
733
|
+
if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) ||
|
|
734
|
+
(value === undefined && !(key in object))) {
|
|
735
|
+
baseAssignValue(object, key, value);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Copies properties of `source` to `object`.
|
|
741
|
+
*
|
|
742
|
+
* @private
|
|
743
|
+
* @param {Object} source The object to copy properties from.
|
|
744
|
+
* @param {Array} props The property identifiers to copy.
|
|
745
|
+
* @param {Object} [object={}] The object to copy properties to.
|
|
746
|
+
* @param {Function} [customizer] The function to customize copied values.
|
|
747
|
+
* @returns {Object} Returns `object`.
|
|
748
|
+
*/
|
|
749
|
+
function copyObject(source, props, object, customizer) {
|
|
750
|
+
var isNew = !object;
|
|
751
|
+
object || (object = {});
|
|
752
|
+
|
|
753
|
+
var index = -1,
|
|
754
|
+
length = props.length;
|
|
755
|
+
|
|
756
|
+
while (++index < length) {
|
|
757
|
+
var key = props[index];
|
|
758
|
+
|
|
759
|
+
var newValue = undefined;
|
|
760
|
+
|
|
761
|
+
if (newValue === undefined) {
|
|
762
|
+
newValue = source[key];
|
|
763
|
+
}
|
|
764
|
+
if (isNew) {
|
|
765
|
+
baseAssignValue(object, key, newValue);
|
|
766
|
+
} else {
|
|
767
|
+
assignValue(object, key, newValue);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return object;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
774
|
+
var nativeMax$1 = Math.max;
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* A specialized version of `baseRest` which transforms the rest array.
|
|
778
|
+
*
|
|
779
|
+
* @private
|
|
780
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
781
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
782
|
+
* @param {Function} transform The rest array transform.
|
|
783
|
+
* @returns {Function} Returns the new function.
|
|
784
|
+
*/
|
|
785
|
+
function overRest(func, start, transform) {
|
|
786
|
+
start = nativeMax$1(start === undefined ? (func.length - 1) : start, 0);
|
|
787
|
+
return function() {
|
|
788
|
+
var args = arguments,
|
|
789
|
+
index = -1,
|
|
790
|
+
length = nativeMax$1(args.length - start, 0),
|
|
791
|
+
array = Array(length);
|
|
792
|
+
|
|
793
|
+
while (++index < length) {
|
|
794
|
+
array[index] = args[start + index];
|
|
795
|
+
}
|
|
796
|
+
index = -1;
|
|
797
|
+
var otherArgs = Array(start + 1);
|
|
798
|
+
while (++index < start) {
|
|
799
|
+
otherArgs[index] = args[index];
|
|
800
|
+
}
|
|
801
|
+
otherArgs[start] = transform(array);
|
|
802
|
+
return apply(func, this, otherArgs);
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|
808
|
+
*
|
|
809
|
+
* @private
|
|
810
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
811
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
812
|
+
* @returns {Function} Returns the new function.
|
|
813
|
+
*/
|
|
814
|
+
function baseRest(func, start) {
|
|
815
|
+
return setToString(overRest(func, start, identity), func + '');
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/** Used as references for various `Number` constants. */
|
|
819
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Checks if `value` is a valid array-like length.
|
|
823
|
+
*
|
|
824
|
+
* **Note:** This method is loosely based on
|
|
825
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
826
|
+
*
|
|
827
|
+
* @static
|
|
828
|
+
* @memberOf _
|
|
829
|
+
* @since 4.0.0
|
|
830
|
+
* @category Lang
|
|
831
|
+
* @param {*} value The value to check.
|
|
832
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
833
|
+
* @example
|
|
834
|
+
*
|
|
835
|
+
* _.isLength(3);
|
|
836
|
+
* // => true
|
|
837
|
+
*
|
|
838
|
+
* _.isLength(Number.MIN_VALUE);
|
|
839
|
+
* // => false
|
|
840
|
+
*
|
|
841
|
+
* _.isLength(Infinity);
|
|
842
|
+
* // => false
|
|
843
|
+
*
|
|
844
|
+
* _.isLength('3');
|
|
845
|
+
* // => false
|
|
846
|
+
*/
|
|
847
|
+
function isLength(value) {
|
|
848
|
+
return typeof value == 'number' &&
|
|
849
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
854
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
855
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
856
|
+
*
|
|
857
|
+
* @static
|
|
858
|
+
* @memberOf _
|
|
859
|
+
* @since 4.0.0
|
|
860
|
+
* @category Lang
|
|
861
|
+
* @param {*} value The value to check.
|
|
862
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
863
|
+
* @example
|
|
864
|
+
*
|
|
865
|
+
* _.isArrayLike([1, 2, 3]);
|
|
866
|
+
* // => true
|
|
867
|
+
*
|
|
868
|
+
* _.isArrayLike(document.body.children);
|
|
869
|
+
* // => true
|
|
870
|
+
*
|
|
871
|
+
* _.isArrayLike('abc');
|
|
872
|
+
* // => true
|
|
873
|
+
*
|
|
874
|
+
* _.isArrayLike(_.noop);
|
|
875
|
+
* // => false
|
|
876
|
+
*/
|
|
877
|
+
function isArrayLike(value) {
|
|
878
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Checks if the given arguments are from an iteratee call.
|
|
883
|
+
*
|
|
884
|
+
* @private
|
|
885
|
+
* @param {*} value The potential iteratee value argument.
|
|
886
|
+
* @param {*} index The potential iteratee index or key argument.
|
|
887
|
+
* @param {*} object The potential iteratee object argument.
|
|
888
|
+
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
|
889
|
+
* else `false`.
|
|
890
|
+
*/
|
|
891
|
+
function isIterateeCall(value, index, object) {
|
|
892
|
+
if (!isObject(object)) {
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
var type = typeof index;
|
|
896
|
+
if (type == 'number'
|
|
897
|
+
? (isArrayLike(object) && isIndex(index, object.length))
|
|
898
|
+
: (type == 'string' && index in object)
|
|
899
|
+
) {
|
|
900
|
+
return eq(object[index], value);
|
|
901
|
+
}
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Creates a function like `_.assign`.
|
|
907
|
+
*
|
|
908
|
+
* @private
|
|
909
|
+
* @param {Function} assigner The function to assign values.
|
|
910
|
+
* @returns {Function} Returns the new assigner function.
|
|
911
|
+
*/
|
|
912
|
+
function createAssigner(assigner) {
|
|
913
|
+
return baseRest(function(object, sources) {
|
|
914
|
+
var index = -1,
|
|
915
|
+
length = sources.length,
|
|
916
|
+
customizer = length > 1 ? sources[length - 1] : undefined,
|
|
917
|
+
guard = length > 2 ? sources[2] : undefined;
|
|
918
|
+
|
|
919
|
+
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
|
920
|
+
? (length--, customizer)
|
|
921
|
+
: undefined;
|
|
922
|
+
|
|
923
|
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
924
|
+
customizer = length < 3 ? undefined : customizer;
|
|
925
|
+
length = 1;
|
|
926
|
+
}
|
|
927
|
+
object = Object(object);
|
|
928
|
+
while (++index < length) {
|
|
929
|
+
var source = sources[index];
|
|
930
|
+
if (source) {
|
|
931
|
+
assigner(object, source, index, customizer);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return object;
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/** Used for built-in method references. */
|
|
939
|
+
var objectProto$5 = Object.prototype;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Checks if `value` is likely a prototype object.
|
|
943
|
+
*
|
|
944
|
+
* @private
|
|
945
|
+
* @param {*} value The value to check.
|
|
946
|
+
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
947
|
+
*/
|
|
948
|
+
function isPrototype(value) {
|
|
949
|
+
var Ctor = value && value.constructor,
|
|
950
|
+
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
|
|
951
|
+
|
|
952
|
+
return value === proto;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* The base implementation of `_.times` without support for iteratee shorthands
|
|
957
|
+
* or max array length checks.
|
|
958
|
+
*
|
|
959
|
+
* @private
|
|
960
|
+
* @param {number} n The number of times to invoke `iteratee`.
|
|
961
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
962
|
+
* @returns {Array} Returns the array of results.
|
|
963
|
+
*/
|
|
964
|
+
function baseTimes(n, iteratee) {
|
|
965
|
+
var index = -1,
|
|
966
|
+
result = Array(n);
|
|
967
|
+
|
|
968
|
+
while (++index < n) {
|
|
969
|
+
result[index] = iteratee(index);
|
|
970
|
+
}
|
|
971
|
+
return result;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/** `Object#toString` result references. */
|
|
975
|
+
var argsTag$1 = '[object Arguments]';
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* The base implementation of `_.isArguments`.
|
|
979
|
+
*
|
|
980
|
+
* @private
|
|
981
|
+
* @param {*} value The value to check.
|
|
982
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
983
|
+
*/
|
|
984
|
+
function baseIsArguments(value) {
|
|
985
|
+
return isObjectLike(value) && baseGetTag(value) == argsTag$1;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/** Used for built-in method references. */
|
|
989
|
+
var objectProto$4 = Object.prototype;
|
|
990
|
+
|
|
991
|
+
/** Used to check objects for own properties. */
|
|
992
|
+
var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
|
|
993
|
+
|
|
994
|
+
/** Built-in value references. */
|
|
995
|
+
var propertyIsEnumerable = objectProto$4.propertyIsEnumerable;
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* Checks if `value` is likely an `arguments` object.
|
|
999
|
+
*
|
|
1000
|
+
* @static
|
|
1001
|
+
* @memberOf _
|
|
1002
|
+
* @since 0.1.0
|
|
1003
|
+
* @category Lang
|
|
1004
|
+
* @param {*} value The value to check.
|
|
1005
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1006
|
+
* else `false`.
|
|
1007
|
+
* @example
|
|
1008
|
+
*
|
|
1009
|
+
* _.isArguments(function() { return arguments; }());
|
|
1010
|
+
* // => true
|
|
1011
|
+
*
|
|
1012
|
+
* _.isArguments([1, 2, 3]);
|
|
1013
|
+
* // => false
|
|
1014
|
+
*/
|
|
1015
|
+
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
1016
|
+
return isObjectLike(value) && hasOwnProperty$4.call(value, 'callee') &&
|
|
1017
|
+
!propertyIsEnumerable.call(value, 'callee');
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* This method returns `false`.
|
|
1022
|
+
*
|
|
1023
|
+
* @static
|
|
1024
|
+
* @memberOf _
|
|
1025
|
+
* @since 4.13.0
|
|
1026
|
+
* @category Util
|
|
1027
|
+
* @returns {boolean} Returns `false`.
|
|
1028
|
+
* @example
|
|
1029
|
+
*
|
|
1030
|
+
* _.times(2, _.stubFalse);
|
|
1031
|
+
* // => [false, false]
|
|
1032
|
+
*/
|
|
1033
|
+
function stubFalse() {
|
|
1034
|
+
return false;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/** Detect free variable `exports`. */
|
|
1038
|
+
var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1039
|
+
|
|
1040
|
+
/** Detect free variable `module`. */
|
|
1041
|
+
var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
|
|
1042
|
+
|
|
1043
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1044
|
+
var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
|
|
1045
|
+
|
|
1046
|
+
/** Built-in value references. */
|
|
1047
|
+
var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
|
|
1048
|
+
|
|
1049
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1050
|
+
var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Checks if `value` is a buffer.
|
|
1054
|
+
*
|
|
1055
|
+
* @static
|
|
1056
|
+
* @memberOf _
|
|
1057
|
+
* @since 4.3.0
|
|
1058
|
+
* @category Lang
|
|
1059
|
+
* @param {*} value The value to check.
|
|
1060
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
1061
|
+
* @example
|
|
1062
|
+
*
|
|
1063
|
+
* _.isBuffer(new Buffer(2));
|
|
1064
|
+
* // => true
|
|
1065
|
+
*
|
|
1066
|
+
* _.isBuffer(new Uint8Array(2));
|
|
1067
|
+
* // => false
|
|
1068
|
+
*/
|
|
1069
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
1070
|
+
|
|
1071
|
+
/** `Object#toString` result references. */
|
|
1072
|
+
var argsTag = '[object Arguments]',
|
|
1073
|
+
arrayTag = '[object Array]',
|
|
1074
|
+
boolTag = '[object Boolean]',
|
|
1075
|
+
dateTag = '[object Date]',
|
|
1076
|
+
errorTag = '[object Error]',
|
|
1077
|
+
funcTag = '[object Function]',
|
|
1078
|
+
mapTag = '[object Map]',
|
|
1079
|
+
numberTag = '[object Number]',
|
|
1080
|
+
objectTag$1 = '[object Object]',
|
|
1081
|
+
regexpTag = '[object RegExp]',
|
|
1082
|
+
setTag = '[object Set]',
|
|
1083
|
+
stringTag = '[object String]',
|
|
1084
|
+
weakMapTag = '[object WeakMap]';
|
|
1085
|
+
|
|
1086
|
+
var arrayBufferTag = '[object ArrayBuffer]',
|
|
1087
|
+
dataViewTag = '[object DataView]',
|
|
1088
|
+
float32Tag = '[object Float32Array]',
|
|
1089
|
+
float64Tag = '[object Float64Array]',
|
|
1090
|
+
int8Tag = '[object Int8Array]',
|
|
1091
|
+
int16Tag = '[object Int16Array]',
|
|
1092
|
+
int32Tag = '[object Int32Array]',
|
|
1093
|
+
uint8Tag = '[object Uint8Array]',
|
|
1094
|
+
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
1095
|
+
uint16Tag = '[object Uint16Array]',
|
|
1096
|
+
uint32Tag = '[object Uint32Array]';
|
|
1097
|
+
|
|
1098
|
+
/** Used to identify `toStringTag` values of typed arrays. */
|
|
1099
|
+
var typedArrayTags = {};
|
|
1100
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
1101
|
+
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
1102
|
+
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
1103
|
+
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
1104
|
+
typedArrayTags[uint32Tag] = true;
|
|
1105
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
1106
|
+
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
1107
|
+
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|
1108
|
+
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
|
1109
|
+
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
|
1110
|
+
typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
|
|
1111
|
+
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
|
1112
|
+
typedArrayTags[weakMapTag] = false;
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
1116
|
+
*
|
|
1117
|
+
* @private
|
|
1118
|
+
* @param {*} value The value to check.
|
|
1119
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1120
|
+
*/
|
|
1121
|
+
function baseIsTypedArray(value) {
|
|
1122
|
+
return isObjectLike(value) &&
|
|
1123
|
+
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* The base implementation of `_.unary` without support for storing metadata.
|
|
1128
|
+
*
|
|
1129
|
+
* @private
|
|
1130
|
+
* @param {Function} func The function to cap arguments for.
|
|
1131
|
+
* @returns {Function} Returns the new capped function.
|
|
1132
|
+
*/
|
|
1133
|
+
function baseUnary(func) {
|
|
1134
|
+
return function(value) {
|
|
1135
|
+
return func(value);
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/** Detect free variable `exports`. */
|
|
1140
|
+
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1141
|
+
|
|
1142
|
+
/** Detect free variable `module`. */
|
|
1143
|
+
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
|
|
1144
|
+
|
|
1145
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1146
|
+
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
1147
|
+
|
|
1148
|
+
/** Detect free variable `process` from Node.js. */
|
|
1149
|
+
var freeProcess = moduleExports$1 && freeGlobal.process;
|
|
1150
|
+
|
|
1151
|
+
/** Used to access faster Node.js helpers. */
|
|
1152
|
+
var nodeUtil = (function() {
|
|
1153
|
+
try {
|
|
1154
|
+
// Use `util.types` for Node.js 10+.
|
|
1155
|
+
var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
|
|
1156
|
+
|
|
1157
|
+
if (types) {
|
|
1158
|
+
return types;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// Legacy `process.binding('util')` for Node.js < 10.
|
|
1162
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
1163
|
+
} catch (e) {}
|
|
1164
|
+
}());
|
|
1165
|
+
|
|
1166
|
+
/* Node.js helper references. */
|
|
1167
|
+
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* Checks if `value` is classified as a typed array.
|
|
1171
|
+
*
|
|
1172
|
+
* @static
|
|
1173
|
+
* @memberOf _
|
|
1174
|
+
* @since 3.0.0
|
|
1175
|
+
* @category Lang
|
|
1176
|
+
* @param {*} value The value to check.
|
|
1177
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1178
|
+
* @example
|
|
1179
|
+
*
|
|
1180
|
+
* _.isTypedArray(new Uint8Array);
|
|
1181
|
+
* // => true
|
|
1182
|
+
*
|
|
1183
|
+
* _.isTypedArray([]);
|
|
1184
|
+
* // => false
|
|
1185
|
+
*/
|
|
1186
|
+
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Creates an array of the enumerable property names of the array-like `value`.
|
|
1190
|
+
*
|
|
1191
|
+
* @private
|
|
1192
|
+
* @param {*} value The value to query.
|
|
1193
|
+
* @param {boolean} inherited Specify returning inherited property names.
|
|
1194
|
+
* @returns {Array} Returns the array of property names.
|
|
1195
|
+
*/
|
|
1196
|
+
function arrayLikeKeys(value, inherited) {
|
|
1197
|
+
var isArr = isArray(value),
|
|
1198
|
+
isArg = !isArr && isArguments(value),
|
|
1199
|
+
isBuff = !isArr && !isArg && isBuffer(value),
|
|
1200
|
+
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
|
1201
|
+
skipIndexes = isArr || isArg || isBuff || isType,
|
|
1202
|
+
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
1203
|
+
length = result.length;
|
|
1204
|
+
|
|
1205
|
+
for (var key in value) {
|
|
1206
|
+
if (!(skipIndexes && (
|
|
1207
|
+
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1208
|
+
key == 'length' ||
|
|
1209
|
+
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1210
|
+
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
1211
|
+
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1212
|
+
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
1213
|
+
// Skip index properties.
|
|
1214
|
+
isIndex(key, length)
|
|
1215
|
+
))) {
|
|
1216
|
+
result.push(key);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
return result;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
1224
|
+
*
|
|
1225
|
+
* @private
|
|
1226
|
+
* @param {Function} func The function to wrap.
|
|
1227
|
+
* @param {Function} transform The argument transform.
|
|
1228
|
+
* @returns {Function} Returns the new function.
|
|
1229
|
+
*/
|
|
1230
|
+
function overArg(func, transform) {
|
|
1231
|
+
return function(arg) {
|
|
1232
|
+
return func(transform(arg));
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* This function is like
|
|
1238
|
+
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
1239
|
+
* except that it includes inherited enumerable properties.
|
|
1240
|
+
*
|
|
1241
|
+
* @private
|
|
1242
|
+
* @param {Object} object The object to query.
|
|
1243
|
+
* @returns {Array} Returns the array of property names.
|
|
1244
|
+
*/
|
|
1245
|
+
function nativeKeysIn(object) {
|
|
1246
|
+
var result = [];
|
|
1247
|
+
if (object != null) {
|
|
1248
|
+
for (var key in Object(object)) {
|
|
1249
|
+
result.push(key);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
return result;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/** Used for built-in method references. */
|
|
1256
|
+
var objectProto$3 = Object.prototype;
|
|
1257
|
+
|
|
1258
|
+
/** Used to check objects for own properties. */
|
|
1259
|
+
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
|
|
1263
|
+
*
|
|
1264
|
+
* @private
|
|
1265
|
+
* @param {Object} object The object to query.
|
|
1266
|
+
* @returns {Array} Returns the array of property names.
|
|
1267
|
+
*/
|
|
1268
|
+
function baseKeysIn(object) {
|
|
1269
|
+
if (!isObject(object)) {
|
|
1270
|
+
return nativeKeysIn(object);
|
|
1271
|
+
}
|
|
1272
|
+
var isProto = isPrototype(object),
|
|
1273
|
+
result = [];
|
|
1274
|
+
|
|
1275
|
+
for (var key in object) {
|
|
1276
|
+
if (!(key == 'constructor' && (isProto || !hasOwnProperty$3.call(object, key)))) {
|
|
1277
|
+
result.push(key);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return result;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Creates an array of the own and inherited enumerable property names of `object`.
|
|
1285
|
+
*
|
|
1286
|
+
* **Note:** Non-object values are coerced to objects.
|
|
1287
|
+
*
|
|
1288
|
+
* @static
|
|
1289
|
+
* @memberOf _
|
|
1290
|
+
* @since 3.0.0
|
|
1291
|
+
* @category Object
|
|
1292
|
+
* @param {Object} object The object to query.
|
|
1293
|
+
* @returns {Array} Returns the array of property names.
|
|
1294
|
+
* @example
|
|
1295
|
+
*
|
|
1296
|
+
* function Foo() {
|
|
1297
|
+
* this.a = 1;
|
|
1298
|
+
* this.b = 2;
|
|
1299
|
+
* }
|
|
1300
|
+
*
|
|
1301
|
+
* Foo.prototype.c = 3;
|
|
1302
|
+
*
|
|
1303
|
+
* _.keysIn(new Foo);
|
|
1304
|
+
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
|
1305
|
+
*/
|
|
1306
|
+
function keysIn(object) {
|
|
1307
|
+
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeysIn(object);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/* Built-in method references that are verified to be native. */
|
|
1311
|
+
var nativeCreate = getNative(Object, 'create');
|
|
1312
|
+
|
|
1313
|
+
/**
|
|
1314
|
+
* Removes all key-value entries from the hash.
|
|
1315
|
+
*
|
|
1316
|
+
* @private
|
|
1317
|
+
* @name clear
|
|
1318
|
+
* @memberOf Hash
|
|
1319
|
+
*/
|
|
1320
|
+
function hashClear() {
|
|
1321
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
1322
|
+
this.size = 0;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* Removes `key` and its value from the hash.
|
|
1327
|
+
*
|
|
1328
|
+
* @private
|
|
1329
|
+
* @name delete
|
|
1330
|
+
* @memberOf Hash
|
|
1331
|
+
* @param {Object} hash The hash to modify.
|
|
1332
|
+
* @param {string} key The key of the value to remove.
|
|
1333
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1334
|
+
*/
|
|
1335
|
+
function hashDelete(key) {
|
|
1336
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
1337
|
+
this.size -= result ? 1 : 0;
|
|
1338
|
+
return result;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1342
|
+
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
1343
|
+
|
|
1344
|
+
/** Used for built-in method references. */
|
|
1345
|
+
var objectProto$2 = Object.prototype;
|
|
1346
|
+
|
|
1347
|
+
/** Used to check objects for own properties. */
|
|
1348
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Gets the hash value for `key`.
|
|
1352
|
+
*
|
|
1353
|
+
* @private
|
|
1354
|
+
* @name get
|
|
1355
|
+
* @memberOf Hash
|
|
1356
|
+
* @param {string} key The key of the value to get.
|
|
1357
|
+
* @returns {*} Returns the entry value.
|
|
1358
|
+
*/
|
|
1359
|
+
function hashGet(key) {
|
|
1360
|
+
var data = this.__data__;
|
|
1361
|
+
if (nativeCreate) {
|
|
1362
|
+
var result = data[key];
|
|
1363
|
+
return result === HASH_UNDEFINED$1 ? undefined : result;
|
|
1364
|
+
}
|
|
1365
|
+
return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/** Used for built-in method references. */
|
|
1369
|
+
var objectProto$1 = Object.prototype;
|
|
1370
|
+
|
|
1371
|
+
/** Used to check objects for own properties. */
|
|
1372
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Checks if a hash value for `key` exists.
|
|
1376
|
+
*
|
|
1377
|
+
* @private
|
|
1378
|
+
* @name has
|
|
1379
|
+
* @memberOf Hash
|
|
1380
|
+
* @param {string} key The key of the entry to check.
|
|
1381
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1382
|
+
*/
|
|
1383
|
+
function hashHas(key) {
|
|
1384
|
+
var data = this.__data__;
|
|
1385
|
+
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1389
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* Sets the hash `key` to `value`.
|
|
1393
|
+
*
|
|
1394
|
+
* @private
|
|
1395
|
+
* @name set
|
|
1396
|
+
* @memberOf Hash
|
|
1397
|
+
* @param {string} key The key of the value to set.
|
|
1398
|
+
* @param {*} value The value to set.
|
|
1399
|
+
* @returns {Object} Returns the hash instance.
|
|
1400
|
+
*/
|
|
1401
|
+
function hashSet(key, value) {
|
|
1402
|
+
var data = this.__data__;
|
|
1403
|
+
this.size += this.has(key) ? 0 : 1;
|
|
1404
|
+
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|
1405
|
+
return this;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Creates a hash object.
|
|
1410
|
+
*
|
|
1411
|
+
* @private
|
|
1412
|
+
* @constructor
|
|
1413
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1414
|
+
*/
|
|
1415
|
+
function Hash(entries) {
|
|
1416
|
+
var index = -1,
|
|
1417
|
+
length = entries == null ? 0 : entries.length;
|
|
1418
|
+
|
|
1419
|
+
this.clear();
|
|
1420
|
+
while (++index < length) {
|
|
1421
|
+
var entry = entries[index];
|
|
1422
|
+
this.set(entry[0], entry[1]);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// Add methods to `Hash`.
|
|
1427
|
+
Hash.prototype.clear = hashClear;
|
|
1428
|
+
Hash.prototype['delete'] = hashDelete;
|
|
1429
|
+
Hash.prototype.get = hashGet;
|
|
1430
|
+
Hash.prototype.has = hashHas;
|
|
1431
|
+
Hash.prototype.set = hashSet;
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Removes all key-value entries from the list cache.
|
|
1435
|
+
*
|
|
1436
|
+
* @private
|
|
1437
|
+
* @name clear
|
|
1438
|
+
* @memberOf ListCache
|
|
1439
|
+
*/
|
|
1440
|
+
function listCacheClear() {
|
|
1441
|
+
this.__data__ = [];
|
|
1442
|
+
this.size = 0;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
1447
|
+
*
|
|
1448
|
+
* @private
|
|
1449
|
+
* @param {Array} array The array to inspect.
|
|
1450
|
+
* @param {*} key The key to search for.
|
|
1451
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
1452
|
+
*/
|
|
1453
|
+
function assocIndexOf(array, key) {
|
|
1454
|
+
var length = array.length;
|
|
1455
|
+
while (length--) {
|
|
1456
|
+
if (eq(array[length][0], key)) {
|
|
1457
|
+
return length;
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
return -1;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
/** Used for built-in method references. */
|
|
1464
|
+
var arrayProto = Array.prototype;
|
|
1465
|
+
|
|
1466
|
+
/** Built-in value references. */
|
|
1467
|
+
var splice = arrayProto.splice;
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Removes `key` and its value from the list cache.
|
|
1471
|
+
*
|
|
1472
|
+
* @private
|
|
1473
|
+
* @name delete
|
|
1474
|
+
* @memberOf ListCache
|
|
1475
|
+
* @param {string} key The key of the value to remove.
|
|
1476
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1477
|
+
*/
|
|
1478
|
+
function listCacheDelete(key) {
|
|
1479
|
+
var data = this.__data__,
|
|
1480
|
+
index = assocIndexOf(data, key);
|
|
1481
|
+
|
|
1482
|
+
if (index < 0) {
|
|
1483
|
+
return false;
|
|
1484
|
+
}
|
|
1485
|
+
var lastIndex = data.length - 1;
|
|
1486
|
+
if (index == lastIndex) {
|
|
1487
|
+
data.pop();
|
|
1488
|
+
} else {
|
|
1489
|
+
splice.call(data, index, 1);
|
|
1490
|
+
}
|
|
1491
|
+
--this.size;
|
|
1492
|
+
return true;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Gets the list cache value for `key`.
|
|
1497
|
+
*
|
|
1498
|
+
* @private
|
|
1499
|
+
* @name get
|
|
1500
|
+
* @memberOf ListCache
|
|
1501
|
+
* @param {string} key The key of the value to get.
|
|
1502
|
+
* @returns {*} Returns the entry value.
|
|
1503
|
+
*/
|
|
1504
|
+
function listCacheGet(key) {
|
|
1505
|
+
var data = this.__data__,
|
|
1506
|
+
index = assocIndexOf(data, key);
|
|
1507
|
+
|
|
1508
|
+
return index < 0 ? undefined : data[index][1];
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* Checks if a list cache value for `key` exists.
|
|
1513
|
+
*
|
|
1514
|
+
* @private
|
|
1515
|
+
* @name has
|
|
1516
|
+
* @memberOf ListCache
|
|
1517
|
+
* @param {string} key The key of the entry to check.
|
|
1518
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1519
|
+
*/
|
|
1520
|
+
function listCacheHas(key) {
|
|
1521
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Sets the list cache `key` to `value`.
|
|
1526
|
+
*
|
|
1527
|
+
* @private
|
|
1528
|
+
* @name set
|
|
1529
|
+
* @memberOf ListCache
|
|
1530
|
+
* @param {string} key The key of the value to set.
|
|
1531
|
+
* @param {*} value The value to set.
|
|
1532
|
+
* @returns {Object} Returns the list cache instance.
|
|
1533
|
+
*/
|
|
1534
|
+
function listCacheSet(key, value) {
|
|
1535
|
+
var data = this.__data__,
|
|
1536
|
+
index = assocIndexOf(data, key);
|
|
1537
|
+
|
|
1538
|
+
if (index < 0) {
|
|
1539
|
+
++this.size;
|
|
1540
|
+
data.push([key, value]);
|
|
1541
|
+
} else {
|
|
1542
|
+
data[index][1] = value;
|
|
1543
|
+
}
|
|
1544
|
+
return this;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Creates an list cache object.
|
|
1549
|
+
*
|
|
1550
|
+
* @private
|
|
1551
|
+
* @constructor
|
|
1552
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1553
|
+
*/
|
|
1554
|
+
function ListCache(entries) {
|
|
1555
|
+
var index = -1,
|
|
1556
|
+
length = entries == null ? 0 : entries.length;
|
|
1557
|
+
|
|
1558
|
+
this.clear();
|
|
1559
|
+
while (++index < length) {
|
|
1560
|
+
var entry = entries[index];
|
|
1561
|
+
this.set(entry[0], entry[1]);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// Add methods to `ListCache`.
|
|
1566
|
+
ListCache.prototype.clear = listCacheClear;
|
|
1567
|
+
ListCache.prototype['delete'] = listCacheDelete;
|
|
1568
|
+
ListCache.prototype.get = listCacheGet;
|
|
1569
|
+
ListCache.prototype.has = listCacheHas;
|
|
1570
|
+
ListCache.prototype.set = listCacheSet;
|
|
1571
|
+
|
|
1572
|
+
/* Built-in method references that are verified to be native. */
|
|
1573
|
+
var Map = getNative(root, 'Map');
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Removes all key-value entries from the map.
|
|
1577
|
+
*
|
|
1578
|
+
* @private
|
|
1579
|
+
* @name clear
|
|
1580
|
+
* @memberOf MapCache
|
|
1581
|
+
*/
|
|
1582
|
+
function mapCacheClear() {
|
|
1583
|
+
this.size = 0;
|
|
1584
|
+
this.__data__ = {
|
|
1585
|
+
'hash': new Hash,
|
|
1586
|
+
'map': new (Map || ListCache),
|
|
1587
|
+
'string': new Hash
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
1593
|
+
*
|
|
1594
|
+
* @private
|
|
1595
|
+
* @param {*} value The value to check.
|
|
1596
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
1597
|
+
*/
|
|
1598
|
+
function isKeyable(value) {
|
|
1599
|
+
var type = typeof value;
|
|
1600
|
+
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
1601
|
+
? (value !== '__proto__')
|
|
1602
|
+
: (value === null);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Gets the data for `map`.
|
|
1607
|
+
*
|
|
1608
|
+
* @private
|
|
1609
|
+
* @param {Object} map The map to query.
|
|
1610
|
+
* @param {string} key The reference key.
|
|
1611
|
+
* @returns {*} Returns the map data.
|
|
1612
|
+
*/
|
|
1613
|
+
function getMapData(map, key) {
|
|
1614
|
+
var data = map.__data__;
|
|
1615
|
+
return isKeyable(key)
|
|
1616
|
+
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
1617
|
+
: data.map;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/**
|
|
1621
|
+
* Removes `key` and its value from the map.
|
|
1622
|
+
*
|
|
1623
|
+
* @private
|
|
1624
|
+
* @name delete
|
|
1625
|
+
* @memberOf MapCache
|
|
1626
|
+
* @param {string} key The key of the value to remove.
|
|
1627
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1628
|
+
*/
|
|
1629
|
+
function mapCacheDelete(key) {
|
|
1630
|
+
var result = getMapData(this, key)['delete'](key);
|
|
1631
|
+
this.size -= result ? 1 : 0;
|
|
1632
|
+
return result;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* Gets the map value for `key`.
|
|
1637
|
+
*
|
|
1638
|
+
* @private
|
|
1639
|
+
* @name get
|
|
1640
|
+
* @memberOf MapCache
|
|
1641
|
+
* @param {string} key The key of the value to get.
|
|
1642
|
+
* @returns {*} Returns the entry value.
|
|
1643
|
+
*/
|
|
1644
|
+
function mapCacheGet(key) {
|
|
1645
|
+
return getMapData(this, key).get(key);
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Checks if a map value for `key` exists.
|
|
1650
|
+
*
|
|
1651
|
+
* @private
|
|
1652
|
+
* @name has
|
|
1653
|
+
* @memberOf MapCache
|
|
1654
|
+
* @param {string} key The key of the entry to check.
|
|
1655
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1656
|
+
*/
|
|
1657
|
+
function mapCacheHas(key) {
|
|
1658
|
+
return getMapData(this, key).has(key);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* Sets the map `key` to `value`.
|
|
1663
|
+
*
|
|
1664
|
+
* @private
|
|
1665
|
+
* @name set
|
|
1666
|
+
* @memberOf MapCache
|
|
1667
|
+
* @param {string} key The key of the value to set.
|
|
1668
|
+
* @param {*} value The value to set.
|
|
1669
|
+
* @returns {Object} Returns the map cache instance.
|
|
1670
|
+
*/
|
|
1671
|
+
function mapCacheSet(key, value) {
|
|
1672
|
+
var data = getMapData(this, key),
|
|
1673
|
+
size = data.size;
|
|
1674
|
+
|
|
1675
|
+
data.set(key, value);
|
|
1676
|
+
this.size += data.size == size ? 0 : 1;
|
|
1677
|
+
return this;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Creates a map cache object to store key-value pairs.
|
|
1682
|
+
*
|
|
1683
|
+
* @private
|
|
1684
|
+
* @constructor
|
|
1685
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1686
|
+
*/
|
|
1687
|
+
function MapCache(entries) {
|
|
1688
|
+
var index = -1,
|
|
1689
|
+
length = entries == null ? 0 : entries.length;
|
|
1690
|
+
|
|
1691
|
+
this.clear();
|
|
1692
|
+
while (++index < length) {
|
|
1693
|
+
var entry = entries[index];
|
|
1694
|
+
this.set(entry[0], entry[1]);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
// Add methods to `MapCache`.
|
|
1699
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
1700
|
+
MapCache.prototype['delete'] = mapCacheDelete;
|
|
1701
|
+
MapCache.prototype.get = mapCacheGet;
|
|
1702
|
+
MapCache.prototype.has = mapCacheHas;
|
|
1703
|
+
MapCache.prototype.set = mapCacheSet;
|
|
1704
|
+
|
|
1705
|
+
/** Built-in value references. */
|
|
1706
|
+
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
1707
|
+
|
|
1708
|
+
/** `Object#toString` result references. */
|
|
1709
|
+
var objectTag = '[object Object]';
|
|
1710
|
+
|
|
1711
|
+
/** Used for built-in method references. */
|
|
1712
|
+
var funcProto = Function.prototype,
|
|
1713
|
+
objectProto = Object.prototype;
|
|
1714
|
+
|
|
1715
|
+
/** Used to resolve the decompiled source of functions. */
|
|
1716
|
+
var funcToString = funcProto.toString;
|
|
1717
|
+
|
|
1718
|
+
/** Used to check objects for own properties. */
|
|
1719
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
1720
|
+
|
|
1721
|
+
/** Used to infer the `Object` constructor. */
|
|
1722
|
+
var objectCtorString = funcToString.call(Object);
|
|
1723
|
+
|
|
1724
|
+
/**
|
|
1725
|
+
* Checks if `value` is a plain object, that is, an object created by the
|
|
1726
|
+
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
1727
|
+
*
|
|
1728
|
+
* @static
|
|
1729
|
+
* @memberOf _
|
|
1730
|
+
* @since 0.8.0
|
|
1731
|
+
* @category Lang
|
|
1732
|
+
* @param {*} value The value to check.
|
|
1733
|
+
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
1734
|
+
* @example
|
|
1735
|
+
*
|
|
1736
|
+
* function Foo() {
|
|
1737
|
+
* this.a = 1;
|
|
1738
|
+
* }
|
|
1739
|
+
*
|
|
1740
|
+
* _.isPlainObject(new Foo);
|
|
1741
|
+
* // => false
|
|
1742
|
+
*
|
|
1743
|
+
* _.isPlainObject([1, 2, 3]);
|
|
1744
|
+
* // => false
|
|
1745
|
+
*
|
|
1746
|
+
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
1747
|
+
* // => true
|
|
1748
|
+
*
|
|
1749
|
+
* _.isPlainObject(Object.create(null));
|
|
1750
|
+
* // => true
|
|
1751
|
+
*/
|
|
1752
|
+
function isPlainObject(value) {
|
|
1753
|
+
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
|
1754
|
+
return false;
|
|
1755
|
+
}
|
|
1756
|
+
var proto = getPrototype(value);
|
|
1757
|
+
if (proto === null) {
|
|
1758
|
+
return true;
|
|
1759
|
+
}
|
|
1760
|
+
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
1761
|
+
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
|
1762
|
+
funcToString.call(Ctor) == objectCtorString;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Removes all key-value entries from the stack.
|
|
1767
|
+
*
|
|
1768
|
+
* @private
|
|
1769
|
+
* @name clear
|
|
1770
|
+
* @memberOf Stack
|
|
1771
|
+
*/
|
|
1772
|
+
function stackClear() {
|
|
1773
|
+
this.__data__ = new ListCache;
|
|
1774
|
+
this.size = 0;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* Removes `key` and its value from the stack.
|
|
1779
|
+
*
|
|
1780
|
+
* @private
|
|
1781
|
+
* @name delete
|
|
1782
|
+
* @memberOf Stack
|
|
1783
|
+
* @param {string} key The key of the value to remove.
|
|
1784
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1785
|
+
*/
|
|
1786
|
+
function stackDelete(key) {
|
|
1787
|
+
var data = this.__data__,
|
|
1788
|
+
result = data['delete'](key);
|
|
1789
|
+
|
|
1790
|
+
this.size = data.size;
|
|
1791
|
+
return result;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
/**
|
|
1795
|
+
* Gets the stack value for `key`.
|
|
1796
|
+
*
|
|
1797
|
+
* @private
|
|
1798
|
+
* @name get
|
|
1799
|
+
* @memberOf Stack
|
|
1800
|
+
* @param {string} key The key of the value to get.
|
|
1801
|
+
* @returns {*} Returns the entry value.
|
|
1802
|
+
*/
|
|
1803
|
+
function stackGet(key) {
|
|
1804
|
+
return this.__data__.get(key);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
/**
|
|
1808
|
+
* Checks if a stack value for `key` exists.
|
|
1809
|
+
*
|
|
1810
|
+
* @private
|
|
1811
|
+
* @name has
|
|
1812
|
+
* @memberOf Stack
|
|
1813
|
+
* @param {string} key The key of the entry to check.
|
|
1814
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1815
|
+
*/
|
|
1816
|
+
function stackHas(key) {
|
|
1817
|
+
return this.__data__.has(key);
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
/** Used as the size to enable large array optimizations. */
|
|
1821
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* Sets the stack `key` to `value`.
|
|
1825
|
+
*
|
|
1826
|
+
* @private
|
|
1827
|
+
* @name set
|
|
1828
|
+
* @memberOf Stack
|
|
1829
|
+
* @param {string} key The key of the value to set.
|
|
1830
|
+
* @param {*} value The value to set.
|
|
1831
|
+
* @returns {Object} Returns the stack cache instance.
|
|
1832
|
+
*/
|
|
1833
|
+
function stackSet(key, value) {
|
|
1834
|
+
var data = this.__data__;
|
|
1835
|
+
if (data instanceof ListCache) {
|
|
1836
|
+
var pairs = data.__data__;
|
|
1837
|
+
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
1838
|
+
pairs.push([key, value]);
|
|
1839
|
+
this.size = ++data.size;
|
|
1840
|
+
return this;
|
|
1841
|
+
}
|
|
1842
|
+
data = this.__data__ = new MapCache(pairs);
|
|
1843
|
+
}
|
|
1844
|
+
data.set(key, value);
|
|
1845
|
+
this.size = data.size;
|
|
1846
|
+
return this;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* Creates a stack cache object to store key-value pairs.
|
|
1851
|
+
*
|
|
1852
|
+
* @private
|
|
1853
|
+
* @constructor
|
|
1854
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1855
|
+
*/
|
|
1856
|
+
function Stack(entries) {
|
|
1857
|
+
var data = this.__data__ = new ListCache(entries);
|
|
1858
|
+
this.size = data.size;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
// Add methods to `Stack`.
|
|
1862
|
+
Stack.prototype.clear = stackClear;
|
|
1863
|
+
Stack.prototype['delete'] = stackDelete;
|
|
1864
|
+
Stack.prototype.get = stackGet;
|
|
1865
|
+
Stack.prototype.has = stackHas;
|
|
1866
|
+
Stack.prototype.set = stackSet;
|
|
1867
|
+
|
|
1868
|
+
/** Detect free variable `exports`. */
|
|
1869
|
+
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1870
|
+
|
|
1871
|
+
/** Detect free variable `module`. */
|
|
1872
|
+
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
1873
|
+
|
|
1874
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1875
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1876
|
+
|
|
1877
|
+
/** Built-in value references. */
|
|
1878
|
+
var Buffer = moduleExports ? root.Buffer : undefined;
|
|
1879
|
+
Buffer ? Buffer.allocUnsafe : undefined;
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Creates a clone of `buffer`.
|
|
1883
|
+
*
|
|
1884
|
+
* @private
|
|
1885
|
+
* @param {Buffer} buffer The buffer to clone.
|
|
1886
|
+
* @param {boolean} [isDeep] Specify a deep clone.
|
|
1887
|
+
* @returns {Buffer} Returns the cloned buffer.
|
|
1888
|
+
*/
|
|
1889
|
+
function cloneBuffer(buffer, isDeep) {
|
|
1890
|
+
{
|
|
1891
|
+
return buffer.slice();
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
/** Built-in value references. */
|
|
1896
|
+
var Uint8Array = root.Uint8Array;
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* Creates a clone of `arrayBuffer`.
|
|
1900
|
+
*
|
|
1901
|
+
* @private
|
|
1902
|
+
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
|
|
1903
|
+
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
|
1904
|
+
*/
|
|
1905
|
+
function cloneArrayBuffer(arrayBuffer) {
|
|
1906
|
+
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
1907
|
+
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
|
1908
|
+
return result;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
/**
|
|
1912
|
+
* Creates a clone of `typedArray`.
|
|
1913
|
+
*
|
|
1914
|
+
* @private
|
|
1915
|
+
* @param {Object} typedArray The typed array to clone.
|
|
1916
|
+
* @param {boolean} [isDeep] Specify a deep clone.
|
|
1917
|
+
* @returns {Object} Returns the cloned typed array.
|
|
1918
|
+
*/
|
|
1919
|
+
function cloneTypedArray(typedArray, isDeep) {
|
|
1920
|
+
var buffer = cloneArrayBuffer(typedArray.buffer) ;
|
|
1921
|
+
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Initializes an object clone.
|
|
1926
|
+
*
|
|
1927
|
+
* @private
|
|
1928
|
+
* @param {Object} object The object to clone.
|
|
1929
|
+
* @returns {Object} Returns the initialized clone.
|
|
1930
|
+
*/
|
|
1931
|
+
function initCloneObject(object) {
|
|
1932
|
+
return (typeof object.constructor == 'function' && !isPrototype(object))
|
|
1933
|
+
? baseCreate(getPrototype(object))
|
|
1934
|
+
: {};
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
|
1939
|
+
*
|
|
1940
|
+
* @private
|
|
1941
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
1942
|
+
* @returns {Function} Returns the new base function.
|
|
1943
|
+
*/
|
|
1944
|
+
function createBaseFor(fromRight) {
|
|
1945
|
+
return function(object, iteratee, keysFunc) {
|
|
1946
|
+
var index = -1,
|
|
1947
|
+
iterable = Object(object),
|
|
1948
|
+
props = keysFunc(object),
|
|
1949
|
+
length = props.length;
|
|
1950
|
+
|
|
1951
|
+
while (length--) {
|
|
1952
|
+
var key = props[++index];
|
|
1953
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
1954
|
+
break;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
return object;
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
/**
|
|
1962
|
+
* The base implementation of `baseForOwn` which iterates over `object`
|
|
1963
|
+
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
|
1964
|
+
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
1965
|
+
*
|
|
1966
|
+
* @private
|
|
1967
|
+
* @param {Object} object The object to iterate over.
|
|
1968
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
1969
|
+
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
1970
|
+
* @returns {Object} Returns `object`.
|
|
1971
|
+
*/
|
|
1972
|
+
var baseFor = createBaseFor();
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
1976
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
1977
|
+
*
|
|
1978
|
+
* @static
|
|
1979
|
+
* @memberOf _
|
|
1980
|
+
* @since 2.4.0
|
|
1981
|
+
* @category Date
|
|
1982
|
+
* @returns {number} Returns the timestamp.
|
|
1983
|
+
* @example
|
|
1984
|
+
*
|
|
1985
|
+
* _.defer(function(stamp) {
|
|
1986
|
+
* console.log(_.now() - stamp);
|
|
1987
|
+
* }, _.now());
|
|
1988
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
1989
|
+
*/
|
|
1990
|
+
var now = function() {
|
|
1991
|
+
return root.Date.now();
|
|
1992
|
+
};
|
|
1993
|
+
|
|
1994
|
+
/** Error message constants. */
|
|
1995
|
+
var FUNC_ERROR_TEXT$1 = 'Expected a function';
|
|
1996
|
+
|
|
1997
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1998
|
+
var nativeMax = Math.max,
|
|
1999
|
+
nativeMin = Math.min;
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
2003
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
2004
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
2005
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
2006
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
2007
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
2008
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
2009
|
+
* calls to the debounced function return the result of the last `func`
|
|
2010
|
+
* invocation.
|
|
2011
|
+
*
|
|
2012
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2013
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
2014
|
+
* is invoked more than once during the `wait` timeout.
|
|
2015
|
+
*
|
|
2016
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2017
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2018
|
+
*
|
|
2019
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2020
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
2021
|
+
*
|
|
2022
|
+
* @static
|
|
2023
|
+
* @memberOf _
|
|
2024
|
+
* @since 0.1.0
|
|
2025
|
+
* @category Function
|
|
2026
|
+
* @param {Function} func The function to debounce.
|
|
2027
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
2028
|
+
* @param {Object} [options={}] The options object.
|
|
2029
|
+
* @param {boolean} [options.leading=false]
|
|
2030
|
+
* Specify invoking on the leading edge of the timeout.
|
|
2031
|
+
* @param {number} [options.maxWait]
|
|
2032
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
2033
|
+
* @param {boolean} [options.trailing=true]
|
|
2034
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
2035
|
+
* @returns {Function} Returns the new debounced function.
|
|
2036
|
+
* @example
|
|
2037
|
+
*
|
|
2038
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
2039
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
2040
|
+
*
|
|
2041
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
2042
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
2043
|
+
* 'leading': true,
|
|
2044
|
+
* 'trailing': false
|
|
2045
|
+
* }));
|
|
2046
|
+
*
|
|
2047
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
2048
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
2049
|
+
* var source = new EventSource('/stream');
|
|
2050
|
+
* jQuery(source).on('message', debounced);
|
|
2051
|
+
*
|
|
2052
|
+
* // Cancel the trailing debounced invocation.
|
|
2053
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
2054
|
+
*/
|
|
2055
|
+
function debounce(func, wait, options) {
|
|
2056
|
+
var lastArgs,
|
|
2057
|
+
lastThis,
|
|
2058
|
+
maxWait,
|
|
2059
|
+
result,
|
|
2060
|
+
timerId,
|
|
2061
|
+
lastCallTime,
|
|
2062
|
+
lastInvokeTime = 0,
|
|
2063
|
+
leading = false,
|
|
2064
|
+
maxing = false,
|
|
2065
|
+
trailing = true;
|
|
2066
|
+
|
|
2067
|
+
if (typeof func != 'function') {
|
|
2068
|
+
throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
2069
|
+
}
|
|
2070
|
+
wait = toNumber(wait) || 0;
|
|
2071
|
+
if (isObject(options)) {
|
|
2072
|
+
leading = !!options.leading;
|
|
2073
|
+
maxing = 'maxWait' in options;
|
|
2074
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
2075
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
function invokeFunc(time) {
|
|
2079
|
+
var args = lastArgs,
|
|
2080
|
+
thisArg = lastThis;
|
|
2081
|
+
|
|
2082
|
+
lastArgs = lastThis = undefined;
|
|
2083
|
+
lastInvokeTime = time;
|
|
2084
|
+
result = func.apply(thisArg, args);
|
|
2085
|
+
return result;
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
function leadingEdge(time) {
|
|
2089
|
+
// Reset any `maxWait` timer.
|
|
2090
|
+
lastInvokeTime = time;
|
|
2091
|
+
// Start the timer for the trailing edge.
|
|
2092
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2093
|
+
// Invoke the leading edge.
|
|
2094
|
+
return leading ? invokeFunc(time) : result;
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
function remainingWait(time) {
|
|
2098
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
2099
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
2100
|
+
timeWaiting = wait - timeSinceLastCall;
|
|
2101
|
+
|
|
2102
|
+
return maxing
|
|
2103
|
+
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
2104
|
+
: timeWaiting;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
function shouldInvoke(time) {
|
|
2108
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
2109
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
2110
|
+
|
|
2111
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
2112
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
2113
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
2114
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
2115
|
+
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
function timerExpired() {
|
|
2119
|
+
var time = now();
|
|
2120
|
+
if (shouldInvoke(time)) {
|
|
2121
|
+
return trailingEdge(time);
|
|
2122
|
+
}
|
|
2123
|
+
// Restart the timer.
|
|
2124
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
function trailingEdge(time) {
|
|
2128
|
+
timerId = undefined;
|
|
2129
|
+
|
|
2130
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
2131
|
+
// debounced at least once.
|
|
2132
|
+
if (trailing && lastArgs) {
|
|
2133
|
+
return invokeFunc(time);
|
|
2134
|
+
}
|
|
2135
|
+
lastArgs = lastThis = undefined;
|
|
2136
|
+
return result;
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
function cancel() {
|
|
2140
|
+
if (timerId !== undefined) {
|
|
2141
|
+
clearTimeout(timerId);
|
|
2142
|
+
}
|
|
2143
|
+
lastInvokeTime = 0;
|
|
2144
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
function flush() {
|
|
2148
|
+
return timerId === undefined ? result : trailingEdge(now());
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
function debounced() {
|
|
2152
|
+
var time = now(),
|
|
2153
|
+
isInvoking = shouldInvoke(time);
|
|
2154
|
+
|
|
2155
|
+
lastArgs = arguments;
|
|
2156
|
+
lastThis = this;
|
|
2157
|
+
lastCallTime = time;
|
|
2158
|
+
|
|
2159
|
+
if (isInvoking) {
|
|
2160
|
+
if (timerId === undefined) {
|
|
2161
|
+
return leadingEdge(lastCallTime);
|
|
2162
|
+
}
|
|
2163
|
+
if (maxing) {
|
|
2164
|
+
// Handle invocations in a tight loop.
|
|
2165
|
+
clearTimeout(timerId);
|
|
2166
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2167
|
+
return invokeFunc(lastCallTime);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
if (timerId === undefined) {
|
|
2171
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2172
|
+
}
|
|
2173
|
+
return result;
|
|
2174
|
+
}
|
|
2175
|
+
debounced.cancel = cancel;
|
|
2176
|
+
debounced.flush = flush;
|
|
2177
|
+
return debounced;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* This function is like `assignValue` except that it doesn't assign
|
|
2182
|
+
* `undefined` values.
|
|
2183
|
+
*
|
|
2184
|
+
* @private
|
|
2185
|
+
* @param {Object} object The object to modify.
|
|
2186
|
+
* @param {string} key The key of the property to assign.
|
|
2187
|
+
* @param {*} value The value to assign.
|
|
2188
|
+
*/
|
|
2189
|
+
function assignMergeValue(object, key, value) {
|
|
2190
|
+
if ((value !== undefined && !eq(object[key], value)) ||
|
|
2191
|
+
(value === undefined && !(key in object))) {
|
|
2192
|
+
baseAssignValue(object, key, value);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
/**
|
|
2197
|
+
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|
2198
|
+
* is an object.
|
|
2199
|
+
*
|
|
2200
|
+
* @static
|
|
2201
|
+
* @memberOf _
|
|
2202
|
+
* @since 4.0.0
|
|
2203
|
+
* @category Lang
|
|
2204
|
+
* @param {*} value The value to check.
|
|
2205
|
+
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|
2206
|
+
* else `false`.
|
|
2207
|
+
* @example
|
|
2208
|
+
*
|
|
2209
|
+
* _.isArrayLikeObject([1, 2, 3]);
|
|
2210
|
+
* // => true
|
|
2211
|
+
*
|
|
2212
|
+
* _.isArrayLikeObject(document.body.children);
|
|
2213
|
+
* // => true
|
|
2214
|
+
*
|
|
2215
|
+
* _.isArrayLikeObject('abc');
|
|
2216
|
+
* // => false
|
|
2217
|
+
*
|
|
2218
|
+
* _.isArrayLikeObject(_.noop);
|
|
2219
|
+
* // => false
|
|
2220
|
+
*/
|
|
2221
|
+
function isArrayLikeObject(value) {
|
|
2222
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Gets the value at `key`, unless `key` is "__proto__" or "constructor".
|
|
2227
|
+
*
|
|
2228
|
+
* @private
|
|
2229
|
+
* @param {Object} object The object to query.
|
|
2230
|
+
* @param {string} key The key of the property to get.
|
|
2231
|
+
* @returns {*} Returns the property value.
|
|
2232
|
+
*/
|
|
2233
|
+
function safeGet(object, key) {
|
|
2234
|
+
if (key === 'constructor' && typeof object[key] === 'function') {
|
|
2235
|
+
return;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
if (key == '__proto__') {
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
return object[key];
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
/**
|
|
2246
|
+
* Converts `value` to a plain object flattening inherited enumerable string
|
|
2247
|
+
* keyed properties of `value` to own properties of the plain object.
|
|
2248
|
+
*
|
|
2249
|
+
* @static
|
|
2250
|
+
* @memberOf _
|
|
2251
|
+
* @since 3.0.0
|
|
2252
|
+
* @category Lang
|
|
2253
|
+
* @param {*} value The value to convert.
|
|
2254
|
+
* @returns {Object} Returns the converted plain object.
|
|
2255
|
+
* @example
|
|
2256
|
+
*
|
|
2257
|
+
* function Foo() {
|
|
2258
|
+
* this.b = 2;
|
|
2259
|
+
* }
|
|
2260
|
+
*
|
|
2261
|
+
* Foo.prototype.c = 3;
|
|
2262
|
+
*
|
|
2263
|
+
* _.assign({ 'a': 1 }, new Foo);
|
|
2264
|
+
* // => { 'a': 1, 'b': 2 }
|
|
2265
|
+
*
|
|
2266
|
+
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
|
|
2267
|
+
* // => { 'a': 1, 'b': 2, 'c': 3 }
|
|
2268
|
+
*/
|
|
2269
|
+
function toPlainObject(value) {
|
|
2270
|
+
return copyObject(value, keysIn(value));
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* A specialized version of `baseMerge` for arrays and objects which performs
|
|
2275
|
+
* deep merges and tracks traversed objects enabling objects with circular
|
|
2276
|
+
* references to be merged.
|
|
2277
|
+
*
|
|
2278
|
+
* @private
|
|
2279
|
+
* @param {Object} object The destination object.
|
|
2280
|
+
* @param {Object} source The source object.
|
|
2281
|
+
* @param {string} key The key of the value to merge.
|
|
2282
|
+
* @param {number} srcIndex The index of `source`.
|
|
2283
|
+
* @param {Function} mergeFunc The function to merge values.
|
|
2284
|
+
* @param {Function} [customizer] The function to customize assigned values.
|
|
2285
|
+
* @param {Object} [stack] Tracks traversed source values and their merged
|
|
2286
|
+
* counterparts.
|
|
2287
|
+
*/
|
|
2288
|
+
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
|
2289
|
+
var objValue = safeGet(object, key),
|
|
2290
|
+
srcValue = safeGet(source, key),
|
|
2291
|
+
stacked = stack.get(srcValue);
|
|
2292
|
+
|
|
2293
|
+
if (stacked) {
|
|
2294
|
+
assignMergeValue(object, key, stacked);
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
var newValue = customizer
|
|
2298
|
+
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
|
2299
|
+
: undefined;
|
|
2300
|
+
|
|
2301
|
+
var isCommon = newValue === undefined;
|
|
2302
|
+
|
|
2303
|
+
if (isCommon) {
|
|
2304
|
+
var isArr = isArray(srcValue),
|
|
2305
|
+
isBuff = !isArr && isBuffer(srcValue),
|
|
2306
|
+
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
|
2307
|
+
|
|
2308
|
+
newValue = srcValue;
|
|
2309
|
+
if (isArr || isBuff || isTyped) {
|
|
2310
|
+
if (isArray(objValue)) {
|
|
2311
|
+
newValue = objValue;
|
|
2312
|
+
}
|
|
2313
|
+
else if (isArrayLikeObject(objValue)) {
|
|
2314
|
+
newValue = copyArray(objValue);
|
|
2315
|
+
}
|
|
2316
|
+
else if (isBuff) {
|
|
2317
|
+
isCommon = false;
|
|
2318
|
+
newValue = cloneBuffer(srcValue);
|
|
2319
|
+
}
|
|
2320
|
+
else if (isTyped) {
|
|
2321
|
+
isCommon = false;
|
|
2322
|
+
newValue = cloneTypedArray(srcValue);
|
|
2323
|
+
}
|
|
2324
|
+
else {
|
|
2325
|
+
newValue = [];
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
|
2329
|
+
newValue = objValue;
|
|
2330
|
+
if (isArguments(objValue)) {
|
|
2331
|
+
newValue = toPlainObject(objValue);
|
|
2332
|
+
}
|
|
2333
|
+
else if (!isObject(objValue) || isFunction(objValue)) {
|
|
2334
|
+
newValue = initCloneObject(srcValue);
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
else {
|
|
2338
|
+
isCommon = false;
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
if (isCommon) {
|
|
2342
|
+
// Recursively merge objects and arrays (susceptible to call stack limits).
|
|
2343
|
+
stack.set(srcValue, newValue);
|
|
2344
|
+
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
|
2345
|
+
stack['delete'](srcValue);
|
|
2346
|
+
}
|
|
2347
|
+
assignMergeValue(object, key, newValue);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* The base implementation of `_.merge` without support for multiple sources.
|
|
2352
|
+
*
|
|
2353
|
+
* @private
|
|
2354
|
+
* @param {Object} object The destination object.
|
|
2355
|
+
* @param {Object} source The source object.
|
|
2356
|
+
* @param {number} srcIndex The index of `source`.
|
|
2357
|
+
* @param {Function} [customizer] The function to customize merged values.
|
|
2358
|
+
* @param {Object} [stack] Tracks traversed source values and their merged
|
|
2359
|
+
* counterparts.
|
|
2360
|
+
*/
|
|
2361
|
+
function baseMerge(object, source, srcIndex, customizer, stack) {
|
|
2362
|
+
if (object === source) {
|
|
2363
|
+
return;
|
|
2364
|
+
}
|
|
2365
|
+
baseFor(source, function(srcValue, key) {
|
|
2366
|
+
stack || (stack = new Stack);
|
|
2367
|
+
if (isObject(srcValue)) {
|
|
2368
|
+
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
|
2369
|
+
}
|
|
2370
|
+
else {
|
|
2371
|
+
var newValue = customizer
|
|
2372
|
+
? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
|
|
2373
|
+
: undefined;
|
|
2374
|
+
|
|
2375
|
+
if (newValue === undefined) {
|
|
2376
|
+
newValue = srcValue;
|
|
2377
|
+
}
|
|
2378
|
+
assignMergeValue(object, key, newValue);
|
|
2379
|
+
}
|
|
2380
|
+
}, keysIn);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
/**
|
|
2384
|
+
* This method is like `_.assign` except that it recursively merges own and
|
|
2385
|
+
* inherited enumerable string keyed properties of source objects into the
|
|
2386
|
+
* destination object. Source properties that resolve to `undefined` are
|
|
2387
|
+
* skipped if a destination value exists. Array and plain object properties
|
|
2388
|
+
* are merged recursively. Other objects and value types are overridden by
|
|
2389
|
+
* assignment. Source objects are applied from left to right. Subsequent
|
|
2390
|
+
* sources overwrite property assignments of previous sources.
|
|
2391
|
+
*
|
|
2392
|
+
* **Note:** This method mutates `object`.
|
|
2393
|
+
*
|
|
2394
|
+
* @static
|
|
2395
|
+
* @memberOf _
|
|
2396
|
+
* @since 0.5.0
|
|
2397
|
+
* @category Object
|
|
2398
|
+
* @param {Object} object The destination object.
|
|
2399
|
+
* @param {...Object} [sources] The source objects.
|
|
2400
|
+
* @returns {Object} Returns `object`.
|
|
2401
|
+
* @example
|
|
2402
|
+
*
|
|
2403
|
+
* var object = {
|
|
2404
|
+
* 'a': [{ 'b': 2 }, { 'd': 4 }]
|
|
2405
|
+
* };
|
|
2406
|
+
*
|
|
2407
|
+
* var other = {
|
|
2408
|
+
* 'a': [{ 'c': 3 }, { 'e': 5 }]
|
|
2409
|
+
* };
|
|
2410
|
+
*
|
|
2411
|
+
* _.merge(object, other);
|
|
2412
|
+
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
|
|
2413
|
+
*/
|
|
2414
|
+
var merge = createAssigner(function(object, source, srcIndex) {
|
|
2415
|
+
baseMerge(object, source, srcIndex);
|
|
2416
|
+
});
|
|
2417
|
+
|
|
2418
|
+
/** Error message constants. */
|
|
2419
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
2420
|
+
|
|
2421
|
+
/**
|
|
2422
|
+
* Creates a throttled function that only invokes `func` at most once per
|
|
2423
|
+
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
2424
|
+
* method to cancel delayed `func` invocations and a `flush` method to
|
|
2425
|
+
* immediately invoke them. Provide `options` to indicate whether `func`
|
|
2426
|
+
* should be invoked on the leading and/or trailing edge of the `wait`
|
|
2427
|
+
* timeout. The `func` is invoked with the last arguments provided to the
|
|
2428
|
+
* throttled function. Subsequent calls to the throttled function return the
|
|
2429
|
+
* result of the last `func` invocation.
|
|
2430
|
+
*
|
|
2431
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2432
|
+
* invoked on the trailing edge of the timeout only if the throttled function
|
|
2433
|
+
* is invoked more than once during the `wait` timeout.
|
|
2434
|
+
*
|
|
2435
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2436
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2437
|
+
*
|
|
2438
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2439
|
+
* for details over the differences between `_.throttle` and `_.debounce`.
|
|
2440
|
+
*
|
|
2441
|
+
* @static
|
|
2442
|
+
* @memberOf _
|
|
2443
|
+
* @since 0.1.0
|
|
2444
|
+
* @category Function
|
|
2445
|
+
* @param {Function} func The function to throttle.
|
|
2446
|
+
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
|
2447
|
+
* @param {Object} [options={}] The options object.
|
|
2448
|
+
* @param {boolean} [options.leading=true]
|
|
2449
|
+
* Specify invoking on the leading edge of the timeout.
|
|
2450
|
+
* @param {boolean} [options.trailing=true]
|
|
2451
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
2452
|
+
* @returns {Function} Returns the new throttled function.
|
|
2453
|
+
* @example
|
|
2454
|
+
*
|
|
2455
|
+
* // Avoid excessively updating the position while scrolling.
|
|
2456
|
+
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
|
2457
|
+
*
|
|
2458
|
+
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
2459
|
+
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
|
|
2460
|
+
* jQuery(element).on('click', throttled);
|
|
2461
|
+
*
|
|
2462
|
+
* // Cancel the trailing throttled invocation.
|
|
2463
|
+
* jQuery(window).on('popstate', throttled.cancel);
|
|
2464
|
+
*/
|
|
2465
|
+
function throttle(func, wait, options) {
|
|
2466
|
+
var leading = true,
|
|
2467
|
+
trailing = true;
|
|
2468
|
+
|
|
2469
|
+
if (typeof func != 'function') {
|
|
2470
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
2471
|
+
}
|
|
2472
|
+
if (isObject(options)) {
|
|
2473
|
+
leading = 'leading' in options ? !!options.leading : leading;
|
|
2474
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
2475
|
+
}
|
|
2476
|
+
return debounce(func, wait, {
|
|
2477
|
+
'leading': leading,
|
|
2478
|
+
'maxWait': wait,
|
|
2479
|
+
'trailing': trailing
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
6
2482
|
|
|
7
2483
|
const GHOST_EL_ID_PREFIX = "ghost_el_";
|
|
8
2484
|
const DRAG_EL_ID_PREFIX = "drag_el_";
|
|
@@ -158,10 +2634,10 @@
|
|
|
158
2634
|
const removeSelectedClassName = (doc) => {
|
|
159
2635
|
const oldEl = doc.querySelector(`.${SELECTED_CLASS}`);
|
|
160
2636
|
if (oldEl) {
|
|
161
|
-
|
|
162
|
-
if (oldEl.parentNode)
|
|
2637
|
+
core.removeClassName(oldEl, SELECTED_CLASS);
|
|
2638
|
+
if (oldEl.parentNode) core.removeClassName(oldEl.parentNode, `${SELECTED_CLASS}-parent`);
|
|
163
2639
|
doc.querySelectorAll(`.${SELECTED_CLASS}-parents`).forEach((item) => {
|
|
164
|
-
|
|
2640
|
+
core.removeClassName(item, `${SELECTED_CLASS}-parents`);
|
|
165
2641
|
});
|
|
166
2642
|
}
|
|
167
2643
|
};
|
|
@@ -176,7 +2652,7 @@
|
|
|
176
2652
|
let swapIndex = 0;
|
|
177
2653
|
let addUpH = target.clientHeight;
|
|
178
2654
|
const brothers = Array.from(target.parentNode?.children || []).filter(
|
|
179
|
-
(child) => !
|
|
2655
|
+
(child) => !core.getIdFromEl()(child)?.startsWith(GHOST_EL_ID_PREFIX)
|
|
180
2656
|
);
|
|
181
2657
|
const index = brothers.indexOf(target);
|
|
182
2658
|
const downEls = brothers.slice(index + 1);
|
|
@@ -192,15 +2668,15 @@
|
|
|
192
2668
|
addUpH += ele.clientHeight / 2;
|
|
193
2669
|
swapIndex = i;
|
|
194
2670
|
}
|
|
195
|
-
const src =
|
|
2671
|
+
const src = core.getIdFromEl()(target) || "";
|
|
196
2672
|
return {
|
|
197
2673
|
src,
|
|
198
|
-
dist: downEls.length && swapIndex > -1 ?
|
|
2674
|
+
dist: downEls.length && swapIndex > -1 ? core.getIdFromEl()(downEls[swapIndex]) || "" : src
|
|
199
2675
|
};
|
|
200
2676
|
};
|
|
201
2677
|
const up = (deltaTop, target) => {
|
|
202
2678
|
const brothers = Array.from(target.parentNode?.children || []).filter(
|
|
203
|
-
(child) => !
|
|
2679
|
+
(child) => !core.getIdFromEl()(child)?.startsWith(GHOST_EL_ID_PREFIX)
|
|
204
2680
|
);
|
|
205
2681
|
const index = brothers.indexOf(target);
|
|
206
2682
|
const upEls = brothers.slice(0, index);
|
|
@@ -215,10 +2691,10 @@
|
|
|
215
2691
|
addUpH += ele.clientHeight / 2;
|
|
216
2692
|
swapIndex = i;
|
|
217
2693
|
}
|
|
218
|
-
const src =
|
|
2694
|
+
const src = core.getIdFromEl()(target) || "";
|
|
219
2695
|
return {
|
|
220
2696
|
src,
|
|
221
|
-
dist: upEls.length && swapIndex > -1 ?
|
|
2697
|
+
dist: upEls.length && swapIndex > -1 ? core.getIdFromEl()(upEls[swapIndex]) || "" : src
|
|
222
2698
|
};
|
|
223
2699
|
};
|
|
224
2700
|
const isMoveableButton = (target) => target.classList.contains("moveable-button") || target.parentElement?.classList.contains("moveable-button");
|
|
@@ -256,7 +2732,7 @@
|
|
|
256
2732
|
class TargetShadow {
|
|
257
2733
|
el;
|
|
258
2734
|
els = [];
|
|
259
|
-
idPrefix = `target_calibrate_${
|
|
2735
|
+
idPrefix = `target_calibrate_${core.guid()}`;
|
|
260
2736
|
container;
|
|
261
2737
|
scrollLeft = 0;
|
|
262
2738
|
scrollTop = 0;
|
|
@@ -271,7 +2747,7 @@
|
|
|
271
2747
|
this.zIndex = config.zIndex;
|
|
272
2748
|
}
|
|
273
2749
|
if (config.idPrefix) {
|
|
274
|
-
this.idPrefix = `${config.idPrefix}_${
|
|
2750
|
+
this.idPrefix = `${config.idPrefix}_${core.guid()}`;
|
|
275
2751
|
}
|
|
276
2752
|
this.container.addEventListener("customScroll", this.scrollHandler);
|
|
277
2753
|
}
|
|
@@ -290,7 +2766,7 @@
|
|
|
290
2766
|
}
|
|
291
2767
|
destroyEl() {
|
|
292
2768
|
this.el?.remove();
|
|
293
|
-
this.el =
|
|
2769
|
+
this.el = undefined;
|
|
294
2770
|
}
|
|
295
2771
|
destroyEls() {
|
|
296
2772
|
this.els.forEach((el) => {
|
|
@@ -305,7 +2781,7 @@
|
|
|
305
2781
|
}
|
|
306
2782
|
updateEl(target, src) {
|
|
307
2783
|
const el = src || globalThis.document.createElement("div");
|
|
308
|
-
|
|
2784
|
+
core.setIdToEl()(el, `${this.idPrefix}_${core.getIdFromEl()(target)}`);
|
|
309
2785
|
el.style.cssText = getTargetElStyle(target, this.zIndex);
|
|
310
2786
|
if (typeof this.updateDragEl === "function") {
|
|
311
2787
|
this.updateDragEl(el, target, this.container);
|
|
@@ -317,7 +2793,7 @@
|
|
|
317
2793
|
} else if (!isFixed && mode === Mode.FIXED) {
|
|
318
2794
|
el.style.transform = `translate3d(${-this.scrollLeft}px, ${-this.scrollTop}px, 0)`;
|
|
319
2795
|
}
|
|
320
|
-
if (!
|
|
2796
|
+
if (!core.getElById()(globalThis.document, core.getIdFromEl()(el))) {
|
|
321
2797
|
this.container.append(el);
|
|
322
2798
|
}
|
|
323
2799
|
return el;
|
|
@@ -450,7 +2926,7 @@
|
|
|
450
2926
|
}
|
|
451
2927
|
destroyGhostEl() {
|
|
452
2928
|
this.ghostEl?.remove();
|
|
453
|
-
this.ghostEl =
|
|
2929
|
+
this.ghostEl = undefined;
|
|
454
2930
|
}
|
|
455
2931
|
clear() {
|
|
456
2932
|
this.moveableHelper.clear();
|
|
@@ -487,15 +2963,15 @@
|
|
|
487
2963
|
events.forEach((ev) => {
|
|
488
2964
|
const { width, height, beforeTranslate } = ev.drag;
|
|
489
2965
|
const frameSnapShot = this.framesSnapShot.find(
|
|
490
|
-
(frameItem) => frameItem.id ===
|
|
2966
|
+
(frameItem) => frameItem.id === core.getIdFromEl()(ev.target)?.replace(DRAG_EL_ID_PREFIX, "")
|
|
491
2967
|
);
|
|
492
2968
|
if (!frameSnapShot) return;
|
|
493
2969
|
const targeEl = this.targetList.find(
|
|
494
|
-
(targetItem) =>
|
|
2970
|
+
(targetItem) => core.getIdFromEl()(targetItem) === core.getIdFromEl()(ev.target)?.replace(DRAG_EL_ID_PREFIX, "")
|
|
495
2971
|
);
|
|
496
2972
|
if (!targeEl) return;
|
|
497
2973
|
const isParentIncluded = this.targetList.find(
|
|
498
|
-
(targetItem) =>
|
|
2974
|
+
(targetItem) => core.getIdFromEl()(targetItem) === core.getIdFromEl()(targeEl.parentElement)
|
|
499
2975
|
);
|
|
500
2976
|
if (!isParentIncluded) {
|
|
501
2977
|
const { marginLeft, marginTop } = getMarginValue(targeEl);
|
|
@@ -516,15 +2992,15 @@
|
|
|
516
2992
|
const { events } = e;
|
|
517
2993
|
events.forEach((ev) => {
|
|
518
2994
|
const frameSnapShot = this.framesSnapShot.find(
|
|
519
|
-
(frameItem) =>
|
|
2995
|
+
(frameItem) => core.getIdFromEl()(ev.target)?.startsWith(DRAG_EL_ID_PREFIX) && core.getIdFromEl()(ev.target)?.endsWith(frameItem.id)
|
|
520
2996
|
);
|
|
521
2997
|
if (!frameSnapShot) return;
|
|
522
2998
|
const targeEl = this.targetList.find(
|
|
523
|
-
(targetItem) =>
|
|
2999
|
+
(targetItem) => core.getIdFromEl()(ev.target)?.startsWith(DRAG_EL_ID_PREFIX) && core.getIdFromEl()(targetItem) && core.getIdFromEl()(ev.target)?.endsWith(core.getIdFromEl()(targetItem))
|
|
524
3000
|
);
|
|
525
3001
|
if (!targeEl) return;
|
|
526
3002
|
const isParentIncluded = this.targetList.find(
|
|
527
|
-
(targetItem) =>
|
|
3003
|
+
(targetItem) => core.getIdFromEl()(targetItem) === core.getIdFromEl()(targeEl.parentElement)
|
|
528
3004
|
);
|
|
529
3005
|
if (!isParentIncluded) {
|
|
530
3006
|
const { marginLeft, marginTop } = getMarginValue(targeEl);
|
|
@@ -536,15 +3012,15 @@
|
|
|
536
3012
|
getUpdatedElRect(el, parentEl, doc) {
|
|
537
3013
|
const offset = this.mode === Mode.SORTABLE ? { left: 0, top: 0 } : { left: el.offsetLeft, top: el.offsetTop };
|
|
538
3014
|
const { marginLeft, marginTop } = getMarginValue(el);
|
|
539
|
-
let left =
|
|
540
|
-
let top =
|
|
3015
|
+
let left = core.calcValueByFontsize(doc, offset.left) - marginLeft;
|
|
3016
|
+
let top = core.calcValueByFontsize(doc, offset.top) - marginTop;
|
|
541
3017
|
const { borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth } = getBorderWidth(el);
|
|
542
|
-
const width =
|
|
543
|
-
const height =
|
|
3018
|
+
const width = core.calcValueByFontsize(doc, el.clientWidth + borderLeftWidth + borderRightWidth);
|
|
3019
|
+
const height = core.calcValueByFontsize(doc, el.clientHeight + borderTopWidth + borderBottomWidth);
|
|
544
3020
|
let shadowEl = this.getShadowEl();
|
|
545
3021
|
const shadowEls = this.getShadowEls();
|
|
546
3022
|
if (shadowEls.length) {
|
|
547
|
-
shadowEl = shadowEls.find((item) =>
|
|
3023
|
+
shadowEl = shadowEls.find((item) => core.getIdFromEl()(item)?.endsWith(core.getIdFromEl()(el) || ""));
|
|
548
3024
|
}
|
|
549
3025
|
if (parentEl && this.mode === Mode.ABSOLUTE && shadowEl) {
|
|
550
3026
|
const targetShadowHtmlEl = shadowEl;
|
|
@@ -553,8 +3029,8 @@
|
|
|
553
3029
|
const frame = this.getFrame(shadowEl);
|
|
554
3030
|
const [translateX, translateY] = frame?.properties.transform.translate.value;
|
|
555
3031
|
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
556
|
-
left =
|
|
557
|
-
top =
|
|
3032
|
+
left = core.calcValueByFontsize(doc, targetShadowElOffsetLeft) + parseFloat(translateX) - core.calcValueByFontsize(doc, parentLeft);
|
|
3033
|
+
top = core.calcValueByFontsize(doc, targetShadowElOffsetTop) + parseFloat(translateY) - core.calcValueByFontsize(doc, parentTop);
|
|
558
3034
|
}
|
|
559
3035
|
return { width, height, left, top };
|
|
560
3036
|
}
|
|
@@ -565,10 +3041,10 @@
|
|
|
565
3041
|
if (this.framesSnapShot.length > 0) return;
|
|
566
3042
|
events.forEach((ev) => {
|
|
567
3043
|
const matchEventTarget = this.targetList.find(
|
|
568
|
-
(targetItem) =>
|
|
3044
|
+
(targetItem) => core.getIdFromEl()(ev.target)?.startsWith(DRAG_EL_ID_PREFIX) && core.getIdFromEl()(ev.target)?.endsWith(core.getIdFromEl()(targetItem) || "")
|
|
569
3045
|
);
|
|
570
3046
|
if (!matchEventTarget) return;
|
|
571
|
-
const id =
|
|
3047
|
+
const id = core.getIdFromEl()(matchEventTarget);
|
|
572
3048
|
id && this.framesSnapShot.push({
|
|
573
3049
|
left: matchEventTarget.offsetLeft,
|
|
574
3050
|
top: matchEventTarget.offsetTop,
|
|
@@ -585,7 +3061,7 @@
|
|
|
585
3061
|
}
|
|
586
3062
|
const ghostEl = document.createElement("div");
|
|
587
3063
|
const { top, left } = getAbsolutePosition(el, getOffset(el));
|
|
588
|
-
|
|
3064
|
+
core.setIdToEl()(ghostEl, `${GHOST_EL_ID_PREFIX}${core.getIdFromEl()(el)}`);
|
|
589
3065
|
ghostEl.style.cssText = `
|
|
590
3066
|
z-index: ${ZIndex.GHOST_EL};
|
|
591
3067
|
opacity: .6;
|
|
@@ -776,7 +3252,7 @@
|
|
|
776
3252
|
getOptions(isMultiSelect, runtimeOptions = {}) {
|
|
777
3253
|
const defaultOptions = this.getDefaultOptions(isMultiSelect);
|
|
778
3254
|
const customizedOptions = this.getCustomizeOptions() || {};
|
|
779
|
-
this.options =
|
|
3255
|
+
this.options = merge(defaultOptions, customizedOptions, runtimeOptions);
|
|
780
3256
|
return this.options;
|
|
781
3257
|
}
|
|
782
3258
|
/**
|
|
@@ -799,11 +3275,11 @@
|
|
|
799
3275
|
top: 0,
|
|
800
3276
|
left: 0,
|
|
801
3277
|
right: this.container.clientWidth,
|
|
802
|
-
bottom: isSortable ?
|
|
3278
|
+
bottom: isSortable ? undefined : this.container.clientHeight
|
|
803
3279
|
}
|
|
804
3280
|
};
|
|
805
3281
|
const differenceOptions = isMultiSelect ? this.getMultiOptions() : this.getSingleOptions();
|
|
806
|
-
return
|
|
3282
|
+
return merge(commonOptions, differenceOptions);
|
|
807
3283
|
}
|
|
808
3284
|
/**
|
|
809
3285
|
* 获取单选下的差异化参数
|
|
@@ -949,7 +3425,7 @@
|
|
|
949
3425
|
select(el, event) {
|
|
950
3426
|
if (!el) {
|
|
951
3427
|
this.moveable?.destroy();
|
|
952
|
-
this.moveable =
|
|
3428
|
+
this.moveable = undefined;
|
|
953
3429
|
return;
|
|
954
3430
|
}
|
|
955
3431
|
if (!this.moveable || el !== this.target) {
|
|
@@ -1050,7 +3526,7 @@
|
|
|
1050
3526
|
if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
|
|
1051
3527
|
if (timeout) {
|
|
1052
3528
|
globalThis.clearTimeout(timeout);
|
|
1053
|
-
timeout =
|
|
3529
|
+
timeout = undefined;
|
|
1054
3530
|
}
|
|
1055
3531
|
timeout = this.delayedMarkContainer(e.inputEvent, [this.target]);
|
|
1056
3532
|
this.dragStatus = StageDragStatus.ING;
|
|
@@ -1058,7 +3534,7 @@
|
|
|
1058
3534
|
}).on("dragEnd", () => {
|
|
1059
3535
|
if (timeout) {
|
|
1060
3536
|
globalThis.clearTimeout(timeout);
|
|
1061
|
-
timeout =
|
|
3537
|
+
timeout = undefined;
|
|
1062
3538
|
}
|
|
1063
3539
|
const parentEl = this.markContainerEnd();
|
|
1064
3540
|
if (this.dragStatus === StageDragStatus.ING) {
|
|
@@ -1144,7 +3620,7 @@
|
|
|
1144
3620
|
this.emit("sort", up(deltaTop, this.target));
|
|
1145
3621
|
}
|
|
1146
3622
|
} else {
|
|
1147
|
-
const id =
|
|
3623
|
+
const id = core.getIdFromEl()(this.target);
|
|
1148
3624
|
id && this.emit("sort", {
|
|
1149
3625
|
src: id,
|
|
1150
3626
|
dist: id
|
|
@@ -1212,17 +3688,17 @@
|
|
|
1212
3688
|
if (!this.moveable || !this.target) return;
|
|
1213
3689
|
this.moveable.zoom = 0;
|
|
1214
3690
|
this.moveable.updateRect();
|
|
1215
|
-
this.target =
|
|
3691
|
+
this.target = undefined;
|
|
1216
3692
|
}
|
|
1217
3693
|
/**
|
|
1218
3694
|
* 销毁实例
|
|
1219
3695
|
*/
|
|
1220
3696
|
destroy() {
|
|
1221
|
-
this.target =
|
|
3697
|
+
this.target = undefined;
|
|
1222
3698
|
this.moveable?.destroy();
|
|
1223
3699
|
this.targetShadow?.destroy();
|
|
1224
|
-
this.moveable =
|
|
1225
|
-
this.targetShadow =
|
|
3700
|
+
this.moveable = undefined;
|
|
3701
|
+
this.targetShadow = undefined;
|
|
1226
3702
|
}
|
|
1227
3703
|
}
|
|
1228
3704
|
|
|
@@ -1292,7 +3768,7 @@
|
|
|
1292
3768
|
}).on("dragGroup", (e) => {
|
|
1293
3769
|
if (timeout) {
|
|
1294
3770
|
globalThis.clearTimeout(timeout);
|
|
1295
|
-
timeout =
|
|
3771
|
+
timeout = undefined;
|
|
1296
3772
|
}
|
|
1297
3773
|
timeout = this.delayedMarkContainer(e.inputEvent, this.targetList);
|
|
1298
3774
|
this.dragResizeHelper.onDragGroup(e);
|
|
@@ -1300,7 +3776,7 @@
|
|
|
1300
3776
|
}).on("dragGroupEnd", () => {
|
|
1301
3777
|
if (timeout) {
|
|
1302
3778
|
globalThis.clearTimeout(timeout);
|
|
1303
|
-
timeout =
|
|
3779
|
+
timeout = undefined;
|
|
1304
3780
|
}
|
|
1305
3781
|
const parentEl = this.markContainerEnd();
|
|
1306
3782
|
this.update(false, parentEl);
|
|
@@ -1308,7 +3784,7 @@
|
|
|
1308
3784
|
}).on("clickGroup", (e) => {
|
|
1309
3785
|
const { inputTarget, targets } = e;
|
|
1310
3786
|
if (targets.length > 1 && targets.includes(inputTarget)) {
|
|
1311
|
-
const id =
|
|
3787
|
+
const id = core.getIdFromEl()(inputTarget)?.replace(DRAG_EL_ID_PREFIX, "");
|
|
1312
3788
|
id && this.emit("change-to-select", id, e.inputEvent);
|
|
1313
3789
|
}
|
|
1314
3790
|
});
|
|
@@ -1414,12 +3890,12 @@
|
|
|
1414
3890
|
getRenderDocument;
|
|
1415
3891
|
disabledMultiSelect = false;
|
|
1416
3892
|
config;
|
|
1417
|
-
mouseMoveHandler =
|
|
3893
|
+
mouseMoveHandler = throttle(async (event) => {
|
|
1418
3894
|
if (event.target?.classList?.contains("moveable-direction")) {
|
|
1419
3895
|
return;
|
|
1420
3896
|
}
|
|
1421
3897
|
const el = await this.getElementFromPoint(event);
|
|
1422
|
-
const id =
|
|
3898
|
+
const id = core.getIdFromEl()(el);
|
|
1423
3899
|
if (!id) {
|
|
1424
3900
|
this.clearHighlight();
|
|
1425
3901
|
return;
|
|
@@ -1437,7 +3913,7 @@
|
|
|
1437
3913
|
this.disabledMultiSelect = config.disabledMultiSelect ?? false;
|
|
1438
3914
|
this.getTargetElement = config.getTargetElement;
|
|
1439
3915
|
this.getElementsFromPoint = config.getElementsFromPoint;
|
|
1440
|
-
this.canSelect = config.canSelect || ((el) => Boolean(
|
|
3916
|
+
this.canSelect = config.canSelect || ((el) => Boolean(core.getIdFromEl()(el)));
|
|
1441
3917
|
this.getRenderDocument = config.getRenderDocument;
|
|
1442
3918
|
this.isContainer = config.isContainer;
|
|
1443
3919
|
this.dr = this.createDr(config);
|
|
@@ -1493,7 +3969,7 @@
|
|
|
1493
3969
|
* 判断是否单选选中的元素
|
|
1494
3970
|
*/
|
|
1495
3971
|
isSelectedEl(el) {
|
|
1496
|
-
return
|
|
3972
|
+
return core.getIdFromEl()(el) === core.getIdFromEl()(this.selectedEl);
|
|
1497
3973
|
}
|
|
1498
3974
|
setSelectedEl(el) {
|
|
1499
3975
|
this.selectedEl = el;
|
|
@@ -1523,7 +3999,7 @@
|
|
|
1523
3999
|
let stopped = false;
|
|
1524
4000
|
const stop = () => stopped = true;
|
|
1525
4001
|
for (const el of els) {
|
|
1526
|
-
if (!
|
|
4002
|
+
if (!core.getIdFromEl()(el)?.startsWith(GHOST_EL_ID_PREFIX) && await this.isElCanSelect(el, event, stop)) {
|
|
1527
4003
|
if (stopped) break;
|
|
1528
4004
|
return el;
|
|
1529
4005
|
}
|
|
@@ -1599,7 +4075,7 @@
|
|
|
1599
4075
|
this.emit("highlight", el);
|
|
1600
4076
|
}
|
|
1601
4077
|
clearHighlight() {
|
|
1602
|
-
this.setHighlightEl(
|
|
4078
|
+
this.setHighlightEl(undefined);
|
|
1603
4079
|
this.highlightLayer?.clearHighlight();
|
|
1604
4080
|
}
|
|
1605
4081
|
/**
|
|
@@ -1624,8 +4100,8 @@
|
|
|
1624
4100
|
if (!doc) return;
|
|
1625
4101
|
const els = this.getElementsFromPoint(event);
|
|
1626
4102
|
for (const el of els) {
|
|
1627
|
-
if (!
|
|
1628
|
-
|
|
4103
|
+
if (!core.getIdFromEl()(el)?.startsWith(GHOST_EL_ID_PREFIX) && await this.isContainer?.(el) && !excludeElList.includes(el)) {
|
|
4104
|
+
core.addClassName(el, doc, this.containerHighlightClassName);
|
|
1629
4105
|
break;
|
|
1630
4106
|
}
|
|
1631
4107
|
}
|
|
@@ -1643,7 +4119,7 @@
|
|
|
1643
4119
|
this.addContainerHighlightClassName(event, excludeElList);
|
|
1644
4120
|
}, this.containerHighlightDuration);
|
|
1645
4121
|
}
|
|
1646
|
-
return
|
|
4122
|
+
return undefined;
|
|
1647
4123
|
}
|
|
1648
4124
|
getDragStatus() {
|
|
1649
4125
|
return this.dr?.getDragStatus();
|
|
@@ -1732,9 +4208,9 @@
|
|
|
1732
4208
|
if (typeof options === "function") {
|
|
1733
4209
|
const cfg = {
|
|
1734
4210
|
targetEl: this.selectedEl,
|
|
1735
|
-
targetElId:
|
|
4211
|
+
targetElId: core.getIdFromEl()(this.selectedEl),
|
|
1736
4212
|
targetEls: this.selectedElList,
|
|
1737
|
-
targetElIds: this.selectedElList?.map((item) =>
|
|
4213
|
+
targetElIds: this.selectedElList?.map((item) => core.getIdFromEl()(item) || ""),
|
|
1738
4214
|
isMulti,
|
|
1739
4215
|
document: this.getRenderDocument()
|
|
1740
4216
|
};
|
|
@@ -1757,7 +4233,7 @@
|
|
|
1757
4233
|
this.selectedElList.push(this.selectedEl);
|
|
1758
4234
|
this.setSelectedEl(null);
|
|
1759
4235
|
}
|
|
1760
|
-
const existIndex = this.selectedElList.findIndex((selectedDom) =>
|
|
4236
|
+
const existIndex = this.selectedElList.findIndex((selectedDom) => core.getIdFromEl()(selectedDom) === core.getIdFromEl()(el));
|
|
1761
4237
|
if (existIndex !== -1) {
|
|
1762
4238
|
if (this.selectedElList.length > 1) {
|
|
1763
4239
|
this.selectedElList.splice(existIndex, 1);
|
|
@@ -1779,7 +4255,7 @@
|
|
|
1779
4255
|
markContainerEnd() {
|
|
1780
4256
|
const doc = this.getRenderDocument();
|
|
1781
4257
|
if (doc && this.canAddToContainer()) {
|
|
1782
|
-
return
|
|
4258
|
+
return core.removeClassNameByClassName(doc, this.containerHighlightClassName);
|
|
1783
4259
|
}
|
|
1784
4260
|
return null;
|
|
1785
4261
|
}
|
|
@@ -1843,7 +4319,7 @@
|
|
|
1843
4319
|
if (!el) return;
|
|
1844
4320
|
this.emit("before-select", el, event);
|
|
1845
4321
|
}
|
|
1846
|
-
|
|
4322
|
+
core.getDocument().addEventListener("mouseup", this.mouseUpHandler);
|
|
1847
4323
|
};
|
|
1848
4324
|
isStopTriggerSelect(event) {
|
|
1849
4325
|
if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT) return true;
|
|
@@ -1861,7 +4337,7 @@
|
|
|
1861
4337
|
* 在up事件中负责对外通知选中事件,通知画布之外的编辑器更新
|
|
1862
4338
|
*/
|
|
1863
4339
|
mouseUpHandler = (event) => {
|
|
1864
|
-
|
|
4340
|
+
core.getDocument().removeEventListener("mouseup", this.mouseUpHandler);
|
|
1865
4341
|
this.container.addEventListener("mousemove", this.mouseMoveHandler);
|
|
1866
4342
|
if (this.isMultiSelectStatus) {
|
|
1867
4343
|
this.emit("multi-select", this.selectedElList, event);
|
|
@@ -2030,9 +4506,9 @@
|
|
|
2030
4506
|
|
|
2031
4507
|
const wrapperClassName = "editor-mask-wrapper";
|
|
2032
4508
|
const hideScrollbar = () => {
|
|
2033
|
-
|
|
4509
|
+
core.injectStyle(core.getDocument(), `.${wrapperClassName}::-webkit-scrollbar { width: 0 !important; display: none }`);
|
|
2034
4510
|
};
|
|
2035
|
-
const createContent = () =>
|
|
4511
|
+
const createContent = () => core.createDiv({
|
|
2036
4512
|
className: "editor-mask",
|
|
2037
4513
|
cssText: `
|
|
2038
4514
|
position: absolute;
|
|
@@ -2042,7 +4518,7 @@
|
|
|
2042
4518
|
`
|
|
2043
4519
|
});
|
|
2044
4520
|
const createWrapper = () => {
|
|
2045
|
-
const el =
|
|
4521
|
+
const el = core.createDiv({
|
|
2046
4522
|
className: wrapperClassName,
|
|
2047
4523
|
cssText: `
|
|
2048
4524
|
position: absolute;
|
|
@@ -2340,9 +4816,9 @@
|
|
|
2340
4816
|
*/
|
|
2341
4817
|
async mount(el) {
|
|
2342
4818
|
if (this.iframe) {
|
|
2343
|
-
if (!
|
|
4819
|
+
if (!core.isSameDomain(this.runtimeUrl) && this.runtimeUrl) {
|
|
2344
4820
|
let html = await fetch(this.runtimeUrl).then((res) => res.text());
|
|
2345
|
-
const base = `${location.protocol}//${
|
|
4821
|
+
const base = `${location.protocol}//${core.getHost(this.runtimeUrl)}`;
|
|
2346
4822
|
html = html.replace("<head>", `<head>
|
|
2347
4823
|
<base href="${base}">`);
|
|
2348
4824
|
this.iframe.srcdoc = html;
|
|
@@ -2384,7 +4860,7 @@
|
|
|
2384
4860
|
return this.getDocument()?.elementsFromPoint(x / this.zoom, y / this.zoom);
|
|
2385
4861
|
}
|
|
2386
4862
|
getTargetElement(id) {
|
|
2387
|
-
return
|
|
4863
|
+
return core.getElById()(this.getDocument(), id);
|
|
2388
4864
|
}
|
|
2389
4865
|
postTmagicRuntimeReady() {
|
|
2390
4866
|
this.contentWindow = this.iframe?.contentWindow;
|
|
@@ -2403,7 +4879,7 @@
|
|
|
2403
4879
|
this.iframe?.removeEventListener("load", this.iframeLoadHandler);
|
|
2404
4880
|
this.contentWindow = null;
|
|
2405
4881
|
this.iframe?.remove();
|
|
2406
|
-
this.iframe =
|
|
4882
|
+
this.iframe = undefined;
|
|
2407
4883
|
this.removeAllListeners();
|
|
2408
4884
|
}
|
|
2409
4885
|
on(eventName, listener) {
|
|
@@ -2414,7 +4890,7 @@
|
|
|
2414
4890
|
}
|
|
2415
4891
|
createIframe() {
|
|
2416
4892
|
this.iframe = globalThis.document.createElement("iframe");
|
|
2417
|
-
this.iframe.src = this.runtimeUrl &&
|
|
4893
|
+
this.iframe.src = this.runtimeUrl && core.isSameDomain(this.runtimeUrl) ? this.runtimeUrl : "";
|
|
2418
4894
|
this.iframe.style.cssText = `
|
|
2419
4895
|
border: 0;
|
|
2420
4896
|
width: 100%;
|
|
@@ -2457,7 +4933,7 @@
|
|
|
2457
4933
|
}
|
|
2458
4934
|
}
|
|
2459
4935
|
this.emit("onload");
|
|
2460
|
-
|
|
4936
|
+
core.injectStyle(this.contentWindow.document, style);
|
|
2461
4937
|
};
|
|
2462
4938
|
}
|
|
2463
4939
|
|
|
@@ -2623,7 +5099,7 @@
|
|
|
2623
5099
|
actionManager?.destroy();
|
|
2624
5100
|
pageResizeObserver?.disconnect();
|
|
2625
5101
|
this.removeAllListeners();
|
|
2626
|
-
this.container =
|
|
5102
|
+
this.container = undefined;
|
|
2627
5103
|
this.renderer = null;
|
|
2628
5104
|
this.mask = null;
|
|
2629
5105
|
this.actionManager = null;
|
|
@@ -2700,12 +5176,12 @@
|
|
|
2700
5176
|
*/
|
|
2701
5177
|
initActionManagerEvent() {
|
|
2702
5178
|
this.actionManager?.on("before-select", (el, event) => {
|
|
2703
|
-
const id =
|
|
5179
|
+
const id = core.getIdFromEl()(el);
|
|
2704
5180
|
id && this.select(id, event);
|
|
2705
5181
|
}).on("select", (selectedEl, event) => {
|
|
2706
5182
|
this.emit("select", selectedEl, event);
|
|
2707
5183
|
}).on("before-multi-select", (els) => {
|
|
2708
|
-
this.multiSelect(els.map((el) =>
|
|
5184
|
+
this.multiSelect(els.map((el) => core.getIdFromEl()(el)).filter((id) => Boolean(id)));
|
|
2709
5185
|
}).on("multi-select", (selectedElList, event) => {
|
|
2710
5186
|
this.emit("multi-select", selectedElList, event);
|
|
2711
5187
|
}).on("dblclick", (event) => {
|