alloy 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +0 -1
- package/.eslintrc.js +2 -1
- package/.github/dependabot.yml +4 -0
- package/.github/workflows/build.yml +12 -9
- package/.github/workflows/cla.yaml +1 -1
- package/.github/workflows/publish.yml +44 -5
- package/Alloy/builtins/moment/lang/af.js +52 -42
- package/Alloy/builtins/moment/lang/ar-dz.js +151 -42
- package/Alloy/builtins/moment/lang/ar-kw.js +42 -34
- package/Alloy/builtins/moment/lang/ar-ly.js +142 -81
- package/Alloy/builtins/moment/lang/ar-ma.js +43 -34
- package/Alloy/builtins/moment/lang/ar-ps.js +123 -0
- package/Alloy/builtins/moment/lang/ar-sa.js +77 -64
- package/Alloy/builtins/moment/lang/ar-tn.js +17 -9
- package/Alloy/builtins/moment/lang/ar.js +161 -95
- package/Alloy/builtins/moment/lang/az.js +54 -45
- package/Alloy/builtins/moment/lang/be.js +73 -51
- package/Alloy/builtins/moment/lang/bg.js +50 -41
- package/Alloy/builtins/moment/lang/bm.js +43 -38
- package/Alloy/builtins/moment/lang/bn-bd.js +140 -0
- package/Alloy/builtins/moment/lang/bn.js +78 -66
- package/Alloy/builtins/moment/lang/bo.js +83 -66
- package/Alloy/builtins/moment/lang/br.js +119 -47
- package/Alloy/builtins/moment/lang/bs.js +64 -43
- package/Alloy/builtins/moment/lang/ca.js +80 -56
- package/Alloy/builtins/moment/lang/cs.js +89 -68
- package/Alloy/builtins/moment/lang/cv.js +47 -35
- package/Alloy/builtins/moment/lang/cy.js +44 -14
- package/Alloy/builtins/moment/lang/da.js +44 -39
- package/Alloy/builtins/moment/lang/de-at.js +57 -42
- package/Alloy/builtins/moment/lang/de-ch.js +54 -42
- package/Alloy/builtins/moment/lang/de.js +56 -42
- package/Alloy/builtins/moment/lang/dv.js +65 -62
- package/Alloy/builtins/moment/lang/el.js +67 -49
- package/Alloy/builtins/moment/lang/en-au.js +56 -43
- package/Alloy/builtins/moment/lang/en-ca.js +53 -40
- package/Alloy/builtins/moment/lang/en-gb.js +56 -43
- package/Alloy/builtins/moment/lang/en-ie.js +56 -43
- package/Alloy/builtins/moment/lang/en-il.js +53 -39
- package/Alloy/builtins/moment/lang/en-in.js +79 -0
- package/Alloy/builtins/moment/lang/en-nz.js +56 -43
- package/Alloy/builtins/moment/lang/en-sg.js +79 -0
- package/Alloy/builtins/moment/lang/eo.js +49 -40
- package/Alloy/builtins/moment/lang/es-do.js +81 -53
- package/Alloy/builtins/moment/lang/es-mx.js +121 -0
- package/Alloy/builtins/moment/lang/es-us.js +83 -53
- package/Alloy/builtins/moment/lang/es.js +88 -58
- package/Alloy/builtins/moment/lang/et.js +60 -50
- package/Alloy/builtins/moment/lang/eu.js +56 -45
- package/Alloy/builtins/moment/lang/fa.js +88 -69
- package/Alloy/builtins/moment/lang/fi.js +75 -48
- package/Alloy/builtins/moment/lang/fil.js +69 -0
- package/Alloy/builtins/moment/lang/fo.js +48 -39
- package/Alloy/builtins/moment/lang/fr-ca.js +46 -38
- package/Alloy/builtins/moment/lang/fr-ch.js +49 -41
- package/Alloy/builtins/moment/lang/fr.js +78 -41
- package/Alloy/builtins/moment/lang/fy.js +51 -39
- package/Alloy/builtins/moment/lang/ga.js +48 -18
- package/Alloy/builtins/moment/lang/gd.js +82 -51
- package/Alloy/builtins/moment/lang/gl.js +56 -46
- package/Alloy/builtins/moment/lang/gom-deva.js +137 -0
- package/Alloy/builtins/moment/lang/gom-latn.js +71 -58
- package/Alloy/builtins/moment/lang/gu.js +30 -20
- package/Alloy/builtins/moment/lang/he.js +52 -43
- package/Alloy/builtins/moment/lang/hi.js +120 -64
- package/Alloy/builtins/moment/lang/hr.js +57 -43
- package/Alloy/builtins/moment/lang/hu.js +64 -44
- package/Alloy/builtins/moment/lang/hy-am.js +47 -36
- package/Alloy/builtins/moment/lang/id.js +46 -40
- package/Alloy/builtins/moment/lang/is.js +63 -43
- package/Alloy/builtins/moment/lang/it-ch.js +42 -35
- package/Alloy/builtins/moment/lang/it.js +91 -42
- package/Alloy/builtins/moment/lang/ja.js +113 -45
- package/Alloy/builtins/moment/lang/jv.js +46 -40
- package/Alloy/builtins/moment/lang/ka.js +66 -51
- package/Alloy/builtins/moment/lang/kk.js +47 -40
- package/Alloy/builtins/moment/lang/km.js +37 -32
- package/Alloy/builtins/moment/lang/kn.js +74 -64
- package/Alloy/builtins/moment/lang/ko.js +50 -44
- package/Alloy/builtins/moment/lang/ku-kmr.js +125 -0
- package/Alloy/builtins/moment/lang/ku.js +94 -83
- package/Alloy/builtins/moment/lang/ky.js +49 -40
- package/Alloy/builtins/moment/lang/lb.js +43 -30
- package/Alloy/builtins/moment/lang/lo.js +46 -38
- package/Alloy/builtins/moment/lang/lt.js +82 -63
- package/Alloy/builtins/moment/lang/lv.js +60 -51
- package/Alloy/builtins/moment/lang/me.js +53 -36
- package/Alloy/builtins/moment/lang/mi.js +17 -9
- package/Alloy/builtins/moment/lang/mk.js +47 -39
- package/Alloy/builtins/moment/lang/ml.js +54 -41
- package/Alloy/builtins/moment/lang/mn.js +48 -40
- package/Alloy/builtins/moment/lang/mr.js +143 -88
- package/Alloy/builtins/moment/lang/ms-my.js +45 -39
- package/Alloy/builtins/moment/lang/ms.js +44 -39
- package/Alloy/builtins/moment/lang/mt.js +47 -39
- package/Alloy/builtins/moment/lang/my.js +40 -30
- package/Alloy/builtins/moment/lang/nb.js +46 -36
- package/Alloy/builtins/moment/lang/ne.js +75 -65
- package/Alloy/builtins/moment/lang/nl-be.js +73 -46
- package/Alloy/builtins/moment/lang/nl.js +75 -46
- package/Alloy/builtins/moment/lang/nn.js +45 -34
- package/Alloy/builtins/moment/lang/oc-lnc.js +96 -0
- package/Alloy/builtins/moment/lang/pa-in.js +73 -63
- package/Alloy/builtins/moment/lang/pl.js +69 -43
- package/Alloy/builtins/moment/lang/pt-br.js +43 -34
- package/Alloy/builtins/moment/lang/pt.js +48 -38
- package/Alloy/builtins/moment/lang/ro.js +52 -39
- package/Alloy/builtins/moment/lang/ru.js +104 -61
- package/Alloy/builtins/moment/lang/sd.js +57 -62
- package/Alloy/builtins/moment/lang/se.js +42 -33
- package/Alloy/builtins/moment/lang/si.js +50 -40
- package/Alloy/builtins/moment/lang/sk.js +54 -53
- package/Alloy/builtins/moment/lang/sl.js +51 -41
- package/Alloy/builtins/moment/lang/sq.js +50 -41
- package/Alloy/builtins/moment/lang/sr-cyrl.js +71 -43
- package/Alloy/builtins/moment/lang/sr.js +74 -44
- package/Alloy/builtins/moment/lang/ss.js +50 -42
- package/Alloy/builtins/moment/lang/sv.js +52 -41
- package/Alloy/builtins/moment/lang/sw.js +47 -39
- package/Alloy/builtins/moment/lang/ta.js +78 -64
- package/Alloy/builtins/moment/lang/te.js +54 -43
- package/Alloy/builtins/moment/lang/tet.js +51 -38
- package/Alloy/builtins/moment/lang/tg.js +51 -38
- package/Alloy/builtins/moment/lang/th.js +47 -37
- package/Alloy/builtins/moment/lang/tk.js +102 -0
- package/Alloy/builtins/moment/lang/tl-ph.js +41 -34
- package/Alloy/builtins/moment/lang/tlh.js +69 -55
- package/Alloy/builtins/moment/lang/tr.js +83 -59
- package/Alloy/builtins/moment/lang/tzl.js +67 -57
- package/Alloy/builtins/moment/lang/tzm-latn.js +41 -33
- package/Alloy/builtins/moment/lang/tzm.js +40 -32
- package/Alloy/builtins/moment/lang/ug-cn.js +13 -9
- package/Alloy/builtins/moment/lang/uk.js +82 -57
- package/Alloy/builtins/moment/lang/ur.js +58 -62
- package/Alloy/builtins/moment/lang/uz-latn.js +46 -38
- package/Alloy/builtins/moment/lang/uz.js +43 -38
- package/Alloy/builtins/moment/lang/vi.js +56 -43
- package/Alloy/builtins/moment/lang/x-pseudo.js +61 -44
- package/Alloy/builtins/moment/lang/yo.js +45 -40
- package/Alloy/builtins/moment/lang/zh-cn.js +68 -46
- package/Alloy/builtins/moment/lang/zh-hk.js +61 -51
- package/Alloy/builtins/moment/lang/zh-mo.js +111 -0
- package/Alloy/builtins/moment/lang/zh-tw.js +57 -49
- package/Alloy/builtins/moment.js +2587 -1501
- package/Alloy/commands/compile/ast/controller.js +6 -2
- package/Alloy/commands/compile/compilerUtils.js +6 -8
- package/Alloy/commands/compile/parsers/Alloy.Abstract.FixedSpace.js +2 -11
- package/Alloy/commands/compile/parsers/Alloy.Abstract.FlexSpace.js +2 -11
- package/Alloy/commands/compile/parsers/Alloy.Abstract.Option.js +2 -2
- package/Alloy/commands/compile/parsers/Alloy.Abstract._ItemContainer.js +9 -2
- package/Alloy/commands/compile/parsers/Ti.UI.Android.CollapseToolbar.ContentView.js +13 -0
- package/Alloy/commands/compile/parsers/Ti.UI.Android.CollapseToolbar._ProxyProperty.js +13 -0
- package/Alloy/commands/compile/parsers/Ti.UI.Android.CollapseToolbar.js +35 -0
- package/Alloy/commands/compile/parsers/Ti.UI.Android.DrawerLayout._ProxyProperty.js +0 -1
- package/Alloy/commands/compile/parsers/Ti.UI.AttributedString.js +0 -5
- package/Alloy/commands/compile/parsers/Ti.UI.Button.js +2 -11
- package/Alloy/commands/compile/parsers/Ti.UI.NavigationWindow.js +0 -15
- package/Alloy/commands/compile/parsers/Ti.UI.OptionBar.js +0 -5
- package/Alloy/commands/compile/parsers/Ti.UI.PickerColumn.js +1 -1
- package/Alloy/commands/compile/parsers/Ti.UI.TabbedBar.js +0 -9
- package/Alloy/commands/compile/parsers/Ti.UI.Toolbar.js +0 -6
- package/Alloy/commands/generate/targets/widget.js +1 -1
- package/Alloy/commands/info/index.js +2 -2
- package/Alloy/common/constants.js +5 -3
- package/Alloy/lib/alloy/backbone/1.6.0/backbone.js +2155 -0
- package/Alloy/lib/alloy/underscore.js +1722 -1372
- package/Alloy/template/README +3 -9
- package/Alloy/template/app.tss +5 -12
- package/Alloy/template/controller.js +1 -1
- package/Alloy/template/gitignore.txt +3 -0
- package/Alloy/template/lib/alloy.js +0 -17
- package/Alloy/template/style.tss +0 -3
- package/Alloy/template/view.xml +4 -3
- package/Alloy/template/widget/style.tss +1 -2
- package/Alloy/tiapp.js +1 -11
- package/Alloy/utils.js +1 -1
- package/CHANGELOG.md +16 -0
- package/README.md +16 -0
- package/package.json +23 -46
- package/samples/lib/testUtils.js +1 -1
- package/test/lib/testUtils.js +1 -1
- package/test/projects/HarnessTemplate/tiapp.xml +1 -15
- package/test/specs/compile.js +3 -2
- package/test/specs/compilefile.js +3 -3
- package/test/specs/new.js +1 -1
- package/test/specs/optimizer.js +10 -13
- package/Alloy/commands/compile/parsers/Ti.UI.iPhone.NavigationGroup.js +0 -58
- package/dangerfile.js +0 -20
- package/samples/apps/advanced/complex_styling/themes/mobileweb/styles/app.tss +0 -11
- package/samples/apps/advanced/complex_styling/themes/mobileweb/styles/requiredlabel.tss +0 -4
- package/samples/apps/advanced/complex_styling/views/mobileweb/label.xml +0 -3
- package/samples/apps/advanced/device_query/_generated/mobileweb/alloy/controllers/index.js +0 -60
- package/samples/apps/advanced/dynamic_styling/views/mobileweb/features/autoStyle.xml +0 -54
- package/samples/apps/advanced/form_factor/_generated/mobileweb/alloy/controllers/index.js +0 -121
- package/samples/apps/advanced/inheritance/_generated/mobileweb/alloy/controllers/animatedDialog.js +0 -44
- package/samples/apps/advanced/inheritance/_generated/mobileweb/alloy/controllers/baseDialog.js +0 -88
- package/samples/apps/advanced/inheritance/_generated/mobileweb/alloy/controllers/index.js +0 -59
- package/samples/apps/advanced/master_detail/_generated/mobileweb/alloy/controllers/detail.js +0 -102
- package/samples/apps/advanced/master_detail/_generated/mobileweb/alloy/controllers/index.js +0 -35
- package/samples/apps/advanced/master_detail/_generated/mobileweb/alloy/controllers/master.js +0 -53
- package/samples/apps/advanced/master_detail/_generated/mobileweb/alloy/controllers/row.js +0 -67
- package/samples/apps/advanced/native_modules/_generated/mobileweb/alloy/controllers/index.js +0 -37
- package/samples/apps/advanced/platform_folders/_generated/mobileweb/alloy/controllers/index.js +0 -60
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/controllers/index.js +0 -207
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/controllers/proxy.js +0 -51
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/controllers/window.js +0 -49
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/widgets/com.foo.widget/controllers/row.js +0 -46
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/widgets/com.foo.widget/controllers/row_bind.js +0 -46
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/widgets/com.foo.widget/controllers/section.js +0 -59
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/widgets/com.foo.widget/styles/row.js +0 -14
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/widgets/com.foo.widget/styles/row_bind.js +0 -14
- package/samples/apps/advanced/proxy_property_requires/_generated/mobileweb/alloy/widgets/com.foo.widget/styles/section.js +0 -14
- package/samples/apps/advanced/themes/_generated/mobileweb/alloy/controllers/dialog.js +0 -112
- package/samples/apps/advanced/themes/_generated/mobileweb/alloy/controllers/index.js +0 -118
- package/samples/apps/basics/builtins/_generated/mobileweb/alloy/controllers/index.js +0 -102
- package/samples/apps/basics/config_json/_generated/mobileweb/alloy/controllers/index.js +0 -49
- package/samples/apps/basics/controller_events/_generated/mobileweb/alloy/controllers/CustomView.js +0 -60
- package/samples/apps/basics/controller_events/_generated/mobileweb/alloy/controllers/index.js +0 -57
- package/samples/apps/basics/global_style/_generated/mobileweb/alloy/controllers/index.js +0 -40
- package/samples/apps/basics/global_style/_generated/mobileweb/alloy/controllers/item.js +0 -45
- package/samples/apps/basics/markup_events/_generated/mobileweb/alloy/controllers/index.js +0 -49
- package/samples/apps/basics/markup_require/_generated/mobileweb/alloy/controllers/bottom.js +0 -42
- package/samples/apps/basics/markup_require/_generated/mobileweb/alloy/controllers/index.js +0 -49
- package/samples/apps/basics/markup_require/_generated/mobileweb/alloy/controllers/middle.js +0 -45
- package/samples/apps/basics/markup_require/_generated/mobileweb/alloy/controllers/theRest.js +0 -41
- package/samples/apps/basics/simple/_generated/mobileweb/alloy/controllers/index.js +0 -49
- package/samples/apps/models/journal/views/mobileweb/index.xml +0 -19
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/00.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/01.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/02.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/03.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/04.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/05.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/06.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/07.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/08.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/09.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/10.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/11.png +0 -0
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/assets/mobileweb/images/spinner.png +0 -0
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('underscore', factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
|
|
5
|
+
var current = global._;
|
|
6
|
+
var exports = global._ = factory();
|
|
7
|
+
exports.noConflict = function () { global._ = current; return exports; };
|
|
8
|
+
}()));
|
|
9
|
+
}(this, (function () {
|
|
10
|
+
// Underscore.js 1.13.6
|
|
11
|
+
// https://underscorejs.org
|
|
12
|
+
// (c) 2009-2022 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
|
|
13
|
+
// Underscore may be freely distributed under the MIT license.
|
|
5
14
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Baseline setup
|
|
9
|
-
// --------------
|
|
15
|
+
// Current version.
|
|
16
|
+
var VERSION = '1.13.6';
|
|
10
17
|
|
|
11
18
|
// Establish the root object, `window` (`self`) in the browser, `global`
|
|
12
19
|
// on the server, or `this` in some virtual machines. We use `self`
|
|
13
20
|
// instead of `window` for `WebWorker` support.
|
|
14
|
-
var root = typeof self == 'object' && self.self === self && self ||
|
|
15
|
-
typeof global == 'object' && global.global === global && global ||
|
|
16
|
-
this ||
|
|
21
|
+
var root = (typeof self == 'object' && self.self === self && self) ||
|
|
22
|
+
(typeof global == 'object' && global.global === global && global) ||
|
|
23
|
+
Function('return this')() ||
|
|
17
24
|
{};
|
|
18
25
|
|
|
19
|
-
// Save the previous value of the `_` variable.
|
|
20
|
-
var previousUnderscore = root._;
|
|
21
|
-
|
|
22
26
|
// Save bytes in the minified (but not gzipped) version:
|
|
23
27
|
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
|
|
24
28
|
var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
|
|
@@ -29,87 +33,35 @@
|
|
|
29
33
|
toString = ObjProto.toString,
|
|
30
34
|
hasOwnProperty = ObjProto.hasOwnProperty;
|
|
31
35
|
|
|
32
|
-
//
|
|
36
|
+
// Modern feature detection.
|
|
37
|
+
var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined',
|
|
38
|
+
supportsDataView = typeof DataView !== 'undefined';
|
|
39
|
+
|
|
40
|
+
// All **ECMAScript 5+** native function implementations that we hope to use
|
|
33
41
|
// are declared here.
|
|
34
42
|
var nativeIsArray = Array.isArray,
|
|
35
43
|
nativeKeys = Object.keys,
|
|
36
|
-
nativeCreate = Object.create
|
|
37
|
-
|
|
38
|
-
// Naked function reference for surrogate-prototype-swapping.
|
|
39
|
-
var Ctor = function(){};
|
|
40
|
-
|
|
41
|
-
// Create a safe reference to the Underscore object for use below.
|
|
42
|
-
var _ = function(obj) {
|
|
43
|
-
if (obj instanceof _) return obj;
|
|
44
|
-
if (!(this instanceof _)) return new _(obj);
|
|
45
|
-
this._wrapped = obj;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Export the Underscore object for **Node.js**, with
|
|
49
|
-
// backwards-compatibility for their old module API. If we're in
|
|
50
|
-
// the browser, add `_` as a global object.
|
|
51
|
-
// (`nodeType` is checked to ensure that `module`
|
|
52
|
-
// and `exports` are not HTML elements.)
|
|
53
|
-
if (typeof exports != 'undefined' && !exports.nodeType) {
|
|
54
|
-
if (typeof module != 'undefined' && !module.nodeType && module.exports) {
|
|
55
|
-
exports = module.exports = _;
|
|
56
|
-
}
|
|
57
|
-
exports._ = _;
|
|
58
|
-
} else {
|
|
59
|
-
root._ = _;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Current version.
|
|
63
|
-
_.VERSION = '1.9.1';
|
|
64
|
-
|
|
65
|
-
// Internal function that returns an efficient (for current engines) version
|
|
66
|
-
// of the passed-in callback, to be repeatedly applied in other Underscore
|
|
67
|
-
// functions.
|
|
68
|
-
var optimizeCb = function(func, context, argCount) {
|
|
69
|
-
if (context === void 0) return func;
|
|
70
|
-
switch (argCount == null ? 3 : argCount) {
|
|
71
|
-
case 1: return function(value) {
|
|
72
|
-
return func.call(context, value);
|
|
73
|
-
};
|
|
74
|
-
// The 2-argument case is omitted because we’re not using it.
|
|
75
|
-
case 3: return function(value, index, collection) {
|
|
76
|
-
return func.call(context, value, index, collection);
|
|
77
|
-
};
|
|
78
|
-
case 4: return function(accumulator, value, index, collection) {
|
|
79
|
-
return func.call(context, accumulator, value, index, collection);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return function() {
|
|
83
|
-
return func.apply(context, arguments);
|
|
84
|
-
};
|
|
85
|
-
};
|
|
44
|
+
nativeCreate = Object.create,
|
|
45
|
+
nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;
|
|
86
46
|
|
|
87
|
-
|
|
47
|
+
// Create references to these builtin functions because we override them.
|
|
48
|
+
var _isNaN = isNaN,
|
|
49
|
+
_isFinite = isFinite;
|
|
88
50
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (_.iteratee !== builtinIteratee) return _.iteratee(value, context);
|
|
94
|
-
if (value == null) return _.identity;
|
|
95
|
-
if (_.isFunction(value)) return optimizeCb(value, context, argCount);
|
|
96
|
-
if (_.isObject(value) && !_.isArray(value)) return _.matcher(value);
|
|
97
|
-
return _.property(value);
|
|
98
|
-
};
|
|
51
|
+
// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
|
|
52
|
+
var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
|
|
53
|
+
var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
|
|
54
|
+
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
|
|
99
55
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
// This abstraction hides the internal-only argCount argument.
|
|
103
|
-
_.iteratee = builtinIteratee = function(value, context) {
|
|
104
|
-
return cb(value, context, Infinity);
|
|
105
|
-
};
|
|
56
|
+
// The largest integer that can be represented exactly.
|
|
57
|
+
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
|
|
106
58
|
|
|
107
59
|
// Some functions take a variable number of arguments, or a few expected
|
|
108
60
|
// arguments at the beginning and then a variable number of values to operate
|
|
109
61
|
// on. This helper accumulates all remaining arguments past the function’s
|
|
110
62
|
// argument length (or an explicit `startIndex`), into an array that becomes
|
|
111
63
|
// the last argument. Similar to ES6’s "rest parameter".
|
|
112
|
-
|
|
64
|
+
function restArguments(func, startIndex) {
|
|
113
65
|
startIndex = startIndex == null ? func.length - 1 : +startIndex;
|
|
114
66
|
return function() {
|
|
115
67
|
var length = Math.max(arguments.length - startIndex, 0),
|
|
@@ -130,659 +82,920 @@
|
|
|
130
82
|
args[startIndex] = rest;
|
|
131
83
|
return func.apply(this, args);
|
|
132
84
|
};
|
|
133
|
-
}
|
|
85
|
+
}
|
|
134
86
|
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
87
|
+
// Is a given variable an object?
|
|
88
|
+
function isObject(obj) {
|
|
89
|
+
var type = typeof obj;
|
|
90
|
+
return type === 'function' || (type === 'object' && !!obj);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Is a given value equal to null?
|
|
94
|
+
function isNull(obj) {
|
|
95
|
+
return obj === null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Is a given variable undefined?
|
|
99
|
+
function isUndefined(obj) {
|
|
100
|
+
return obj === void 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Is a given value a boolean?
|
|
104
|
+
function isBoolean(obj) {
|
|
105
|
+
return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Is a given value a DOM element?
|
|
109
|
+
function isElement(obj) {
|
|
110
|
+
return !!(obj && obj.nodeType === 1);
|
|
111
|
+
}
|
|
144
112
|
|
|
145
|
-
|
|
113
|
+
// Internal function for creating a `toString`-based type tester.
|
|
114
|
+
function tagTester(name) {
|
|
115
|
+
var tag = '[object ' + name + ']';
|
|
146
116
|
return function(obj) {
|
|
147
|
-
return obj
|
|
117
|
+
return toString.call(obj) === tag;
|
|
148
118
|
};
|
|
149
|
-
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var isString = tagTester('String');
|
|
122
|
+
|
|
123
|
+
var isNumber = tagTester('Number');
|
|
124
|
+
|
|
125
|
+
var isDate = tagTester('Date');
|
|
126
|
+
|
|
127
|
+
var isRegExp = tagTester('RegExp');
|
|
150
128
|
|
|
151
|
-
var
|
|
152
|
-
|
|
129
|
+
var isError = tagTester('Error');
|
|
130
|
+
|
|
131
|
+
var isSymbol = tagTester('Symbol');
|
|
132
|
+
|
|
133
|
+
var isArrayBuffer = tagTester('ArrayBuffer');
|
|
134
|
+
|
|
135
|
+
var isFunction = tagTester('Function');
|
|
136
|
+
|
|
137
|
+
// Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old
|
|
138
|
+
// v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
|
|
139
|
+
var nodelist = root.document && root.document.childNodes;
|
|
140
|
+
if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
|
|
141
|
+
isFunction = function(obj) {
|
|
142
|
+
return typeof obj == 'function' || false;
|
|
143
|
+
};
|
|
153
144
|
}
|
|
154
145
|
|
|
155
|
-
var
|
|
156
|
-
var length = path.length;
|
|
157
|
-
for (var i = 0; i < length; i++) {
|
|
158
|
-
if (obj == null) return void 0;
|
|
159
|
-
obj = obj[path[i]];
|
|
160
|
-
}
|
|
161
|
-
return length ? obj : void 0;
|
|
162
|
-
};
|
|
146
|
+
var isFunction$1 = isFunction;
|
|
163
147
|
|
|
164
|
-
|
|
165
|
-
// should be iterated as an array or as an object.
|
|
166
|
-
// Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
|
|
167
|
-
// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
|
|
168
|
-
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
|
|
169
|
-
var getLength = shallowProperty('length');
|
|
170
|
-
var isArrayLike = function(collection) {
|
|
171
|
-
var length = getLength(collection);
|
|
172
|
-
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
|
|
173
|
-
};
|
|
148
|
+
var hasObjectTag = tagTester('Object');
|
|
174
149
|
|
|
175
|
-
//
|
|
176
|
-
//
|
|
150
|
+
// In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`.
|
|
151
|
+
// In IE 11, the most common among them, this problem also applies to
|
|
152
|
+
// `Map`, `WeakMap` and `Set`.
|
|
153
|
+
var hasStringTagBug = (
|
|
154
|
+
supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8)))
|
|
155
|
+
),
|
|
156
|
+
isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map));
|
|
177
157
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
158
|
+
var isDataView = tagTester('DataView');
|
|
159
|
+
|
|
160
|
+
// In IE 10 - Edge 13, we need a different heuristic
|
|
161
|
+
// to determine whether an object is a `DataView`.
|
|
162
|
+
function ie10IsDataView(obj) {
|
|
163
|
+
return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView);
|
|
167
|
+
|
|
168
|
+
// Is a given value an array?
|
|
169
|
+
// Delegates to ECMA5's native `Array.isArray`.
|
|
170
|
+
var isArray = nativeIsArray || tagTester('Array');
|
|
171
|
+
|
|
172
|
+
// Internal function to check whether `key` is an own property name of `obj`.
|
|
173
|
+
function has$1(obj, key) {
|
|
174
|
+
return obj != null && hasOwnProperty.call(obj, key);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
var isArguments = tagTester('Arguments');
|
|
178
|
+
|
|
179
|
+
// Define a fallback version of the method in browsers (ahem, IE < 9), where
|
|
180
|
+
// there isn't any inspectable "Arguments" type.
|
|
181
|
+
(function() {
|
|
182
|
+
if (!isArguments(arguments)) {
|
|
183
|
+
isArguments = function(obj) {
|
|
184
|
+
return has$1(obj, 'callee');
|
|
185
|
+
};
|
|
193
186
|
}
|
|
194
|
-
|
|
195
|
-
};
|
|
187
|
+
}());
|
|
196
188
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
189
|
+
var isArguments$1 = isArguments;
|
|
190
|
+
|
|
191
|
+
// Is a given object a finite number?
|
|
192
|
+
function isFinite$1(obj) {
|
|
193
|
+
return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Is the given value `NaN`?
|
|
197
|
+
function isNaN$1(obj) {
|
|
198
|
+
return isNumber(obj) && _isNaN(obj);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Predicate-generating function. Often useful outside of Underscore.
|
|
202
|
+
function constant(value) {
|
|
203
|
+
return function() {
|
|
204
|
+
return value;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Common internal logic for `isArrayLike` and `isBufferLike`.
|
|
209
|
+
function createSizePropertyCheck(getSizeProperty) {
|
|
210
|
+
return function(collection) {
|
|
211
|
+
var sizeProperty = getSizeProperty(collection);
|
|
212
|
+
return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;
|
|
206
213
|
}
|
|
207
|
-
|
|
208
|
-
};
|
|
214
|
+
}
|
|
209
215
|
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
var reducer = function(obj, iteratee, memo, initial) {
|
|
215
|
-
var keys = !isArrayLike(obj) && _.keys(obj),
|
|
216
|
-
length = (keys || obj).length,
|
|
217
|
-
index = dir > 0 ? 0 : length - 1;
|
|
218
|
-
if (!initial) {
|
|
219
|
-
memo = obj[keys ? keys[index] : index];
|
|
220
|
-
index += dir;
|
|
221
|
-
}
|
|
222
|
-
for (; index >= 0 && index < length; index += dir) {
|
|
223
|
-
var currentKey = keys ? keys[index] : index;
|
|
224
|
-
memo = iteratee(memo, obj[currentKey], currentKey, obj);
|
|
225
|
-
}
|
|
226
|
-
return memo;
|
|
216
|
+
// Internal helper to generate a function to obtain property `key` from `obj`.
|
|
217
|
+
function shallowProperty(key) {
|
|
218
|
+
return function(obj) {
|
|
219
|
+
return obj == null ? void 0 : obj[key];
|
|
227
220
|
};
|
|
221
|
+
}
|
|
228
222
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
223
|
+
// Internal helper to obtain the `byteLength` property of an object.
|
|
224
|
+
var getByteLength = shallowProperty('byteLength');
|
|
225
|
+
|
|
226
|
+
// Internal helper to determine whether we should spend extensive checks against
|
|
227
|
+
// `ArrayBuffer` et al.
|
|
228
|
+
var isBufferLike = createSizePropertyCheck(getByteLength);
|
|
229
|
+
|
|
230
|
+
// Is a given value a typed array?
|
|
231
|
+
var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
|
|
232
|
+
function isTypedArray(obj) {
|
|
233
|
+
// `ArrayBuffer.isView` is the most future-proof, so use it when available.
|
|
234
|
+
// Otherwise, fall back on the above regular expression.
|
|
235
|
+
return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) :
|
|
236
|
+
isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);
|
|
240
|
+
|
|
241
|
+
// Internal helper to obtain the `length` property of an object.
|
|
242
|
+
var getLength = shallowProperty('length');
|
|
243
|
+
|
|
244
|
+
// Internal helper to create a simple lookup structure.
|
|
245
|
+
// `collectNonEnumProps` used to depend on `_.contains`, but this led to
|
|
246
|
+
// circular imports. `emulatedSet` is a one-off solution that only works for
|
|
247
|
+
// arrays of strings.
|
|
248
|
+
function emulatedSet(keys) {
|
|
249
|
+
var hash = {};
|
|
250
|
+
for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true;
|
|
251
|
+
return {
|
|
252
|
+
contains: function(key) { return hash[key] === true; },
|
|
253
|
+
push: function(key) {
|
|
254
|
+
hash[key] = true;
|
|
255
|
+
return keys.push(key);
|
|
256
|
+
}
|
|
232
257
|
};
|
|
233
|
-
}
|
|
258
|
+
}
|
|
234
259
|
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
|
|
260
|
+
// Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't
|
|
261
|
+
// be iterated by `for key in ...` and thus missed. Extends `keys` in place if
|
|
262
|
+
// needed.
|
|
263
|
+
function collectNonEnumProps(obj, keys) {
|
|
264
|
+
keys = emulatedSet(keys);
|
|
265
|
+
var nonEnumIdx = nonEnumerableProps.length;
|
|
266
|
+
var constructor = obj.constructor;
|
|
267
|
+
var proto = (isFunction$1(constructor) && constructor.prototype) || ObjProto;
|
|
238
268
|
|
|
239
|
-
|
|
240
|
-
|
|
269
|
+
// Constructor is a special case.
|
|
270
|
+
var prop = 'constructor';
|
|
271
|
+
if (has$1(obj, prop) && !keys.contains(prop)) keys.push(prop);
|
|
241
272
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
273
|
+
while (nonEnumIdx--) {
|
|
274
|
+
prop = nonEnumerableProps[nonEnumIdx];
|
|
275
|
+
if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) {
|
|
276
|
+
keys.push(prop);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
248
280
|
|
|
249
|
-
//
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
281
|
+
// Retrieve the names of an object's own properties.
|
|
282
|
+
// Delegates to **ECMAScript 5**'s native `Object.keys`.
|
|
283
|
+
function keys(obj) {
|
|
284
|
+
if (!isObject(obj)) return [];
|
|
285
|
+
if (nativeKeys) return nativeKeys(obj);
|
|
286
|
+
var keys = [];
|
|
287
|
+
for (var key in obj) if (has$1(obj, key)) keys.push(key);
|
|
288
|
+
// Ahem, IE < 9.
|
|
289
|
+
if (hasEnumBug) collectNonEnumProps(obj, keys);
|
|
290
|
+
return keys;
|
|
291
|
+
}
|
|
259
292
|
|
|
260
|
-
//
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
293
|
+
// Is a given array, string, or object empty?
|
|
294
|
+
// An "empty" object has no enumerable own-properties.
|
|
295
|
+
function isEmpty(obj) {
|
|
296
|
+
if (obj == null) return true;
|
|
297
|
+
// Skip the more expensive `toString`-based type checks if `obj` has no
|
|
298
|
+
// `.length`.
|
|
299
|
+
var length = getLength(obj);
|
|
300
|
+
if (typeof length == 'number' && (
|
|
301
|
+
isArray(obj) || isString(obj) || isArguments$1(obj)
|
|
302
|
+
)) return length === 0;
|
|
303
|
+
return getLength(keys(obj)) === 0;
|
|
304
|
+
}
|
|
264
305
|
|
|
265
|
-
//
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (!predicate(obj[currentKey], currentKey, obj)) return false;
|
|
306
|
+
// Returns whether an object has a given set of `key:value` pairs.
|
|
307
|
+
function isMatch(object, attrs) {
|
|
308
|
+
var _keys = keys(attrs), length = _keys.length;
|
|
309
|
+
if (object == null) return !length;
|
|
310
|
+
var obj = Object(object);
|
|
311
|
+
for (var i = 0; i < length; i++) {
|
|
312
|
+
var key = _keys[i];
|
|
313
|
+
if (attrs[key] !== obj[key] || !(key in obj)) return false;
|
|
274
314
|
}
|
|
275
315
|
return true;
|
|
276
|
-
}
|
|
316
|
+
}
|
|
277
317
|
|
|
278
|
-
//
|
|
279
|
-
//
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (predicate(obj[currentKey], currentKey, obj)) return true;
|
|
287
|
-
}
|
|
288
|
-
return false;
|
|
289
|
-
};
|
|
318
|
+
// If Underscore is called as a function, it returns a wrapped object that can
|
|
319
|
+
// be used OO-style. This wrapper holds altered versions of all functions added
|
|
320
|
+
// through `_.mixin`. Wrapped objects may be chained.
|
|
321
|
+
function _$1(obj) {
|
|
322
|
+
if (obj instanceof _$1) return obj;
|
|
323
|
+
if (!(this instanceof _$1)) return new _$1(obj);
|
|
324
|
+
this._wrapped = obj;
|
|
325
|
+
}
|
|
290
326
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return _.indexOf(obj, item, fromIndex) >= 0;
|
|
327
|
+
_$1.VERSION = VERSION;
|
|
328
|
+
|
|
329
|
+
// Extracts the result from a wrapped and chained object.
|
|
330
|
+
_$1.prototype.value = function() {
|
|
331
|
+
return this._wrapped;
|
|
297
332
|
};
|
|
298
333
|
|
|
299
|
-
//
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (_.isFunction(path)) {
|
|
303
|
-
func = path;
|
|
304
|
-
} else if (_.isArray(path)) {
|
|
305
|
-
contextPath = path.slice(0, -1);
|
|
306
|
-
path = path[path.length - 1];
|
|
307
|
-
}
|
|
308
|
-
return _.map(obj, function(context) {
|
|
309
|
-
var method = func;
|
|
310
|
-
if (!method) {
|
|
311
|
-
if (contextPath && contextPath.length) {
|
|
312
|
-
context = deepGet(context, contextPath);
|
|
313
|
-
}
|
|
314
|
-
if (context == null) return void 0;
|
|
315
|
-
method = context[path];
|
|
316
|
-
}
|
|
317
|
-
return method == null ? method : method.apply(context, args);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
334
|
+
// Provide unwrapping proxies for some methods used in engine operations
|
|
335
|
+
// such as arithmetic and JSON stringification.
|
|
336
|
+
_$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value;
|
|
320
337
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
return _.map(obj, _.property(key));
|
|
338
|
+
_$1.prototype.toString = function() {
|
|
339
|
+
return String(this._wrapped);
|
|
324
340
|
};
|
|
325
341
|
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
|
|
329
|
-
return
|
|
330
|
-
|
|
342
|
+
// Internal function to wrap or shallow-copy an ArrayBuffer,
|
|
343
|
+
// typed array or DataView to a new view, reusing the buffer.
|
|
344
|
+
function toBufferView(bufferSource) {
|
|
345
|
+
return new Uint8Array(
|
|
346
|
+
bufferSource.buffer || bufferSource,
|
|
347
|
+
bufferSource.byteOffset || 0,
|
|
348
|
+
getByteLength(bufferSource)
|
|
349
|
+
);
|
|
350
|
+
}
|
|
331
351
|
|
|
332
|
-
//
|
|
333
|
-
|
|
334
|
-
_.findWhere = function(obj, attrs) {
|
|
335
|
-
return _.find(obj, _.matcher(attrs));
|
|
336
|
-
};
|
|
352
|
+
// We use this string twice, so give it a name for minification.
|
|
353
|
+
var tagDataView = '[object DataView]';
|
|
337
354
|
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
355
|
+
// Internal recursive comparison function for `_.isEqual`.
|
|
356
|
+
function eq(a, b, aStack, bStack) {
|
|
357
|
+
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
|
358
|
+
// See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal).
|
|
359
|
+
if (a === b) return a !== 0 || 1 / a === 1 / b;
|
|
360
|
+
// `null` or `undefined` only equal to itself (strict comparison).
|
|
361
|
+
if (a == null || b == null) return false;
|
|
362
|
+
// `NaN`s are equivalent, but non-reflexive.
|
|
363
|
+
if (a !== a) return b !== b;
|
|
364
|
+
// Exhaust primitive checks
|
|
365
|
+
var type = typeof a;
|
|
366
|
+
if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
|
|
367
|
+
return deepEq(a, b, aStack, bStack);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Internal recursive comparison function for `_.isEqual`.
|
|
371
|
+
function deepEq(a, b, aStack, bStack) {
|
|
372
|
+
// Unwrap any wrapped objects.
|
|
373
|
+
if (a instanceof _$1) a = a._wrapped;
|
|
374
|
+
if (b instanceof _$1) b = b._wrapped;
|
|
375
|
+
// Compare `[[Class]]` names.
|
|
376
|
+
var className = toString.call(a);
|
|
377
|
+
if (className !== toString.call(b)) return false;
|
|
378
|
+
// Work around a bug in IE 10 - Edge 13.
|
|
379
|
+
if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) {
|
|
380
|
+
if (!isDataView$1(b)) return false;
|
|
381
|
+
className = tagDataView;
|
|
382
|
+
}
|
|
383
|
+
switch (className) {
|
|
384
|
+
// These types are compared by value.
|
|
385
|
+
case '[object RegExp]':
|
|
386
|
+
// RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
|
|
387
|
+
case '[object String]':
|
|
388
|
+
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
|
|
389
|
+
// equivalent to `new String("5")`.
|
|
390
|
+
return '' + a === '' + b;
|
|
391
|
+
case '[object Number]':
|
|
392
|
+
// `NaN`s are equivalent, but non-reflexive.
|
|
393
|
+
// Object(NaN) is equivalent to NaN.
|
|
394
|
+
if (+a !== +a) return +b !== +b;
|
|
395
|
+
// An `egal` comparison is performed for other numeric values.
|
|
396
|
+
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
|
|
397
|
+
case '[object Date]':
|
|
398
|
+
case '[object Boolean]':
|
|
399
|
+
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
|
|
400
|
+
// millisecond representations. Note that invalid dates with millisecond representations
|
|
401
|
+
// of `NaN` are not equivalent.
|
|
402
|
+
return +a === +b;
|
|
403
|
+
case '[object Symbol]':
|
|
404
|
+
return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
|
|
405
|
+
case '[object ArrayBuffer]':
|
|
406
|
+
case tagDataView:
|
|
407
|
+
// Coerce to typed array so we can fall through.
|
|
408
|
+
return deepEq(toBufferView(a), toBufferView(b), aStack, bStack);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
var areArrays = className === '[object Array]';
|
|
412
|
+
if (!areArrays && isTypedArray$1(a)) {
|
|
413
|
+
var byteLength = getByteLength(a);
|
|
414
|
+
if (byteLength !== getByteLength(b)) return false;
|
|
415
|
+
if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true;
|
|
416
|
+
areArrays = true;
|
|
417
|
+
}
|
|
418
|
+
if (!areArrays) {
|
|
419
|
+
if (typeof a != 'object' || typeof b != 'object') return false;
|
|
420
|
+
|
|
421
|
+
// Objects with different constructors are not equivalent, but `Object`s or `Array`s
|
|
422
|
+
// from different frames are.
|
|
423
|
+
var aCtor = a.constructor, bCtor = b.constructor;
|
|
424
|
+
if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor &&
|
|
425
|
+
isFunction$1(bCtor) && bCtor instanceof bCtor)
|
|
426
|
+
&& ('constructor' in a && 'constructor' in b)) {
|
|
427
|
+
return false;
|
|
349
428
|
}
|
|
350
|
-
} else {
|
|
351
|
-
iteratee = cb(iteratee, context);
|
|
352
|
-
_.each(obj, function(v, index, list) {
|
|
353
|
-
computed = iteratee(v, index, list);
|
|
354
|
-
if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
|
|
355
|
-
result = v;
|
|
356
|
-
lastComputed = computed;
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
429
|
}
|
|
360
|
-
|
|
361
|
-
|
|
430
|
+
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
|
431
|
+
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
|
362
432
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
433
|
+
// Initializing stack of traversed objects.
|
|
434
|
+
// It's done here since we only need them for objects and arrays comparison.
|
|
435
|
+
aStack = aStack || [];
|
|
436
|
+
bStack = bStack || [];
|
|
437
|
+
var length = aStack.length;
|
|
438
|
+
while (length--) {
|
|
439
|
+
// Linear search. Performance is inversely proportional to the number of
|
|
440
|
+
// unique nested structures.
|
|
441
|
+
if (aStack[length] === a) return bStack[length] === b;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Add the first object to the stack of traversed objects.
|
|
445
|
+
aStack.push(a);
|
|
446
|
+
bStack.push(b);
|
|
447
|
+
|
|
448
|
+
// Recursively compare objects and arrays.
|
|
449
|
+
if (areArrays) {
|
|
450
|
+
// Compare array lengths to determine if a deep comparison is necessary.
|
|
451
|
+
length = a.length;
|
|
452
|
+
if (length !== b.length) return false;
|
|
453
|
+
// Deep compare the contents, ignoring non-numeric properties.
|
|
454
|
+
while (length--) {
|
|
455
|
+
if (!eq(a[length], b[length], aStack, bStack)) return false;
|
|
374
456
|
}
|
|
375
457
|
} else {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
458
|
+
// Deep compare objects.
|
|
459
|
+
var _keys = keys(a), key;
|
|
460
|
+
length = _keys.length;
|
|
461
|
+
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
|
462
|
+
if (keys(b).length !== length) return false;
|
|
463
|
+
while (length--) {
|
|
464
|
+
// Deep compare each member
|
|
465
|
+
key = _keys[length];
|
|
466
|
+
if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
|
|
467
|
+
}
|
|
384
468
|
}
|
|
385
|
-
|
|
386
|
-
|
|
469
|
+
// Remove the first object from the stack of traversed objects.
|
|
470
|
+
aStack.pop();
|
|
471
|
+
bStack.pop();
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
387
474
|
|
|
388
|
-
//
|
|
389
|
-
|
|
390
|
-
return
|
|
391
|
-
}
|
|
475
|
+
// Perform a deep comparison to check if two objects are equal.
|
|
476
|
+
function isEqual(a, b) {
|
|
477
|
+
return eq(a, b);
|
|
478
|
+
}
|
|
392
479
|
|
|
393
|
-
//
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
480
|
+
// Retrieve all the enumerable property names of an object.
|
|
481
|
+
function allKeys(obj) {
|
|
482
|
+
if (!isObject(obj)) return [];
|
|
483
|
+
var keys = [];
|
|
484
|
+
for (var key in obj) keys.push(key);
|
|
485
|
+
// Ahem, IE < 9.
|
|
486
|
+
if (hasEnumBug) collectNonEnumProps(obj, keys);
|
|
487
|
+
return keys;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Since the regular `Object.prototype.toString` type tests don't work for
|
|
491
|
+
// some types in IE 11, we use a fingerprinting heuristic instead, based
|
|
492
|
+
// on the methods. It's not great, but it's the best we got.
|
|
493
|
+
// The fingerprint method lists are defined below.
|
|
494
|
+
function ie11fingerprint(methods) {
|
|
495
|
+
var length = getLength(methods);
|
|
496
|
+
return function(obj) {
|
|
497
|
+
if (obj == null) return false;
|
|
498
|
+
// `Map`, `WeakMap` and `Set` have no enumerable keys.
|
|
499
|
+
var keys = allKeys(obj);
|
|
500
|
+
if (getLength(keys)) return false;
|
|
501
|
+
for (var i = 0; i < length; i++) {
|
|
502
|
+
if (!isFunction$1(obj[methods[i]])) return false;
|
|
503
|
+
}
|
|
504
|
+
// If we are testing against `WeakMap`, we need to ensure that
|
|
505
|
+
// `obj` doesn't have a `forEach` method in order to distinguish
|
|
506
|
+
// it from a regular `Map`.
|
|
507
|
+
return methods !== weakMapMethods || !isFunction$1(obj[forEachName]);
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// In the interest of compact minification, we write
|
|
512
|
+
// each string in the fingerprints only once.
|
|
513
|
+
var forEachName = 'forEach',
|
|
514
|
+
hasName = 'has',
|
|
515
|
+
commonInit = ['clear', 'delete'],
|
|
516
|
+
mapTail = ['get', hasName, 'set'];
|
|
517
|
+
|
|
518
|
+
// `Map`, `WeakMap` and `Set` each have slightly different
|
|
519
|
+
// combinations of the above sublists.
|
|
520
|
+
var mapMethods = commonInit.concat(forEachName, mapTail),
|
|
521
|
+
weakMapMethods = commonInit.concat(mapTail),
|
|
522
|
+
setMethods = ['add'].concat(commonInit, forEachName, hasName);
|
|
523
|
+
|
|
524
|
+
var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map');
|
|
525
|
+
|
|
526
|
+
var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap');
|
|
527
|
+
|
|
528
|
+
var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set');
|
|
529
|
+
|
|
530
|
+
var isWeakSet = tagTester('WeakSet');
|
|
531
|
+
|
|
532
|
+
// Retrieve the values of an object's properties.
|
|
533
|
+
function values(obj) {
|
|
534
|
+
var _keys = keys(obj);
|
|
535
|
+
var length = _keys.length;
|
|
536
|
+
var values = Array(length);
|
|
537
|
+
for (var i = 0; i < length; i++) {
|
|
538
|
+
values[i] = obj[_keys[i]];
|
|
401
539
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
540
|
+
return values;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// Convert an object into a list of `[key, value]` pairs.
|
|
544
|
+
// The opposite of `_.object` with one argument.
|
|
545
|
+
function pairs(obj) {
|
|
546
|
+
var _keys = keys(obj);
|
|
547
|
+
var length = _keys.length;
|
|
548
|
+
var pairs = Array(length);
|
|
549
|
+
for (var i = 0; i < length; i++) {
|
|
550
|
+
pairs[i] = [_keys[i], obj[_keys[i]]];
|
|
411
551
|
}
|
|
412
|
-
return
|
|
413
|
-
}
|
|
552
|
+
return pairs;
|
|
553
|
+
}
|
|
414
554
|
|
|
415
|
-
//
|
|
416
|
-
|
|
417
|
-
var
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
};
|
|
425
|
-
}).sort(function(left, right) {
|
|
426
|
-
var a = left.criteria;
|
|
427
|
-
var b = right.criteria;
|
|
428
|
-
if (a !== b) {
|
|
429
|
-
if (a > b || a === void 0) return 1;
|
|
430
|
-
if (a < b || b === void 0) return -1;
|
|
431
|
-
}
|
|
432
|
-
return left.index - right.index;
|
|
433
|
-
}), 'value');
|
|
434
|
-
};
|
|
555
|
+
// Invert the keys and values of an object. The values must be serializable.
|
|
556
|
+
function invert(obj) {
|
|
557
|
+
var result = {};
|
|
558
|
+
var _keys = keys(obj);
|
|
559
|
+
for (var i = 0, length = _keys.length; i < length; i++) {
|
|
560
|
+
result[obj[_keys[i]]] = _keys[i];
|
|
561
|
+
}
|
|
562
|
+
return result;
|
|
563
|
+
}
|
|
435
564
|
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
565
|
+
// Return a sorted list of the function names available on the object.
|
|
566
|
+
function functions(obj) {
|
|
567
|
+
var names = [];
|
|
568
|
+
for (var key in obj) {
|
|
569
|
+
if (isFunction$1(obj[key])) names.push(key);
|
|
570
|
+
}
|
|
571
|
+
return names.sort();
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// An internal function for creating assigner functions.
|
|
575
|
+
function createAssigner(keysFunc, defaults) {
|
|
576
|
+
return function(obj) {
|
|
577
|
+
var length = arguments.length;
|
|
578
|
+
if (defaults) obj = Object(obj);
|
|
579
|
+
if (length < 2 || obj == null) return obj;
|
|
580
|
+
for (var index = 1; index < length; index++) {
|
|
581
|
+
var source = arguments[index],
|
|
582
|
+
keys = keysFunc(source),
|
|
583
|
+
l = keys.length;
|
|
584
|
+
for (var i = 0; i < l; i++) {
|
|
585
|
+
var key = keys[i];
|
|
586
|
+
if (!defaults || obj[key] === void 0) obj[key] = source[key];
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return obj;
|
|
446
590
|
};
|
|
447
|
-
}
|
|
591
|
+
}
|
|
448
592
|
|
|
449
|
-
//
|
|
450
|
-
|
|
451
|
-
_.groupBy = group(function(result, value, key) {
|
|
452
|
-
if (has(result, key)) result[key].push(value); else result[key] = [value];
|
|
453
|
-
});
|
|
593
|
+
// Extend a given object with all the properties in passed-in object(s).
|
|
594
|
+
var extend = createAssigner(allKeys);
|
|
454
595
|
|
|
455
|
-
//
|
|
456
|
-
//
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
});
|
|
596
|
+
// Assigns a given object with all the own properties in the passed-in
|
|
597
|
+
// object(s).
|
|
598
|
+
// (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
|
|
599
|
+
var extendOwn = createAssigner(keys);
|
|
460
600
|
|
|
461
|
-
//
|
|
462
|
-
|
|
463
|
-
// criterion.
|
|
464
|
-
_.countBy = group(function(result, value, key) {
|
|
465
|
-
if (has(result, key)) result[key]++; else result[key] = 1;
|
|
466
|
-
});
|
|
601
|
+
// Fill in a given object with default properties.
|
|
602
|
+
var defaults = createAssigner(allKeys, true);
|
|
467
603
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
604
|
+
// Create a naked function reference for surrogate-prototype-swapping.
|
|
605
|
+
function ctor() {
|
|
606
|
+
return function(){};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// An internal function for creating a new object that inherits from another.
|
|
610
|
+
function baseCreate(prototype) {
|
|
611
|
+
if (!isObject(prototype)) return {};
|
|
612
|
+
if (nativeCreate) return nativeCreate(prototype);
|
|
613
|
+
var Ctor = ctor();
|
|
614
|
+
Ctor.prototype = prototype;
|
|
615
|
+
var result = new Ctor;
|
|
616
|
+
Ctor.prototype = null;
|
|
617
|
+
return result;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// Creates an object that inherits from the given prototype object.
|
|
621
|
+
// If additional properties are provided then they will be added to the
|
|
622
|
+
// created object.
|
|
623
|
+
function create(prototype, props) {
|
|
624
|
+
var result = baseCreate(prototype);
|
|
625
|
+
if (props) extendOwn(result, props);
|
|
626
|
+
return result;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// Create a (shallow-cloned) duplicate of an object.
|
|
630
|
+
function clone(obj) {
|
|
631
|
+
if (!isObject(obj)) return obj;
|
|
632
|
+
return isArray(obj) ? obj.slice() : extend({}, obj);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// Invokes `interceptor` with the `obj` and then returns `obj`.
|
|
636
|
+
// The primary purpose of this method is to "tap into" a method chain, in
|
|
637
|
+
// order to perform operations on intermediate results within the chain.
|
|
638
|
+
function tap(obj, interceptor) {
|
|
639
|
+
interceptor(obj);
|
|
640
|
+
return obj;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// Normalize a (deep) property `path` to array.
|
|
644
|
+
// Like `_.iteratee`, this function can be customized.
|
|
645
|
+
function toPath$1(path) {
|
|
646
|
+
return isArray(path) ? path : [path];
|
|
647
|
+
}
|
|
648
|
+
_$1.toPath = toPath$1;
|
|
649
|
+
|
|
650
|
+
// Internal wrapper for `_.toPath` to enable minification.
|
|
651
|
+
// Similar to `cb` for `_.iteratee`.
|
|
652
|
+
function toPath(path) {
|
|
653
|
+
return _$1.toPath(path);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// Internal function to obtain a nested property in `obj` along `path`.
|
|
657
|
+
function deepGet(obj, path) {
|
|
658
|
+
var length = path.length;
|
|
659
|
+
for (var i = 0; i < length; i++) {
|
|
660
|
+
if (obj == null) return void 0;
|
|
661
|
+
obj = obj[path[i]];
|
|
476
662
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
};
|
|
663
|
+
return length ? obj : void 0;
|
|
664
|
+
}
|
|
480
665
|
|
|
481
|
-
//
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
666
|
+
// Get the value of the (deep) property on `path` from `object`.
|
|
667
|
+
// If any property in `path` does not exist or if the value is
|
|
668
|
+
// `undefined`, return `defaultValue` instead.
|
|
669
|
+
// The `path` is normalized through `_.toPath`.
|
|
670
|
+
function get(object, path, defaultValue) {
|
|
671
|
+
var value = deepGet(object, toPath(path));
|
|
672
|
+
return isUndefined(value) ? defaultValue : value;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Shortcut function for checking if an object has a given property directly on
|
|
676
|
+
// itself (in other words, not on a prototype). Unlike the internal `has`
|
|
677
|
+
// function, this public version can also traverse nested properties.
|
|
678
|
+
function has(obj, path) {
|
|
679
|
+
path = toPath(path);
|
|
680
|
+
var length = path.length;
|
|
681
|
+
for (var i = 0; i < length; i++) {
|
|
682
|
+
var key = path[i];
|
|
683
|
+
if (!has$1(obj, key)) return false;
|
|
684
|
+
obj = obj[key];
|
|
685
|
+
}
|
|
686
|
+
return !!length;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// Keep the identity function around for default iteratees.
|
|
690
|
+
function identity(value) {
|
|
691
|
+
return value;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// Returns a predicate for checking whether an object has a given set of
|
|
695
|
+
// `key:value` pairs.
|
|
696
|
+
function matcher(attrs) {
|
|
697
|
+
attrs = extendOwn({}, attrs);
|
|
698
|
+
return function(obj) {
|
|
699
|
+
return isMatch(obj, attrs);
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// Creates a function that, when passed an object, will traverse that object’s
|
|
704
|
+
// properties down the given `path`, specified as an array of keys or indices.
|
|
705
|
+
function property(path) {
|
|
706
|
+
path = toPath(path);
|
|
707
|
+
return function(obj) {
|
|
708
|
+
return deepGet(obj, path);
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// Internal function that returns an efficient (for current engines) version
|
|
713
|
+
// of the passed-in callback, to be repeatedly applied in other Underscore
|
|
714
|
+
// functions.
|
|
715
|
+
function optimizeCb(func, context, argCount) {
|
|
716
|
+
if (context === void 0) return func;
|
|
717
|
+
switch (argCount == null ? 3 : argCount) {
|
|
718
|
+
case 1: return function(value) {
|
|
719
|
+
return func.call(context, value);
|
|
720
|
+
};
|
|
721
|
+
// The 2-argument case is omitted because we’re not using it.
|
|
722
|
+
case 3: return function(value, index, collection) {
|
|
723
|
+
return func.call(context, value, index, collection);
|
|
724
|
+
};
|
|
725
|
+
case 4: return function(accumulator, value, index, collection) {
|
|
726
|
+
return func.call(context, accumulator, value, index, collection);
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
return function() {
|
|
730
|
+
return func.apply(context, arguments);
|
|
731
|
+
};
|
|
732
|
+
}
|
|
486
733
|
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
734
|
+
// An internal function to generate callbacks that can be applied to each
|
|
735
|
+
// element in a collection, returning the desired result — either `_.identity`,
|
|
736
|
+
// an arbitrary callback, a property matcher, or a property accessor.
|
|
737
|
+
function baseIteratee(value, context, argCount) {
|
|
738
|
+
if (value == null) return identity;
|
|
739
|
+
if (isFunction$1(value)) return optimizeCb(value, context, argCount);
|
|
740
|
+
if (isObject(value) && !isArray(value)) return matcher(value);
|
|
741
|
+
return property(value);
|
|
742
|
+
}
|
|
492
743
|
|
|
493
|
-
//
|
|
494
|
-
//
|
|
744
|
+
// External wrapper for our callback generator. Users may customize
|
|
745
|
+
// `_.iteratee` if they want additional predicate/iteratee shorthand styles.
|
|
746
|
+
// This abstraction hides the internal-only `argCount` argument.
|
|
747
|
+
function iteratee(value, context) {
|
|
748
|
+
return baseIteratee(value, context, Infinity);
|
|
749
|
+
}
|
|
750
|
+
_$1.iteratee = iteratee;
|
|
495
751
|
|
|
496
|
-
//
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return _.initial(array, array.length - n);
|
|
503
|
-
};
|
|
752
|
+
// The function we call internally to generate a callback. It invokes
|
|
753
|
+
// `_.iteratee` if overridden, otherwise `baseIteratee`.
|
|
754
|
+
function cb(value, context, argCount) {
|
|
755
|
+
if (_$1.iteratee !== iteratee) return _$1.iteratee(value, context);
|
|
756
|
+
return baseIteratee(value, context, argCount);
|
|
757
|
+
}
|
|
504
758
|
|
|
505
|
-
// Returns
|
|
506
|
-
//
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
759
|
+
// Returns the results of applying the `iteratee` to each element of `obj`.
|
|
760
|
+
// In contrast to `_.map` it returns an object.
|
|
761
|
+
function mapObject(obj, iteratee, context) {
|
|
762
|
+
iteratee = cb(iteratee, context);
|
|
763
|
+
var _keys = keys(obj),
|
|
764
|
+
length = _keys.length,
|
|
765
|
+
results = {};
|
|
766
|
+
for (var index = 0; index < length; index++) {
|
|
767
|
+
var currentKey = _keys[index];
|
|
768
|
+
results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
|
|
769
|
+
}
|
|
770
|
+
return results;
|
|
771
|
+
}
|
|
511
772
|
|
|
512
|
-
//
|
|
513
|
-
|
|
514
|
-
_.last = function(array, n, guard) {
|
|
515
|
-
if (array == null || array.length < 1) return n == null ? void 0 : [];
|
|
516
|
-
if (n == null || guard) return array[array.length - 1];
|
|
517
|
-
return _.rest(array, Math.max(0, array.length - n));
|
|
518
|
-
};
|
|
773
|
+
// Predicate-generating function. Often useful outside of Underscore.
|
|
774
|
+
function noop(){}
|
|
519
775
|
|
|
520
|
-
//
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
776
|
+
// Generates a function for a given object that returns a given property.
|
|
777
|
+
function propertyOf(obj) {
|
|
778
|
+
if (obj == null) return noop;
|
|
779
|
+
return function(path) {
|
|
780
|
+
return get(obj, path);
|
|
781
|
+
};
|
|
782
|
+
}
|
|
526
783
|
|
|
527
|
-
//
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
784
|
+
// Run a function **n** times.
|
|
785
|
+
function times(n, iteratee, context) {
|
|
786
|
+
var accum = Array(Math.max(0, n));
|
|
787
|
+
iteratee = optimizeCb(iteratee, context, 1);
|
|
788
|
+
for (var i = 0; i < n; i++) accum[i] = iteratee(i);
|
|
789
|
+
return accum;
|
|
790
|
+
}
|
|
531
791
|
|
|
532
|
-
//
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
var value = input[i];
|
|
538
|
-
if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
|
|
539
|
-
// Flatten current level of array or arguments object.
|
|
540
|
-
if (shallow) {
|
|
541
|
-
var j = 0, len = value.length;
|
|
542
|
-
while (j < len) output[idx++] = value[j++];
|
|
543
|
-
} else {
|
|
544
|
-
flatten(value, shallow, strict, output);
|
|
545
|
-
idx = output.length;
|
|
546
|
-
}
|
|
547
|
-
} else if (!strict) {
|
|
548
|
-
output[idx++] = value;
|
|
549
|
-
}
|
|
792
|
+
// Return a random integer between `min` and `max` (inclusive).
|
|
793
|
+
function random(min, max) {
|
|
794
|
+
if (max == null) {
|
|
795
|
+
max = min;
|
|
796
|
+
min = 0;
|
|
550
797
|
}
|
|
551
|
-
return
|
|
552
|
-
}
|
|
798
|
+
return min + Math.floor(Math.random() * (max - min + 1));
|
|
799
|
+
}
|
|
553
800
|
|
|
554
|
-
//
|
|
555
|
-
|
|
556
|
-
return
|
|
801
|
+
// A (possibly faster) way to get the current timestamp as an integer.
|
|
802
|
+
var now = Date.now || function() {
|
|
803
|
+
return new Date().getTime();
|
|
557
804
|
};
|
|
558
805
|
|
|
559
|
-
//
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
806
|
+
// Internal helper to generate functions for escaping and unescaping strings
|
|
807
|
+
// to/from HTML interpolation.
|
|
808
|
+
function createEscaper(map) {
|
|
809
|
+
var escaper = function(match) {
|
|
810
|
+
return map[match];
|
|
811
|
+
};
|
|
812
|
+
// Regexes for identifying a key that needs to be escaped.
|
|
813
|
+
var source = '(?:' + keys(map).join('|') + ')';
|
|
814
|
+
var testRegexp = RegExp(source);
|
|
815
|
+
var replaceRegexp = RegExp(source, 'g');
|
|
816
|
+
return function(string) {
|
|
817
|
+
string = string == null ? '' : '' + string;
|
|
818
|
+
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
|
|
819
|
+
};
|
|
820
|
+
}
|
|
563
821
|
|
|
564
|
-
//
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
context = iteratee;
|
|
573
|
-
iteratee = isSorted;
|
|
574
|
-
isSorted = false;
|
|
575
|
-
}
|
|
576
|
-
if (iteratee != null) iteratee = cb(iteratee, context);
|
|
577
|
-
var result = [];
|
|
578
|
-
var seen = [];
|
|
579
|
-
for (var i = 0, length = getLength(array); i < length; i++) {
|
|
580
|
-
var value = array[i],
|
|
581
|
-
computed = iteratee ? iteratee(value, i, array) : value;
|
|
582
|
-
if (isSorted && !iteratee) {
|
|
583
|
-
if (!i || seen !== computed) result.push(value);
|
|
584
|
-
seen = computed;
|
|
585
|
-
} else if (iteratee) {
|
|
586
|
-
if (!_.contains(seen, computed)) {
|
|
587
|
-
seen.push(computed);
|
|
588
|
-
result.push(value);
|
|
589
|
-
}
|
|
590
|
-
} else if (!_.contains(result, value)) {
|
|
591
|
-
result.push(value);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
return result;
|
|
822
|
+
// Internal list of HTML entities for escaping.
|
|
823
|
+
var escapeMap = {
|
|
824
|
+
'&': '&',
|
|
825
|
+
'<': '<',
|
|
826
|
+
'>': '>',
|
|
827
|
+
'"': '"',
|
|
828
|
+
"'": ''',
|
|
829
|
+
'`': '`'
|
|
595
830
|
};
|
|
596
831
|
|
|
597
|
-
//
|
|
598
|
-
|
|
599
|
-
_.union = restArguments(function(arrays) {
|
|
600
|
-
return _.uniq(flatten(arrays, true, true));
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
// Produce an array that contains every item shared between all the
|
|
604
|
-
// passed-in arrays.
|
|
605
|
-
_.intersection = function(array) {
|
|
606
|
-
var result = [];
|
|
607
|
-
var argsLength = arguments.length;
|
|
608
|
-
for (var i = 0, length = getLength(array); i < length; i++) {
|
|
609
|
-
var item = array[i];
|
|
610
|
-
if (_.contains(result, item)) continue;
|
|
611
|
-
var j;
|
|
612
|
-
for (j = 1; j < argsLength; j++) {
|
|
613
|
-
if (!_.contains(arguments[j], item)) break;
|
|
614
|
-
}
|
|
615
|
-
if (j === argsLength) result.push(item);
|
|
616
|
-
}
|
|
617
|
-
return result;
|
|
618
|
-
};
|
|
832
|
+
// Function for escaping strings to HTML interpolation.
|
|
833
|
+
var _escape = createEscaper(escapeMap);
|
|
619
834
|
|
|
620
|
-
//
|
|
621
|
-
|
|
622
|
-
_.difference = restArguments(function(array, rest) {
|
|
623
|
-
rest = flatten(rest, true, true);
|
|
624
|
-
return _.filter(array, function(value){
|
|
625
|
-
return !_.contains(rest, value);
|
|
626
|
-
});
|
|
627
|
-
});
|
|
835
|
+
// Internal list of HTML entities for unescaping.
|
|
836
|
+
var unescapeMap = invert(escapeMap);
|
|
628
837
|
|
|
629
|
-
//
|
|
630
|
-
|
|
631
|
-
_.unzip = function(array) {
|
|
632
|
-
var length = array && _.max(array, getLength).length || 0;
|
|
633
|
-
var result = Array(length);
|
|
838
|
+
// Function for unescaping strings from HTML interpolation.
|
|
839
|
+
var _unescape = createEscaper(unescapeMap);
|
|
634
840
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
841
|
+
// By default, Underscore uses ERB-style template delimiters. Change the
|
|
842
|
+
// following template settings to use alternative delimiters.
|
|
843
|
+
var templateSettings = _$1.templateSettings = {
|
|
844
|
+
evaluate: /<%([\s\S]+?)%>/g,
|
|
845
|
+
interpolate: /<%=([\s\S]+?)%>/g,
|
|
846
|
+
escape: /<%-([\s\S]+?)%>/g
|
|
639
847
|
};
|
|
640
848
|
|
|
641
|
-
//
|
|
642
|
-
//
|
|
643
|
-
|
|
849
|
+
// When customizing `_.templateSettings`, if you don't want to define an
|
|
850
|
+
// interpolation, evaluation or escaping regex, we need one that is
|
|
851
|
+
// guaranteed not to match.
|
|
852
|
+
var noMatch = /(.)^/;
|
|
644
853
|
|
|
645
|
-
//
|
|
646
|
-
//
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
result[list[i][0]] = list[i][1];
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
return result;
|
|
854
|
+
// Certain characters need to be escaped so that they can be put into a
|
|
855
|
+
// string literal.
|
|
856
|
+
var escapes = {
|
|
857
|
+
"'": "'",
|
|
858
|
+
'\\': '\\',
|
|
859
|
+
'\r': 'r',
|
|
860
|
+
'\n': 'n',
|
|
861
|
+
'\u2028': 'u2028',
|
|
862
|
+
'\u2029': 'u2029'
|
|
658
863
|
};
|
|
659
864
|
|
|
660
|
-
|
|
661
|
-
var createPredicateIndexFinder = function(dir) {
|
|
662
|
-
return function(array, predicate, context) {
|
|
663
|
-
predicate = cb(predicate, context);
|
|
664
|
-
var length = getLength(array);
|
|
665
|
-
var index = dir > 0 ? 0 : length - 1;
|
|
666
|
-
for (; index >= 0 && index < length; index += dir) {
|
|
667
|
-
if (predicate(array[index], index, array)) return index;
|
|
668
|
-
}
|
|
669
|
-
return -1;
|
|
670
|
-
};
|
|
671
|
-
};
|
|
865
|
+
var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
|
|
672
866
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
867
|
+
function escapeChar(match) {
|
|
868
|
+
return '\\' + escapes[match];
|
|
869
|
+
}
|
|
676
870
|
|
|
677
|
-
//
|
|
678
|
-
//
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
while (low < high) {
|
|
684
|
-
var mid = Math.floor((low + high) / 2);
|
|
685
|
-
if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
|
|
686
|
-
}
|
|
687
|
-
return low;
|
|
688
|
-
};
|
|
871
|
+
// In order to prevent third-party code injection through
|
|
872
|
+
// `_.templateSettings.variable`, we test it against the following regular
|
|
873
|
+
// expression. It is intentionally a bit more liberal than just matching valid
|
|
874
|
+
// identifiers, but still prevents possible loopholes through defaults or
|
|
875
|
+
// destructuring assignment.
|
|
876
|
+
var bareIdentifier = /^\s*(\w|\$)+\s*$/;
|
|
689
877
|
|
|
690
|
-
//
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
878
|
+
// JavaScript micro-templating, similar to John Resig's implementation.
|
|
879
|
+
// Underscore templating handles arbitrary delimiters, preserves whitespace,
|
|
880
|
+
// and correctly escapes quotes within interpolated code.
|
|
881
|
+
// NB: `oldSettings` only exists for backwards compatibility.
|
|
882
|
+
function template(text, settings, oldSettings) {
|
|
883
|
+
if (!settings && oldSettings) settings = oldSettings;
|
|
884
|
+
settings = defaults({}, settings, _$1.templateSettings);
|
|
885
|
+
|
|
886
|
+
// Combine delimiters into one regular expression via alternation.
|
|
887
|
+
var matcher = RegExp([
|
|
888
|
+
(settings.escape || noMatch).source,
|
|
889
|
+
(settings.interpolate || noMatch).source,
|
|
890
|
+
(settings.evaluate || noMatch).source
|
|
891
|
+
].join('|') + '|$', 'g');
|
|
892
|
+
|
|
893
|
+
// Compile the template source, escaping string literals appropriately.
|
|
894
|
+
var index = 0;
|
|
895
|
+
var source = "__p+='";
|
|
896
|
+
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
|
|
897
|
+
source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
|
|
898
|
+
index = offset + match.length;
|
|
899
|
+
|
|
900
|
+
if (escape) {
|
|
901
|
+
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
|
|
902
|
+
} else if (interpolate) {
|
|
903
|
+
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
|
|
904
|
+
} else if (evaluate) {
|
|
905
|
+
source += "';\n" + evaluate + "\n__p+='";
|
|
710
906
|
}
|
|
711
|
-
return -1;
|
|
712
|
-
};
|
|
713
|
-
};
|
|
714
907
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
_.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
|
|
720
|
-
_.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
|
|
908
|
+
// Adobe VMs need the match returned to produce the correct offset.
|
|
909
|
+
return match;
|
|
910
|
+
});
|
|
911
|
+
source += "';\n";
|
|
721
912
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
913
|
+
var argument = settings.variable;
|
|
914
|
+
if (argument) {
|
|
915
|
+
// Insure against third-party code injection. (CVE-2021-23358)
|
|
916
|
+
if (!bareIdentifier.test(argument)) throw new Error(
|
|
917
|
+
'variable is not a bare identifier: ' + argument
|
|
918
|
+
);
|
|
919
|
+
} else {
|
|
920
|
+
// If a variable is not specified, place data values in local scope.
|
|
921
|
+
source = 'with(obj||{}){\n' + source + '}\n';
|
|
922
|
+
argument = 'obj';
|
|
729
923
|
}
|
|
730
|
-
|
|
731
|
-
|
|
924
|
+
|
|
925
|
+
source = "var __t,__p='',__j=Array.prototype.join," +
|
|
926
|
+
"print=function(){__p+=__j.call(arguments,'');};\n" +
|
|
927
|
+
source + 'return __p;\n';
|
|
928
|
+
|
|
929
|
+
var render;
|
|
930
|
+
try {
|
|
931
|
+
render = new Function(argument, '_', source);
|
|
932
|
+
} catch (e) {
|
|
933
|
+
e.source = source;
|
|
934
|
+
throw e;
|
|
732
935
|
}
|
|
733
936
|
|
|
734
|
-
var
|
|
735
|
-
|
|
937
|
+
var template = function(data) {
|
|
938
|
+
return render.call(this, data, _$1);
|
|
939
|
+
};
|
|
736
940
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
941
|
+
// Provide the compiled source as a convenience for precompilation.
|
|
942
|
+
template.source = 'function(' + argument + '){\n' + source + '}';
|
|
740
943
|
|
|
741
|
-
return
|
|
742
|
-
}
|
|
944
|
+
return template;
|
|
945
|
+
}
|
|
743
946
|
|
|
744
|
-
//
|
|
745
|
-
//
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
var
|
|
750
|
-
|
|
751
|
-
|
|
947
|
+
// Traverses the children of `obj` along `path`. If a child is a function, it
|
|
948
|
+
// is invoked with its parent as context. Returns the value of the final
|
|
949
|
+
// child, or `fallback` if any child is undefined.
|
|
950
|
+
function result(obj, path, fallback) {
|
|
951
|
+
path = toPath(path);
|
|
952
|
+
var length = path.length;
|
|
953
|
+
if (!length) {
|
|
954
|
+
return isFunction$1(fallback) ? fallback.call(obj) : fallback;
|
|
752
955
|
}
|
|
753
|
-
|
|
754
|
-
|
|
956
|
+
for (var i = 0; i < length; i++) {
|
|
957
|
+
var prop = obj == null ? void 0 : obj[path[i]];
|
|
958
|
+
if (prop === void 0) {
|
|
959
|
+
prop = fallback;
|
|
960
|
+
i = length; // Ensure we don't continue iterating.
|
|
961
|
+
}
|
|
962
|
+
obj = isFunction$1(prop) ? prop.call(obj) : prop;
|
|
963
|
+
}
|
|
964
|
+
return obj;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// Generate a unique integer id (unique within the entire client session).
|
|
968
|
+
// Useful for temporary DOM ids.
|
|
969
|
+
var idCounter = 0;
|
|
970
|
+
function uniqueId(prefix) {
|
|
971
|
+
var id = ++idCounter + '';
|
|
972
|
+
return prefix ? prefix + id : id;
|
|
973
|
+
}
|
|
755
974
|
|
|
756
|
-
//
|
|
757
|
-
|
|
975
|
+
// Start chaining a wrapped Underscore object.
|
|
976
|
+
function chain(obj) {
|
|
977
|
+
var instance = _$1(obj);
|
|
978
|
+
instance._chain = true;
|
|
979
|
+
return instance;
|
|
980
|
+
}
|
|
758
981
|
|
|
759
|
-
//
|
|
760
|
-
//
|
|
761
|
-
|
|
982
|
+
// Internal function to execute `sourceFunc` bound to `context` with optional
|
|
983
|
+
// `args`. Determines whether to execute a function as a constructor or as a
|
|
984
|
+
// normal function.
|
|
985
|
+
function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
|
|
762
986
|
if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
|
|
763
987
|
var self = baseCreate(sourceFunc.prototype);
|
|
764
988
|
var result = sourceFunc.apply(self, args);
|
|
765
|
-
if (
|
|
989
|
+
if (isObject(result)) return result;
|
|
766
990
|
return self;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
// Create a function bound to a given object (assigning `this`, and arguments,
|
|
770
|
-
// optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
|
|
771
|
-
// available.
|
|
772
|
-
_.bind = restArguments(function(func, context, args) {
|
|
773
|
-
if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
|
|
774
|
-
var bound = restArguments(function(callArgs) {
|
|
775
|
-
return executeBound(func, bound, context, this, args.concat(callArgs));
|
|
776
|
-
});
|
|
777
|
-
return bound;
|
|
778
|
-
});
|
|
991
|
+
}
|
|
779
992
|
|
|
780
993
|
// Partially apply a function by creating a version that has had some of its
|
|
781
|
-
// arguments pre-filled, without changing its dynamic `this` context. _ acts
|
|
994
|
+
// arguments pre-filled, without changing its dynamic `this` context. `_` acts
|
|
782
995
|
// as a placeholder by default, allowing any combination of arguments to be
|
|
783
996
|
// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
|
|
784
|
-
|
|
785
|
-
var placeholder =
|
|
997
|
+
var partial = restArguments(function(func, boundArgs) {
|
|
998
|
+
var placeholder = partial.placeholder;
|
|
786
999
|
var bound = function() {
|
|
787
1000
|
var position = 0, length = boundArgs.length;
|
|
788
1001
|
var args = Array(length);
|
|
@@ -795,36 +1008,80 @@
|
|
|
795
1008
|
return bound;
|
|
796
1009
|
});
|
|
797
1010
|
|
|
798
|
-
|
|
1011
|
+
partial.placeholder = _$1;
|
|
1012
|
+
|
|
1013
|
+
// Create a function bound to a given object (assigning `this`, and arguments,
|
|
1014
|
+
// optionally).
|
|
1015
|
+
var bind = restArguments(function(func, context, args) {
|
|
1016
|
+
if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function');
|
|
1017
|
+
var bound = restArguments(function(callArgs) {
|
|
1018
|
+
return executeBound(func, bound, context, this, args.concat(callArgs));
|
|
1019
|
+
});
|
|
1020
|
+
return bound;
|
|
1021
|
+
});
|
|
1022
|
+
|
|
1023
|
+
// Internal helper for collection methods to determine whether a collection
|
|
1024
|
+
// should be iterated as an array or as an object.
|
|
1025
|
+
// Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
|
|
1026
|
+
// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
|
|
1027
|
+
var isArrayLike = createSizePropertyCheck(getLength);
|
|
1028
|
+
|
|
1029
|
+
// Internal implementation of a recursive `flatten` function.
|
|
1030
|
+
function flatten$1(input, depth, strict, output) {
|
|
1031
|
+
output = output || [];
|
|
1032
|
+
if (!depth && depth !== 0) {
|
|
1033
|
+
depth = Infinity;
|
|
1034
|
+
} else if (depth <= 0) {
|
|
1035
|
+
return output.concat(input);
|
|
1036
|
+
}
|
|
1037
|
+
var idx = output.length;
|
|
1038
|
+
for (var i = 0, length = getLength(input); i < length; i++) {
|
|
1039
|
+
var value = input[i];
|
|
1040
|
+
if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {
|
|
1041
|
+
// Flatten current level of array or arguments object.
|
|
1042
|
+
if (depth > 1) {
|
|
1043
|
+
flatten$1(value, depth - 1, strict, output);
|
|
1044
|
+
idx = output.length;
|
|
1045
|
+
} else {
|
|
1046
|
+
var j = 0, len = value.length;
|
|
1047
|
+
while (j < len) output[idx++] = value[j++];
|
|
1048
|
+
}
|
|
1049
|
+
} else if (!strict) {
|
|
1050
|
+
output[idx++] = value;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
return output;
|
|
1054
|
+
}
|
|
799
1055
|
|
|
800
1056
|
// Bind a number of an object's methods to that object. Remaining arguments
|
|
801
1057
|
// are the method names to be bound. Useful for ensuring that all callbacks
|
|
802
1058
|
// defined on an object belong to it.
|
|
803
|
-
|
|
804
|
-
keys = flatten(keys, false, false);
|
|
1059
|
+
var bindAll = restArguments(function(obj, keys) {
|
|
1060
|
+
keys = flatten$1(keys, false, false);
|
|
805
1061
|
var index = keys.length;
|
|
806
1062
|
if (index < 1) throw new Error('bindAll must be passed function names');
|
|
807
1063
|
while (index--) {
|
|
808
1064
|
var key = keys[index];
|
|
809
|
-
obj[key] =
|
|
1065
|
+
obj[key] = bind(obj[key], obj);
|
|
810
1066
|
}
|
|
1067
|
+
return obj;
|
|
811
1068
|
});
|
|
812
1069
|
|
|
813
1070
|
// Memoize an expensive function by storing its results.
|
|
814
|
-
|
|
1071
|
+
function memoize(func, hasher) {
|
|
815
1072
|
var memoize = function(key) {
|
|
816
1073
|
var cache = memoize.cache;
|
|
817
1074
|
var address = '' + (hasher ? hasher.apply(this, arguments) : key);
|
|
818
|
-
if (!has(cache, address)) cache[address] = func.apply(this, arguments);
|
|
1075
|
+
if (!has$1(cache, address)) cache[address] = func.apply(this, arguments);
|
|
819
1076
|
return cache[address];
|
|
820
1077
|
};
|
|
821
1078
|
memoize.cache = {};
|
|
822
1079
|
return memoize;
|
|
823
|
-
}
|
|
1080
|
+
}
|
|
824
1081
|
|
|
825
1082
|
// Delays a function for the given number of milliseconds, and then calls
|
|
826
1083
|
// it with the arguments supplied.
|
|
827
|
-
|
|
1084
|
+
var delay = restArguments(function(func, wait, args) {
|
|
828
1085
|
return setTimeout(function() {
|
|
829
1086
|
return func.apply(null, args);
|
|
830
1087
|
}, wait);
|
|
@@ -832,29 +1089,29 @@
|
|
|
832
1089
|
|
|
833
1090
|
// Defers a function, scheduling it to run after the current call stack has
|
|
834
1091
|
// cleared.
|
|
835
|
-
|
|
1092
|
+
var defer = partial(delay, _$1, 1);
|
|
836
1093
|
|
|
837
1094
|
// Returns a function, that, when invoked, will only be triggered at most once
|
|
838
1095
|
// during a given window of time. Normally, the throttled function will run
|
|
839
1096
|
// as much as it can, without ever going more than once per `wait` duration;
|
|
840
1097
|
// but if you'd like to disable the execution on the leading edge, pass
|
|
841
1098
|
// `{leading: false}`. To disable execution on the trailing edge, ditto.
|
|
842
|
-
|
|
1099
|
+
function throttle(func, wait, options) {
|
|
843
1100
|
var timeout, context, args, result;
|
|
844
1101
|
var previous = 0;
|
|
845
1102
|
if (!options) options = {};
|
|
846
1103
|
|
|
847
1104
|
var later = function() {
|
|
848
|
-
previous = options.leading === false ? 0 :
|
|
1105
|
+
previous = options.leading === false ? 0 : now();
|
|
849
1106
|
timeout = null;
|
|
850
1107
|
result = func.apply(context, args);
|
|
851
1108
|
if (!timeout) context = args = null;
|
|
852
1109
|
};
|
|
853
1110
|
|
|
854
1111
|
var throttled = function() {
|
|
855
|
-
var
|
|
856
|
-
if (!previous && options.leading === false) previous =
|
|
857
|
-
var remaining = wait - (
|
|
1112
|
+
var _now = now();
|
|
1113
|
+
if (!previous && options.leading === false) previous = _now;
|
|
1114
|
+
var remaining = wait - (_now - previous);
|
|
858
1115
|
context = this;
|
|
859
1116
|
args = arguments;
|
|
860
1117
|
if (remaining <= 0 || remaining > wait) {
|
|
@@ -862,831 +1119,924 @@
|
|
|
862
1119
|
clearTimeout(timeout);
|
|
863
1120
|
timeout = null;
|
|
864
1121
|
}
|
|
865
|
-
previous =
|
|
1122
|
+
previous = _now;
|
|
866
1123
|
result = func.apply(context, args);
|
|
867
1124
|
if (!timeout) context = args = null;
|
|
868
1125
|
} else if (!timeout && options.trailing !== false) {
|
|
869
1126
|
timeout = setTimeout(later, remaining);
|
|
870
1127
|
}
|
|
871
|
-
return result;
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
throttled.cancel = function() {
|
|
875
|
-
clearTimeout(timeout);
|
|
876
|
-
previous = 0;
|
|
877
|
-
timeout = context = args = null;
|
|
878
|
-
};
|
|
879
|
-
|
|
880
|
-
return throttled;
|
|
881
|
-
};
|
|
882
|
-
|
|
883
|
-
// Returns a function, that, as long as it continues to be invoked, will not
|
|
884
|
-
// be triggered. The function will be called after it stops being called for
|
|
885
|
-
// N milliseconds. If `immediate` is passed, trigger the function on the
|
|
886
|
-
// leading edge, instead of the trailing.
|
|
887
|
-
_.debounce = function(func, wait, immediate) {
|
|
888
|
-
var timeout, result;
|
|
889
|
-
|
|
890
|
-
var later = function(context, args) {
|
|
891
|
-
timeout = null;
|
|
892
|
-
if (args) result = func.apply(context, args);
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
var debounced = restArguments(function(args) {
|
|
896
|
-
if (timeout) clearTimeout(timeout);
|
|
897
|
-
if (immediate) {
|
|
898
|
-
var callNow = !timeout;
|
|
899
|
-
timeout = setTimeout(later, wait);
|
|
900
|
-
if (callNow) result = func.apply(this, args);
|
|
901
|
-
} else {
|
|
902
|
-
timeout = _.delay(later, wait, this, args);
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
return result;
|
|
906
|
-
});
|
|
907
|
-
|
|
908
|
-
debounced.cancel = function() {
|
|
909
|
-
clearTimeout(timeout);
|
|
910
|
-
timeout = null;
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
return debounced;
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
// Returns the first function passed as an argument to the second,
|
|
917
|
-
// allowing you to adjust arguments, run code before and after, and
|
|
918
|
-
// conditionally execute the original function.
|
|
919
|
-
_.wrap = function(func, wrapper) {
|
|
920
|
-
return _.partial(wrapper, func);
|
|
921
|
-
};
|
|
922
|
-
|
|
923
|
-
// Returns a negated version of the passed-in predicate.
|
|
924
|
-
_.negate = function(predicate) {
|
|
925
|
-
return function() {
|
|
926
|
-
return !predicate.apply(this, arguments);
|
|
927
|
-
};
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
// Returns a function that is the composition of a list of functions, each
|
|
931
|
-
// consuming the return value of the function that follows.
|
|
932
|
-
_.compose = function() {
|
|
933
|
-
var args = arguments;
|
|
934
|
-
var start = args.length - 1;
|
|
935
|
-
return function() {
|
|
936
|
-
var i = start;
|
|
937
|
-
var result = args[start].apply(this, arguments);
|
|
938
|
-
while (i--) result = args[i].call(this, result);
|
|
939
|
-
return result;
|
|
940
|
-
};
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
// Returns a function that will only be executed on and after the Nth call.
|
|
944
|
-
_.after = function(times, func) {
|
|
945
|
-
return function() {
|
|
946
|
-
if (--times < 1) {
|
|
947
|
-
return func.apply(this, arguments);
|
|
948
|
-
}
|
|
949
|
-
};
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
// Returns a function that will only be executed up to (but not including) the Nth call.
|
|
953
|
-
_.before = function(times, func) {
|
|
954
|
-
var memo;
|
|
955
|
-
return function() {
|
|
956
|
-
if (--times > 0) {
|
|
957
|
-
memo = func.apply(this, arguments);
|
|
958
|
-
}
|
|
959
|
-
if (times <= 1) func = null;
|
|
960
|
-
return memo;
|
|
961
|
-
};
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
// Returns a function that will be executed at most one time, no matter how
|
|
965
|
-
// often you call it. Useful for lazy initialization.
|
|
966
|
-
_.once = _.partial(_.before, 2);
|
|
967
|
-
|
|
968
|
-
_.restArguments = restArguments;
|
|
969
|
-
|
|
970
|
-
// Object Functions
|
|
971
|
-
// ----------------
|
|
972
|
-
|
|
973
|
-
// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
|
|
974
|
-
var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
|
|
975
|
-
var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
|
|
976
|
-
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
|
|
977
|
-
|
|
978
|
-
var collectNonEnumProps = function(obj, keys) {
|
|
979
|
-
var nonEnumIdx = nonEnumerableProps.length;
|
|
980
|
-
var constructor = obj.constructor;
|
|
981
|
-
var proto = _.isFunction(constructor) && constructor.prototype || ObjProto;
|
|
982
|
-
|
|
983
|
-
// Constructor is a special case.
|
|
984
|
-
var prop = 'constructor';
|
|
985
|
-
if (has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
|
|
986
|
-
|
|
987
|
-
while (nonEnumIdx--) {
|
|
988
|
-
prop = nonEnumerableProps[nonEnumIdx];
|
|
989
|
-
if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
|
|
990
|
-
keys.push(prop);
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
|
|
995
|
-
// Retrieve the names of an object's own properties.
|
|
996
|
-
// Delegates to **ECMAScript 5**'s native `Object.keys`.
|
|
997
|
-
_.keys = function(obj) {
|
|
998
|
-
if (!_.isObject(obj)) return [];
|
|
999
|
-
if (nativeKeys) return nativeKeys(obj);
|
|
1000
|
-
var keys = [];
|
|
1001
|
-
for (var key in obj) if (has(obj, key)) keys.push(key);
|
|
1002
|
-
// Ahem, IE < 9.
|
|
1003
|
-
if (hasEnumBug) collectNonEnumProps(obj, keys);
|
|
1004
|
-
return keys;
|
|
1005
|
-
};
|
|
1006
|
-
|
|
1007
|
-
// Retrieve all the property names of an object.
|
|
1008
|
-
_.allKeys = function(obj) {
|
|
1009
|
-
if (!_.isObject(obj)) return [];
|
|
1010
|
-
var keys = [];
|
|
1011
|
-
for (var key in obj) keys.push(key);
|
|
1012
|
-
// Ahem, IE < 9.
|
|
1013
|
-
if (hasEnumBug) collectNonEnumProps(obj, keys);
|
|
1014
|
-
return keys;
|
|
1015
|
-
};
|
|
1016
|
-
|
|
1017
|
-
// Retrieve the values of an object's properties.
|
|
1018
|
-
_.values = function(obj) {
|
|
1019
|
-
var keys = _.keys(obj);
|
|
1020
|
-
var length = keys.length;
|
|
1021
|
-
var values = Array(length);
|
|
1022
|
-
for (var i = 0; i < length; i++) {
|
|
1023
|
-
values[i] = obj[keys[i]];
|
|
1024
|
-
}
|
|
1025
|
-
return values;
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
|
-
// Returns the results of applying the iteratee to each element of the object.
|
|
1029
|
-
// In contrast to _.map it returns an object.
|
|
1030
|
-
_.mapObject = function(obj, iteratee, context) {
|
|
1031
|
-
iteratee = cb(iteratee, context);
|
|
1032
|
-
var keys = _.keys(obj),
|
|
1033
|
-
length = keys.length,
|
|
1034
|
-
results = {};
|
|
1035
|
-
for (var index = 0; index < length; index++) {
|
|
1036
|
-
var currentKey = keys[index];
|
|
1037
|
-
results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
|
|
1038
|
-
}
|
|
1039
|
-
return results;
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
// Convert an object into a list of `[key, value]` pairs.
|
|
1043
|
-
// The opposite of _.object.
|
|
1044
|
-
_.pairs = function(obj) {
|
|
1045
|
-
var keys = _.keys(obj);
|
|
1046
|
-
var length = keys.length;
|
|
1047
|
-
var pairs = Array(length);
|
|
1048
|
-
for (var i = 0; i < length; i++) {
|
|
1049
|
-
pairs[i] = [keys[i], obj[keys[i]]];
|
|
1050
|
-
}
|
|
1051
|
-
return pairs;
|
|
1052
|
-
};
|
|
1053
|
-
|
|
1054
|
-
// Invert the keys and values of an object. The values must be serializable.
|
|
1055
|
-
_.invert = function(obj) {
|
|
1056
|
-
var result = {};
|
|
1057
|
-
var keys = _.keys(obj);
|
|
1058
|
-
for (var i = 0, length = keys.length; i < length; i++) {
|
|
1059
|
-
result[obj[keys[i]]] = keys[i];
|
|
1060
|
-
}
|
|
1061
|
-
return result;
|
|
1062
|
-
};
|
|
1063
|
-
|
|
1064
|
-
// Return a sorted list of the function names available on the object.
|
|
1065
|
-
// Aliased as `methods`.
|
|
1066
|
-
_.functions = _.methods = function(obj) {
|
|
1067
|
-
var names = [];
|
|
1068
|
-
for (var key in obj) {
|
|
1069
|
-
if (_.isFunction(obj[key])) names.push(key);
|
|
1070
|
-
}
|
|
1071
|
-
return names.sort();
|
|
1072
|
-
};
|
|
1073
|
-
|
|
1074
|
-
// An internal function for creating assigner functions.
|
|
1075
|
-
var createAssigner = function(keysFunc, defaults) {
|
|
1076
|
-
return function(obj) {
|
|
1077
|
-
var length = arguments.length;
|
|
1078
|
-
if (defaults) obj = Object(obj);
|
|
1079
|
-
if (length < 2 || obj == null) return obj;
|
|
1080
|
-
for (var index = 1; index < length; index++) {
|
|
1081
|
-
var source = arguments[index],
|
|
1082
|
-
keys = keysFunc(source),
|
|
1083
|
-
l = keys.length;
|
|
1084
|
-
for (var i = 0; i < l; i++) {
|
|
1085
|
-
var key = keys[i];
|
|
1086
|
-
if (!defaults || obj[key] === void 0) obj[key] = source[key];
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
return obj;
|
|
1128
|
+
return result;
|
|
1090
1129
|
};
|
|
1091
|
-
};
|
|
1092
1130
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1131
|
+
throttled.cancel = function() {
|
|
1132
|
+
clearTimeout(timeout);
|
|
1133
|
+
previous = 0;
|
|
1134
|
+
timeout = context = args = null;
|
|
1135
|
+
};
|
|
1095
1136
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
_.extendOwn = _.assign = createAssigner(_.keys);
|
|
1137
|
+
return throttled;
|
|
1138
|
+
}
|
|
1099
1139
|
|
|
1100
|
-
//
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
if (predicate(obj[key], key, obj)) return key;
|
|
1107
|
-
}
|
|
1108
|
-
};
|
|
1140
|
+
// When a sequence of calls of the returned function ends, the argument
|
|
1141
|
+
// function is triggered. The end of a sequence is defined by the `wait`
|
|
1142
|
+
// parameter. If `immediate` is passed, the argument function will be
|
|
1143
|
+
// triggered at the beginning of the sequence instead of at the end.
|
|
1144
|
+
function debounce(func, wait, immediate) {
|
|
1145
|
+
var timeout, previous, args, result, context;
|
|
1109
1146
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1147
|
+
var later = function() {
|
|
1148
|
+
var passed = now() - previous;
|
|
1149
|
+
if (wait > passed) {
|
|
1150
|
+
timeout = setTimeout(later, wait - passed);
|
|
1151
|
+
} else {
|
|
1152
|
+
timeout = null;
|
|
1153
|
+
if (!immediate) result = func.apply(context, args);
|
|
1154
|
+
// This check is needed because `func` can recursively invoke `debounced`.
|
|
1155
|
+
if (!timeout) args = context = null;
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1114
1158
|
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
obj = Object(obj);
|
|
1126
|
-
}
|
|
1127
|
-
for (var i = 0, length = keys.length; i < length; i++) {
|
|
1128
|
-
var key = keys[i];
|
|
1129
|
-
var value = obj[key];
|
|
1130
|
-
if (iteratee(value, key, obj)) result[key] = value;
|
|
1131
|
-
}
|
|
1132
|
-
return result;
|
|
1133
|
-
});
|
|
1159
|
+
var debounced = restArguments(function(_args) {
|
|
1160
|
+
context = this;
|
|
1161
|
+
args = _args;
|
|
1162
|
+
previous = now();
|
|
1163
|
+
if (!timeout) {
|
|
1164
|
+
timeout = setTimeout(later, wait);
|
|
1165
|
+
if (immediate) result = func.apply(context, args);
|
|
1166
|
+
}
|
|
1167
|
+
return result;
|
|
1168
|
+
});
|
|
1134
1169
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
iteratee = _.negate(iteratee);
|
|
1140
|
-
if (keys.length > 1) context = keys[1];
|
|
1141
|
-
} else {
|
|
1142
|
-
keys = _.map(flatten(keys, false, false), String);
|
|
1143
|
-
iteratee = function(value, key) {
|
|
1144
|
-
return !_.contains(keys, key);
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
return _.pick(obj, iteratee, context);
|
|
1148
|
-
});
|
|
1170
|
+
debounced.cancel = function() {
|
|
1171
|
+
clearTimeout(timeout);
|
|
1172
|
+
timeout = args = context = null;
|
|
1173
|
+
};
|
|
1149
1174
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1175
|
+
return debounced;
|
|
1176
|
+
}
|
|
1152
1177
|
|
|
1153
|
-
//
|
|
1154
|
-
//
|
|
1155
|
-
//
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
return result;
|
|
1160
|
-
};
|
|
1178
|
+
// Returns the first function passed as an argument to the second,
|
|
1179
|
+
// allowing you to adjust arguments, run code before and after, and
|
|
1180
|
+
// conditionally execute the original function.
|
|
1181
|
+
function wrap(func, wrapper) {
|
|
1182
|
+
return partial(wrapper, func);
|
|
1183
|
+
}
|
|
1161
1184
|
|
|
1162
|
-
//
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1185
|
+
// Returns a negated version of the passed-in predicate.
|
|
1186
|
+
function negate(predicate) {
|
|
1187
|
+
return function() {
|
|
1188
|
+
return !predicate.apply(this, arguments);
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1167
1191
|
|
|
1168
|
-
//
|
|
1169
|
-
//
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
return
|
|
1174
|
-
|
|
1192
|
+
// Returns a function that is the composition of a list of functions, each
|
|
1193
|
+
// consuming the return value of the function that follows.
|
|
1194
|
+
function compose() {
|
|
1195
|
+
var args = arguments;
|
|
1196
|
+
var start = args.length - 1;
|
|
1197
|
+
return function() {
|
|
1198
|
+
var i = start;
|
|
1199
|
+
var result = args[start].apply(this, arguments);
|
|
1200
|
+
while (i--) result = args[i].call(this, result);
|
|
1201
|
+
return result;
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1175
1204
|
|
|
1176
|
-
// Returns
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
}
|
|
1185
|
-
return true;
|
|
1186
|
-
};
|
|
1205
|
+
// Returns a function that will only be executed on and after the Nth call.
|
|
1206
|
+
function after(times, func) {
|
|
1207
|
+
return function() {
|
|
1208
|
+
if (--times < 1) {
|
|
1209
|
+
return func.apply(this, arguments);
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1187
1213
|
|
|
1214
|
+
// Returns a function that will only be executed up to (but not including) the
|
|
1215
|
+
// Nth call.
|
|
1216
|
+
function before(times, func) {
|
|
1217
|
+
var memo;
|
|
1218
|
+
return function() {
|
|
1219
|
+
if (--times > 0) {
|
|
1220
|
+
memo = func.apply(this, arguments);
|
|
1221
|
+
}
|
|
1222
|
+
if (times <= 1) func = null;
|
|
1223
|
+
return memo;
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1188
1226
|
|
|
1189
|
-
//
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
|
1193
|
-
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
|
|
1194
|
-
if (a === b) return a !== 0 || 1 / a === 1 / b;
|
|
1195
|
-
// `null` or `undefined` only equal to itself (strict comparison).
|
|
1196
|
-
if (a == null || b == null) return false;
|
|
1197
|
-
// `NaN`s are equivalent, but non-reflexive.
|
|
1198
|
-
if (a !== a) return b !== b;
|
|
1199
|
-
// Exhaust primitive checks
|
|
1200
|
-
var type = typeof a;
|
|
1201
|
-
if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
|
|
1202
|
-
return deepEq(a, b, aStack, bStack);
|
|
1203
|
-
};
|
|
1227
|
+
// Returns a function that will be executed at most one time, no matter how
|
|
1228
|
+
// often you call it. Useful for lazy initialization.
|
|
1229
|
+
var once = partial(before, 2);
|
|
1204
1230
|
|
|
1205
|
-
//
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
if (className !== toString.call(b)) return false;
|
|
1213
|
-
switch (className) {
|
|
1214
|
-
// Strings, numbers, regular expressions, dates, and booleans are compared by value.
|
|
1215
|
-
case '[object RegExp]':
|
|
1216
|
-
// RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
|
|
1217
|
-
case '[object String]':
|
|
1218
|
-
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
|
|
1219
|
-
// equivalent to `new String("5")`.
|
|
1220
|
-
return '' + a === '' + b;
|
|
1221
|
-
case '[object Number]':
|
|
1222
|
-
// `NaN`s are equivalent, but non-reflexive.
|
|
1223
|
-
// Object(NaN) is equivalent to NaN.
|
|
1224
|
-
if (+a !== +a) return +b !== +b;
|
|
1225
|
-
// An `egal` comparison is performed for other numeric values.
|
|
1226
|
-
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
|
|
1227
|
-
case '[object Date]':
|
|
1228
|
-
case '[object Boolean]':
|
|
1229
|
-
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
|
|
1230
|
-
// millisecond representations. Note that invalid dates with millisecond representations
|
|
1231
|
-
// of `NaN` are not equivalent.
|
|
1232
|
-
return +a === +b;
|
|
1233
|
-
case '[object Symbol]':
|
|
1234
|
-
return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
|
|
1231
|
+
// Returns the first key on an object that passes a truth test.
|
|
1232
|
+
function findKey(obj, predicate, context) {
|
|
1233
|
+
predicate = cb(predicate, context);
|
|
1234
|
+
var _keys = keys(obj), key;
|
|
1235
|
+
for (var i = 0, length = _keys.length; i < length; i++) {
|
|
1236
|
+
key = _keys[i];
|
|
1237
|
+
if (predicate(obj[key], key, obj)) return key;
|
|
1235
1238
|
}
|
|
1239
|
+
}
|
|
1236
1240
|
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
_.isFunction(bCtor) && bCtor instanceof bCtor)
|
|
1246
|
-
&& ('constructor' in a && 'constructor' in b)) {
|
|
1247
|
-
return false;
|
|
1241
|
+
// Internal function to generate `_.findIndex` and `_.findLastIndex`.
|
|
1242
|
+
function createPredicateIndexFinder(dir) {
|
|
1243
|
+
return function(array, predicate, context) {
|
|
1244
|
+
predicate = cb(predicate, context);
|
|
1245
|
+
var length = getLength(array);
|
|
1246
|
+
var index = dir > 0 ? 0 : length - 1;
|
|
1247
|
+
for (; index >= 0 && index < length; index += dir) {
|
|
1248
|
+
if (predicate(array[index], index, array)) return index;
|
|
1248
1249
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1250
|
+
return -1;
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1252
1253
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
aStack = aStack || [];
|
|
1256
|
-
bStack = bStack || [];
|
|
1257
|
-
var length = aStack.length;
|
|
1258
|
-
while (length--) {
|
|
1259
|
-
// Linear search. Performance is inversely proportional to the number of
|
|
1260
|
-
// unique nested structures.
|
|
1261
|
-
if (aStack[length] === a) return bStack[length] === b;
|
|
1262
|
-
}
|
|
1254
|
+
// Returns the first index on an array-like that passes a truth test.
|
|
1255
|
+
var findIndex = createPredicateIndexFinder(1);
|
|
1263
1256
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
bStack.push(b);
|
|
1257
|
+
// Returns the last index on an array-like that passes a truth test.
|
|
1258
|
+
var findLastIndex = createPredicateIndexFinder(-1);
|
|
1267
1259
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1260
|
+
// Use a comparator function to figure out the smallest index at which
|
|
1261
|
+
// an object should be inserted so as to maintain order. Uses binary search.
|
|
1262
|
+
function sortedIndex(array, obj, iteratee, context) {
|
|
1263
|
+
iteratee = cb(iteratee, context, 1);
|
|
1264
|
+
var value = iteratee(obj);
|
|
1265
|
+
var low = 0, high = getLength(array);
|
|
1266
|
+
while (low < high) {
|
|
1267
|
+
var mid = Math.floor((low + high) / 2);
|
|
1268
|
+
if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
|
|
1269
|
+
}
|
|
1270
|
+
return low;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
|
|
1274
|
+
function createIndexFinder(dir, predicateFind, sortedIndex) {
|
|
1275
|
+
return function(array, item, idx) {
|
|
1276
|
+
var i = 0, length = getLength(array);
|
|
1277
|
+
if (typeof idx == 'number') {
|
|
1278
|
+
if (dir > 0) {
|
|
1279
|
+
i = idx >= 0 ? idx : Math.max(idx + length, i);
|
|
1280
|
+
} else {
|
|
1281
|
+
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
|
|
1282
|
+
}
|
|
1283
|
+
} else if (sortedIndex && idx && length) {
|
|
1284
|
+
idx = sortedIndex(array, item);
|
|
1285
|
+
return array[idx] === item ? idx : -1;
|
|
1276
1286
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
length = keys.length;
|
|
1281
|
-
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
|
1282
|
-
if (_.keys(b).length !== length) return false;
|
|
1283
|
-
while (length--) {
|
|
1284
|
-
// Deep compare each member
|
|
1285
|
-
key = keys[length];
|
|
1286
|
-
if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
|
|
1287
|
+
if (item !== item) {
|
|
1288
|
+
idx = predicateFind(slice.call(array, i, length), isNaN$1);
|
|
1289
|
+
return idx >= 0 ? idx + i : -1;
|
|
1287
1290
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
}
|
|
1291
|
+
for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
|
|
1292
|
+
if (array[idx] === item) return idx;
|
|
1293
|
+
}
|
|
1294
|
+
return -1;
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1294
1297
|
|
|
1295
|
-
//
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1298
|
+
// Return the position of the first occurrence of an item in an array,
|
|
1299
|
+
// or -1 if the item is not included in the array.
|
|
1300
|
+
// If the array is large and already in sort order, pass `true`
|
|
1301
|
+
// for **isSorted** to use binary search.
|
|
1302
|
+
var indexOf = createIndexFinder(1, findIndex, sortedIndex);
|
|
1299
1303
|
|
|
1300
|
-
//
|
|
1301
|
-
//
|
|
1302
|
-
|
|
1303
|
-
if (obj == null) return true;
|
|
1304
|
-
if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
|
|
1305
|
-
return _.keys(obj).length === 0;
|
|
1306
|
-
};
|
|
1304
|
+
// Return the position of the last occurrence of an item in an array,
|
|
1305
|
+
// or -1 if the item is not included in the array.
|
|
1306
|
+
var lastIndexOf = createIndexFinder(-1, findLastIndex);
|
|
1307
1307
|
|
|
1308
|
-
//
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1308
|
+
// Return the first value which passes a truth test.
|
|
1309
|
+
function find(obj, predicate, context) {
|
|
1310
|
+
var keyFinder = isArrayLike(obj) ? findIndex : findKey;
|
|
1311
|
+
var key = keyFinder(obj, predicate, context);
|
|
1312
|
+
if (key !== void 0 && key !== -1) return obj[key];
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
// Convenience version of a common use case of `_.find`: getting the first
|
|
1316
|
+
// object containing specific `key:value` pairs.
|
|
1317
|
+
function findWhere(obj, attrs) {
|
|
1318
|
+
return find(obj, matcher(attrs));
|
|
1319
|
+
}
|
|
1312
1320
|
|
|
1313
|
-
//
|
|
1314
|
-
//
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1321
|
+
// The cornerstone for collection functions, an `each`
|
|
1322
|
+
// implementation, aka `forEach`.
|
|
1323
|
+
// Handles raw objects in addition to array-likes. Treats all
|
|
1324
|
+
// sparse array-likes as if they were dense.
|
|
1325
|
+
function each(obj, iteratee, context) {
|
|
1326
|
+
iteratee = optimizeCb(iteratee, context);
|
|
1327
|
+
var i, length;
|
|
1328
|
+
if (isArrayLike(obj)) {
|
|
1329
|
+
for (i = 0, length = obj.length; i < length; i++) {
|
|
1330
|
+
iteratee(obj[i], i, obj);
|
|
1331
|
+
}
|
|
1332
|
+
} else {
|
|
1333
|
+
var _keys = keys(obj);
|
|
1334
|
+
for (i = 0, length = _keys.length; i < length; i++) {
|
|
1335
|
+
iteratee(obj[_keys[i]], _keys[i], obj);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
return obj;
|
|
1339
|
+
}
|
|
1318
1340
|
|
|
1319
|
-
//
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1341
|
+
// Return the results of applying the iteratee to each element.
|
|
1342
|
+
function map(obj, iteratee, context) {
|
|
1343
|
+
iteratee = cb(iteratee, context);
|
|
1344
|
+
var _keys = !isArrayLike(obj) && keys(obj),
|
|
1345
|
+
length = (_keys || obj).length,
|
|
1346
|
+
results = Array(length);
|
|
1347
|
+
for (var index = 0; index < length; index++) {
|
|
1348
|
+
var currentKey = _keys ? _keys[index] : index;
|
|
1349
|
+
results[index] = iteratee(obj[currentKey], currentKey, obj);
|
|
1350
|
+
}
|
|
1351
|
+
return results;
|
|
1352
|
+
}
|
|
1324
1353
|
|
|
1325
|
-
//
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1354
|
+
// Internal helper to create a reducing function, iterating left or right.
|
|
1355
|
+
function createReduce(dir) {
|
|
1356
|
+
// Wrap code that reassigns argument variables in a separate function than
|
|
1357
|
+
// the one that accesses `arguments.length` to avoid a perf hit. (#1991)
|
|
1358
|
+
var reducer = function(obj, iteratee, memo, initial) {
|
|
1359
|
+
var _keys = !isArrayLike(obj) && keys(obj),
|
|
1360
|
+
length = (_keys || obj).length,
|
|
1361
|
+
index = dir > 0 ? 0 : length - 1;
|
|
1362
|
+
if (!initial) {
|
|
1363
|
+
memo = obj[_keys ? _keys[index] : index];
|
|
1364
|
+
index += dir;
|
|
1365
|
+
}
|
|
1366
|
+
for (; index >= 0 && index < length; index += dir) {
|
|
1367
|
+
var currentKey = _keys ? _keys[index] : index;
|
|
1368
|
+
memo = iteratee(memo, obj[currentKey], currentKey, obj);
|
|
1369
|
+
}
|
|
1370
|
+
return memo;
|
|
1329
1371
|
};
|
|
1330
|
-
});
|
|
1331
1372
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
_.isArguments = function(obj) {
|
|
1336
|
-
return has(obj, 'callee');
|
|
1373
|
+
return function(obj, iteratee, memo, context) {
|
|
1374
|
+
var initial = arguments.length >= 3;
|
|
1375
|
+
return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
|
|
1337
1376
|
};
|
|
1338
1377
|
}
|
|
1339
1378
|
|
|
1340
|
-
//
|
|
1341
|
-
//
|
|
1342
|
-
var
|
|
1343
|
-
if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
|
|
1344
|
-
_.isFunction = function(obj) {
|
|
1345
|
-
return typeof obj == 'function' || false;
|
|
1346
|
-
};
|
|
1347
|
-
}
|
|
1379
|
+
// **Reduce** builds up a single result from a list of values, aka `inject`,
|
|
1380
|
+
// or `foldl`.
|
|
1381
|
+
var reduce = createReduce(1);
|
|
1348
1382
|
|
|
1349
|
-
//
|
|
1350
|
-
|
|
1351
|
-
return !_.isSymbol(obj) && isFinite(obj) && !isNaN(parseFloat(obj));
|
|
1352
|
-
};
|
|
1383
|
+
// The right-associative version of reduce, also known as `foldr`.
|
|
1384
|
+
var reduceRight = createReduce(-1);
|
|
1353
1385
|
|
|
1354
|
-
//
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1386
|
+
// Return all the elements that pass a truth test.
|
|
1387
|
+
function filter(obj, predicate, context) {
|
|
1388
|
+
var results = [];
|
|
1389
|
+
predicate = cb(predicate, context);
|
|
1390
|
+
each(obj, function(value, index, list) {
|
|
1391
|
+
if (predicate(value, index, list)) results.push(value);
|
|
1392
|
+
});
|
|
1393
|
+
return results;
|
|
1394
|
+
}
|
|
1358
1395
|
|
|
1359
|
-
//
|
|
1360
|
-
|
|
1361
|
-
return obj
|
|
1362
|
-
}
|
|
1396
|
+
// Return all the elements for which a truth test fails.
|
|
1397
|
+
function reject(obj, predicate, context) {
|
|
1398
|
+
return filter(obj, negate(cb(predicate)), context);
|
|
1399
|
+
}
|
|
1363
1400
|
|
|
1364
|
-
//
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1401
|
+
// Determine whether all of the elements pass a truth test.
|
|
1402
|
+
function every(obj, predicate, context) {
|
|
1403
|
+
predicate = cb(predicate, context);
|
|
1404
|
+
var _keys = !isArrayLike(obj) && keys(obj),
|
|
1405
|
+
length = (_keys || obj).length;
|
|
1406
|
+
for (var index = 0; index < length; index++) {
|
|
1407
|
+
var currentKey = _keys ? _keys[index] : index;
|
|
1408
|
+
if (!predicate(obj[currentKey], currentKey, obj)) return false;
|
|
1409
|
+
}
|
|
1410
|
+
return true;
|
|
1411
|
+
}
|
|
1368
1412
|
|
|
1369
|
-
//
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1413
|
+
// Determine if at least one element in the object passes a truth test.
|
|
1414
|
+
function some(obj, predicate, context) {
|
|
1415
|
+
predicate = cb(predicate, context);
|
|
1416
|
+
var _keys = !isArrayLike(obj) && keys(obj),
|
|
1417
|
+
length = (_keys || obj).length;
|
|
1418
|
+
for (var index = 0; index < length; index++) {
|
|
1419
|
+
var currentKey = _keys ? _keys[index] : index;
|
|
1420
|
+
if (predicate(obj[currentKey], currentKey, obj)) return true;
|
|
1421
|
+
}
|
|
1422
|
+
return false;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// Determine if the array or object contains a given item (using `===`).
|
|
1426
|
+
function contains(obj, item, fromIndex, guard) {
|
|
1427
|
+
if (!isArrayLike(obj)) obj = values(obj);
|
|
1428
|
+
if (typeof fromIndex != 'number' || guard) fromIndex = 0;
|
|
1429
|
+
return indexOf(obj, item, fromIndex) >= 0;
|
|
1430
|
+
}
|
|
1373
1431
|
|
|
1374
|
-
//
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
if (
|
|
1378
|
-
|
|
1432
|
+
// Invoke a method (with arguments) on every item in a collection.
|
|
1433
|
+
var invoke = restArguments(function(obj, path, args) {
|
|
1434
|
+
var contextPath, func;
|
|
1435
|
+
if (isFunction$1(path)) {
|
|
1436
|
+
func = path;
|
|
1437
|
+
} else {
|
|
1438
|
+
path = toPath(path);
|
|
1439
|
+
contextPath = path.slice(0, -1);
|
|
1440
|
+
path = path[path.length - 1];
|
|
1379
1441
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1442
|
+
return map(obj, function(context) {
|
|
1443
|
+
var method = func;
|
|
1444
|
+
if (!method) {
|
|
1445
|
+
if (contextPath && contextPath.length) {
|
|
1446
|
+
context = deepGet(context, contextPath);
|
|
1447
|
+
}
|
|
1448
|
+
if (context == null) return void 0;
|
|
1449
|
+
method = context[path];
|
|
1385
1450
|
}
|
|
1386
|
-
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
};
|
|
1390
|
-
|
|
1391
|
-
// Utility Functions
|
|
1392
|
-
// -----------------
|
|
1451
|
+
return method == null ? method : method.apply(context, args);
|
|
1452
|
+
});
|
|
1453
|
+
});
|
|
1393
1454
|
|
|
1394
|
-
//
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
return this;
|
|
1399
|
-
};
|
|
1455
|
+
// Convenience version of a common use case of `_.map`: fetching a property.
|
|
1456
|
+
function pluck(obj, key) {
|
|
1457
|
+
return map(obj, property(key));
|
|
1458
|
+
}
|
|
1400
1459
|
|
|
1401
|
-
//
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1460
|
+
// Convenience version of a common use case of `_.filter`: selecting only
|
|
1461
|
+
// objects containing specific `key:value` pairs.
|
|
1462
|
+
function where(obj, attrs) {
|
|
1463
|
+
return filter(obj, matcher(attrs));
|
|
1464
|
+
}
|
|
1405
1465
|
|
|
1406
|
-
//
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1466
|
+
// Return the maximum element (or element-based computation).
|
|
1467
|
+
function max(obj, iteratee, context) {
|
|
1468
|
+
var result = -Infinity, lastComputed = -Infinity,
|
|
1469
|
+
value, computed;
|
|
1470
|
+
if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
|
|
1471
|
+
obj = isArrayLike(obj) ? obj : values(obj);
|
|
1472
|
+
for (var i = 0, length = obj.length; i < length; i++) {
|
|
1473
|
+
value = obj[i];
|
|
1474
|
+
if (value != null && value > result) {
|
|
1475
|
+
result = value;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
} else {
|
|
1479
|
+
iteratee = cb(iteratee, context);
|
|
1480
|
+
each(obj, function(v, index, list) {
|
|
1481
|
+
computed = iteratee(v, index, list);
|
|
1482
|
+
if (computed > lastComputed || (computed === -Infinity && result === -Infinity)) {
|
|
1483
|
+
result = v;
|
|
1484
|
+
lastComputed = computed;
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
return result;
|
|
1489
|
+
}
|
|
1412
1490
|
|
|
1413
|
-
|
|
1491
|
+
// Return the minimum element (or element-based computation).
|
|
1492
|
+
function min(obj, iteratee, context) {
|
|
1493
|
+
var result = Infinity, lastComputed = Infinity,
|
|
1494
|
+
value, computed;
|
|
1495
|
+
if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null)) {
|
|
1496
|
+
obj = isArrayLike(obj) ? obj : values(obj);
|
|
1497
|
+
for (var i = 0, length = obj.length; i < length; i++) {
|
|
1498
|
+
value = obj[i];
|
|
1499
|
+
if (value != null && value < result) {
|
|
1500
|
+
result = value;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
} else {
|
|
1504
|
+
iteratee = cb(iteratee, context);
|
|
1505
|
+
each(obj, function(v, index, list) {
|
|
1506
|
+
computed = iteratee(v, index, list);
|
|
1507
|
+
if (computed < lastComputed || (computed === Infinity && result === Infinity)) {
|
|
1508
|
+
result = v;
|
|
1509
|
+
lastComputed = computed;
|
|
1510
|
+
}
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
return result;
|
|
1514
|
+
}
|
|
1414
1515
|
|
|
1415
|
-
//
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
if (!
|
|
1419
|
-
|
|
1516
|
+
// Safely create a real, live array from anything iterable.
|
|
1517
|
+
var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
|
|
1518
|
+
function toArray(obj) {
|
|
1519
|
+
if (!obj) return [];
|
|
1520
|
+
if (isArray(obj)) return slice.call(obj);
|
|
1521
|
+
if (isString(obj)) {
|
|
1522
|
+
// Keep surrogate pair characters together.
|
|
1523
|
+
return obj.match(reStrSymbol);
|
|
1420
1524
|
}
|
|
1421
|
-
return
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
};
|
|
1525
|
+
if (isArrayLike(obj)) return map(obj, identity);
|
|
1526
|
+
return values(obj);
|
|
1527
|
+
}
|
|
1425
1528
|
|
|
1426
|
-
//
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1529
|
+
// Sample **n** random values from a collection using the modern version of the
|
|
1530
|
+
// [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
|
|
1531
|
+
// If **n** is not specified, returns a single random element.
|
|
1532
|
+
// The internal `guard` argument allows it to work with `_.map`.
|
|
1533
|
+
function sample(obj, n, guard) {
|
|
1534
|
+
if (n == null || guard) {
|
|
1535
|
+
if (!isArrayLike(obj)) obj = values(obj);
|
|
1536
|
+
return obj[random(obj.length - 1)];
|
|
1430
1537
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1538
|
+
var sample = toArray(obj);
|
|
1539
|
+
var length = getLength(sample);
|
|
1540
|
+
n = Math.max(Math.min(n, length), 0);
|
|
1541
|
+
var last = length - 1;
|
|
1542
|
+
for (var index = 0; index < n; index++) {
|
|
1543
|
+
var rand = random(index, last);
|
|
1544
|
+
var temp = sample[index];
|
|
1545
|
+
sample[index] = sample[rand];
|
|
1546
|
+
sample[rand] = temp;
|
|
1547
|
+
}
|
|
1548
|
+
return sample.slice(0, n);
|
|
1549
|
+
}
|
|
1435
1550
|
|
|
1436
|
-
//
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
return function(obj) {
|
|
1441
|
-
return _.isMatch(obj, attrs);
|
|
1442
|
-
};
|
|
1443
|
-
};
|
|
1551
|
+
// Shuffle a collection.
|
|
1552
|
+
function shuffle(obj) {
|
|
1553
|
+
return sample(obj, Infinity);
|
|
1554
|
+
}
|
|
1444
1555
|
|
|
1445
|
-
//
|
|
1446
|
-
|
|
1447
|
-
var
|
|
1448
|
-
iteratee =
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1556
|
+
// Sort the object's values by a criterion produced by an iteratee.
|
|
1557
|
+
function sortBy(obj, iteratee, context) {
|
|
1558
|
+
var index = 0;
|
|
1559
|
+
iteratee = cb(iteratee, context);
|
|
1560
|
+
return pluck(map(obj, function(value, key, list) {
|
|
1561
|
+
return {
|
|
1562
|
+
value: value,
|
|
1563
|
+
index: index++,
|
|
1564
|
+
criteria: iteratee(value, key, list)
|
|
1565
|
+
};
|
|
1566
|
+
}).sort(function(left, right) {
|
|
1567
|
+
var a = left.criteria;
|
|
1568
|
+
var b = right.criteria;
|
|
1569
|
+
if (a !== b) {
|
|
1570
|
+
if (a > b || a === void 0) return 1;
|
|
1571
|
+
if (a < b || b === void 0) return -1;
|
|
1572
|
+
}
|
|
1573
|
+
return left.index - right.index;
|
|
1574
|
+
}), 'value');
|
|
1575
|
+
}
|
|
1452
1576
|
|
|
1453
|
-
//
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1577
|
+
// An internal function used for aggregate "group by" operations.
|
|
1578
|
+
function group(behavior, partition) {
|
|
1579
|
+
return function(obj, iteratee, context) {
|
|
1580
|
+
var result = partition ? [[], []] : {};
|
|
1581
|
+
iteratee = cb(iteratee, context);
|
|
1582
|
+
each(obj, function(value, index) {
|
|
1583
|
+
var key = iteratee(value, index, obj);
|
|
1584
|
+
behavior(result, value, key);
|
|
1585
|
+
});
|
|
1586
|
+
return result;
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1461
1589
|
|
|
1462
|
-
//
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1590
|
+
// Groups the object's values by a criterion. Pass either a string attribute
|
|
1591
|
+
// to group by, or a function that returns the criterion.
|
|
1592
|
+
var groupBy = group(function(result, value, key) {
|
|
1593
|
+
if (has$1(result, key)) result[key].push(value); else result[key] = [value];
|
|
1594
|
+
});
|
|
1466
1595
|
|
|
1467
|
-
//
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
var
|
|
1596
|
+
// Indexes the object's values by a criterion, similar to `_.groupBy`, but for
|
|
1597
|
+
// when you know that your index values will be unique.
|
|
1598
|
+
var indexBy = group(function(result, value, key) {
|
|
1599
|
+
result[key] = value;
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
// Counts instances of an object that group by a certain criterion. Pass
|
|
1603
|
+
// either a string attribute to count by, or a function that returns the
|
|
1604
|
+
// criterion.
|
|
1605
|
+
var countBy = group(function(result, value, key) {
|
|
1606
|
+
if (has$1(result, key)) result[key]++; else result[key] = 1;
|
|
1607
|
+
});
|
|
1477
1608
|
|
|
1478
|
-
//
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
// Regexes for identifying a key that needs to be escaped.
|
|
1484
|
-
var source = '(?:' + _.keys(map).join('|') + ')';
|
|
1485
|
-
var testRegexp = RegExp(source);
|
|
1486
|
-
var replaceRegexp = RegExp(source, 'g');
|
|
1487
|
-
return function(string) {
|
|
1488
|
-
string = string == null ? '' : '' + string;
|
|
1489
|
-
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
|
|
1490
|
-
};
|
|
1491
|
-
};
|
|
1492
|
-
_.escape = createEscaper(escapeMap);
|
|
1493
|
-
_.unescape = createEscaper(unescapeMap);
|
|
1609
|
+
// Split a collection into two arrays: one whose elements all pass the given
|
|
1610
|
+
// truth test, and one whose elements all do not pass the truth test.
|
|
1611
|
+
var partition = group(function(result, value, pass) {
|
|
1612
|
+
result[pass ? 0 : 1].push(value);
|
|
1613
|
+
}, true);
|
|
1494
1614
|
|
|
1495
|
-
//
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1615
|
+
// Return the number of elements in a collection.
|
|
1616
|
+
function size(obj) {
|
|
1617
|
+
if (obj == null) return 0;
|
|
1618
|
+
return isArrayLike(obj) ? obj.length : keys(obj).length;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
// Internal `_.pick` helper function to determine whether `key` is an enumerable
|
|
1622
|
+
// property name of `obj`.
|
|
1623
|
+
function keyInObj(value, key, obj) {
|
|
1624
|
+
return key in obj;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
// Return a copy of the object only containing the allowed properties.
|
|
1628
|
+
var pick = restArguments(function(obj, keys) {
|
|
1629
|
+
var result = {}, iteratee = keys[0];
|
|
1630
|
+
if (obj == null) return result;
|
|
1631
|
+
if (isFunction$1(iteratee)) {
|
|
1632
|
+
if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
|
|
1633
|
+
keys = allKeys(obj);
|
|
1634
|
+
} else {
|
|
1635
|
+
iteratee = keyInObj;
|
|
1636
|
+
keys = flatten$1(keys, false, false);
|
|
1637
|
+
obj = Object(obj);
|
|
1503
1638
|
}
|
|
1504
|
-
for (var i = 0; i < length; i++) {
|
|
1505
|
-
var
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
i = length; // Ensure we don't continue iterating.
|
|
1509
|
-
}
|
|
1510
|
-
obj = _.isFunction(prop) ? prop.call(obj) : prop;
|
|
1639
|
+
for (var i = 0, length = keys.length; i < length; i++) {
|
|
1640
|
+
var key = keys[i];
|
|
1641
|
+
var value = obj[key];
|
|
1642
|
+
if (iteratee(value, key, obj)) result[key] = value;
|
|
1511
1643
|
}
|
|
1512
|
-
return
|
|
1513
|
-
};
|
|
1644
|
+
return result;
|
|
1645
|
+
});
|
|
1514
1646
|
|
|
1515
|
-
//
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1647
|
+
// Return a copy of the object without the disallowed properties.
|
|
1648
|
+
var omit = restArguments(function(obj, keys) {
|
|
1649
|
+
var iteratee = keys[0], context;
|
|
1650
|
+
if (isFunction$1(iteratee)) {
|
|
1651
|
+
iteratee = negate(iteratee);
|
|
1652
|
+
if (keys.length > 1) context = keys[1];
|
|
1653
|
+
} else {
|
|
1654
|
+
keys = map(flatten$1(keys, false, false), String);
|
|
1655
|
+
iteratee = function(value, key) {
|
|
1656
|
+
return !contains(keys, key);
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
return pick(obj, iteratee, context);
|
|
1660
|
+
});
|
|
1522
1661
|
|
|
1523
|
-
//
|
|
1524
|
-
//
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
};
|
|
1662
|
+
// Returns everything but the last entry of the array. Especially useful on
|
|
1663
|
+
// the arguments object. Passing **n** will return all the values in
|
|
1664
|
+
// the array, excluding the last N.
|
|
1665
|
+
function initial(array, n, guard) {
|
|
1666
|
+
return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
|
|
1667
|
+
}
|
|
1530
1668
|
|
|
1531
|
-
//
|
|
1532
|
-
//
|
|
1533
|
-
|
|
1534
|
-
|
|
1669
|
+
// Get the first element of an array. Passing **n** will return the first N
|
|
1670
|
+
// values in the array. The **guard** check allows it to work with `_.map`.
|
|
1671
|
+
function first(array, n, guard) {
|
|
1672
|
+
if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
|
|
1673
|
+
if (n == null || guard) return array[0];
|
|
1674
|
+
return initial(array, array.length - n);
|
|
1675
|
+
}
|
|
1535
1676
|
|
|
1536
|
-
//
|
|
1537
|
-
//
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
'\n': 'n',
|
|
1543
|
-
'\u2028': 'u2028',
|
|
1544
|
-
'\u2029': 'u2029'
|
|
1545
|
-
};
|
|
1677
|
+
// Returns everything but the first entry of the `array`. Especially useful on
|
|
1678
|
+
// the `arguments` object. Passing an **n** will return the rest N values in the
|
|
1679
|
+
// `array`.
|
|
1680
|
+
function rest(array, n, guard) {
|
|
1681
|
+
return slice.call(array, n == null || guard ? 1 : n);
|
|
1682
|
+
}
|
|
1546
1683
|
|
|
1547
|
-
|
|
1684
|
+
// Get the last element of an array. Passing **n** will return the last N
|
|
1685
|
+
// values in the array.
|
|
1686
|
+
function last(array, n, guard) {
|
|
1687
|
+
if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
|
|
1688
|
+
if (n == null || guard) return array[array.length - 1];
|
|
1689
|
+
return rest(array, Math.max(0, array.length - n));
|
|
1690
|
+
}
|
|
1548
1691
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1692
|
+
// Trim out all falsy values from an array.
|
|
1693
|
+
function compact(array) {
|
|
1694
|
+
return filter(array, Boolean);
|
|
1695
|
+
}
|
|
1552
1696
|
|
|
1553
|
-
//
|
|
1554
|
-
//
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
if (!settings && oldSettings) settings = oldSettings;
|
|
1559
|
-
settings = _.defaults({}, settings, _.templateSettings);
|
|
1697
|
+
// Flatten out an array, either recursively (by default), or up to `depth`.
|
|
1698
|
+
// Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
|
|
1699
|
+
function flatten(array, depth) {
|
|
1700
|
+
return flatten$1(array, depth, false);
|
|
1701
|
+
}
|
|
1560
1702
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1703
|
+
// Take the difference between one array and a number of other arrays.
|
|
1704
|
+
// Only the elements present in just the first array will remain.
|
|
1705
|
+
var difference = restArguments(function(array, rest) {
|
|
1706
|
+
rest = flatten$1(rest, true, true);
|
|
1707
|
+
return filter(array, function(value){
|
|
1708
|
+
return !contains(rest, value);
|
|
1709
|
+
});
|
|
1710
|
+
});
|
|
1567
1711
|
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
|
|
1573
|
-
index = offset + match.length;
|
|
1712
|
+
// Return a version of the array that does not contain the specified value(s).
|
|
1713
|
+
var without = restArguments(function(array, otherArrays) {
|
|
1714
|
+
return difference(array, otherArrays);
|
|
1715
|
+
});
|
|
1574
1716
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1717
|
+
// Produce a duplicate-free version of the array. If the array has already
|
|
1718
|
+
// been sorted, you have the option of using a faster algorithm.
|
|
1719
|
+
// The faster algorithm will not work with an iteratee if the iteratee
|
|
1720
|
+
// is not a one-to-one function, so providing an iteratee will disable
|
|
1721
|
+
// the faster algorithm.
|
|
1722
|
+
function uniq(array, isSorted, iteratee, context) {
|
|
1723
|
+
if (!isBoolean(isSorted)) {
|
|
1724
|
+
context = iteratee;
|
|
1725
|
+
iteratee = isSorted;
|
|
1726
|
+
isSorted = false;
|
|
1727
|
+
}
|
|
1728
|
+
if (iteratee != null) iteratee = cb(iteratee, context);
|
|
1729
|
+
var result = [];
|
|
1730
|
+
var seen = [];
|
|
1731
|
+
for (var i = 0, length = getLength(array); i < length; i++) {
|
|
1732
|
+
var value = array[i],
|
|
1733
|
+
computed = iteratee ? iteratee(value, i, array) : value;
|
|
1734
|
+
if (isSorted && !iteratee) {
|
|
1735
|
+
if (!i || seen !== computed) result.push(value);
|
|
1736
|
+
seen = computed;
|
|
1737
|
+
} else if (iteratee) {
|
|
1738
|
+
if (!contains(seen, computed)) {
|
|
1739
|
+
seen.push(computed);
|
|
1740
|
+
result.push(value);
|
|
1741
|
+
}
|
|
1742
|
+
} else if (!contains(result, value)) {
|
|
1743
|
+
result.push(value);
|
|
1581
1744
|
}
|
|
1745
|
+
}
|
|
1746
|
+
return result;
|
|
1747
|
+
}
|
|
1582
1748
|
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1749
|
+
// Produce an array that contains the union: each distinct element from all of
|
|
1750
|
+
// the passed-in arrays.
|
|
1751
|
+
var union = restArguments(function(arrays) {
|
|
1752
|
+
return uniq(flatten$1(arrays, true, true));
|
|
1753
|
+
});
|
|
1587
1754
|
|
|
1588
|
-
|
|
1589
|
-
|
|
1755
|
+
// Produce an array that contains every item shared between all the
|
|
1756
|
+
// passed-in arrays.
|
|
1757
|
+
function intersection(array) {
|
|
1758
|
+
var result = [];
|
|
1759
|
+
var argsLength = arguments.length;
|
|
1760
|
+
for (var i = 0, length = getLength(array); i < length; i++) {
|
|
1761
|
+
var item = array[i];
|
|
1762
|
+
if (contains(result, item)) continue;
|
|
1763
|
+
var j;
|
|
1764
|
+
for (j = 1; j < argsLength; j++) {
|
|
1765
|
+
if (!contains(arguments[j], item)) break;
|
|
1766
|
+
}
|
|
1767
|
+
if (j === argsLength) result.push(item);
|
|
1768
|
+
}
|
|
1769
|
+
return result;
|
|
1770
|
+
}
|
|
1590
1771
|
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1772
|
+
// Complement of zip. Unzip accepts an array of arrays and groups
|
|
1773
|
+
// each array's elements on shared indices.
|
|
1774
|
+
function unzip(array) {
|
|
1775
|
+
var length = (array && max(array, getLength).length) || 0;
|
|
1776
|
+
var result = Array(length);
|
|
1594
1777
|
|
|
1595
|
-
var
|
|
1596
|
-
|
|
1597
|
-
render = new Function(settings.variable || 'obj', '_', source);
|
|
1598
|
-
} catch (e) {
|
|
1599
|
-
e.source = source;
|
|
1600
|
-
throw e;
|
|
1778
|
+
for (var index = 0; index < length; index++) {
|
|
1779
|
+
result[index] = pluck(array, index);
|
|
1601
1780
|
}
|
|
1781
|
+
return result;
|
|
1782
|
+
}
|
|
1602
1783
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1784
|
+
// Zip together multiple lists into a single array -- elements that share
|
|
1785
|
+
// an index go together.
|
|
1786
|
+
var zip = restArguments(unzip);
|
|
1606
1787
|
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1788
|
+
// Converts lists into objects. Pass either a single array of `[key, value]`
|
|
1789
|
+
// pairs, or two parallel arrays of the same length -- one of keys, and one of
|
|
1790
|
+
// the corresponding values. Passing by pairs is the reverse of `_.pairs`.
|
|
1791
|
+
function object(list, values) {
|
|
1792
|
+
var result = {};
|
|
1793
|
+
for (var i = 0, length = getLength(list); i < length; i++) {
|
|
1794
|
+
if (values) {
|
|
1795
|
+
result[list[i]] = values[i];
|
|
1796
|
+
} else {
|
|
1797
|
+
result[list[i][0]] = list[i][1];
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
return result;
|
|
1801
|
+
}
|
|
1610
1802
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1803
|
+
// Generate an integer Array containing an arithmetic progression. A port of
|
|
1804
|
+
// the native Python `range()` function. See
|
|
1805
|
+
// [the Python documentation](https://docs.python.org/library/functions.html#range).
|
|
1806
|
+
function range(start, stop, step) {
|
|
1807
|
+
if (stop == null) {
|
|
1808
|
+
stop = start || 0;
|
|
1809
|
+
start = 0;
|
|
1810
|
+
}
|
|
1811
|
+
if (!step) {
|
|
1812
|
+
step = stop < start ? -1 : 1;
|
|
1813
|
+
}
|
|
1613
1814
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1815
|
+
var length = Math.max(Math.ceil((stop - start) / step), 0);
|
|
1816
|
+
var range = Array(length);
|
|
1817
|
+
|
|
1818
|
+
for (var idx = 0; idx < length; idx++, start += step) {
|
|
1819
|
+
range[idx] = start;
|
|
1820
|
+
}
|
|
1620
1821
|
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
//
|
|
1625
|
-
//
|
|
1822
|
+
return range;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
// Chunk a single array into multiple arrays, each containing `count` or fewer
|
|
1826
|
+
// items.
|
|
1827
|
+
function chunk(array, count) {
|
|
1828
|
+
if (count == null || count < 1) return [];
|
|
1829
|
+
var result = [];
|
|
1830
|
+
var i = 0, length = array.length;
|
|
1831
|
+
while (i < length) {
|
|
1832
|
+
result.push(slice.call(array, i, i += count));
|
|
1833
|
+
}
|
|
1834
|
+
return result;
|
|
1835
|
+
}
|
|
1626
1836
|
|
|
1627
1837
|
// Helper function to continue chaining intermediate results.
|
|
1628
|
-
|
|
1629
|
-
return instance._chain ? _(obj).chain() : obj;
|
|
1630
|
-
}
|
|
1838
|
+
function chainResult(instance, obj) {
|
|
1839
|
+
return instance._chain ? _$1(obj).chain() : obj;
|
|
1840
|
+
}
|
|
1631
1841
|
|
|
1632
1842
|
// Add your own custom functions to the Underscore object.
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
var func = _[name] = obj[name];
|
|
1636
|
-
_.prototype[name] = function() {
|
|
1843
|
+
function mixin(obj) {
|
|
1844
|
+
each(functions(obj), function(name) {
|
|
1845
|
+
var func = _$1[name] = obj[name];
|
|
1846
|
+
_$1.prototype[name] = function() {
|
|
1637
1847
|
var args = [this._wrapped];
|
|
1638
1848
|
push.apply(args, arguments);
|
|
1639
|
-
return chainResult(this, func.apply(_, args));
|
|
1849
|
+
return chainResult(this, func.apply(_$1, args));
|
|
1640
1850
|
};
|
|
1641
1851
|
});
|
|
1642
|
-
return _;
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
// Add all of the Underscore functions to the wrapper object.
|
|
1646
|
-
_.mixin(_);
|
|
1852
|
+
return _$1;
|
|
1853
|
+
}
|
|
1647
1854
|
|
|
1648
|
-
// Add all mutator Array functions to the wrapper.
|
|
1649
|
-
|
|
1855
|
+
// Add all mutator `Array` functions to the wrapper.
|
|
1856
|
+
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
|
|
1650
1857
|
var method = ArrayProto[name];
|
|
1651
|
-
_.prototype[name] = function() {
|
|
1858
|
+
_$1.prototype[name] = function() {
|
|
1652
1859
|
var obj = this._wrapped;
|
|
1653
|
-
|
|
1654
|
-
|
|
1860
|
+
if (obj != null) {
|
|
1861
|
+
method.apply(obj, arguments);
|
|
1862
|
+
if ((name === 'shift' || name === 'splice') && obj.length === 0) {
|
|
1863
|
+
delete obj[0];
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1655
1866
|
return chainResult(this, obj);
|
|
1656
1867
|
};
|
|
1657
1868
|
});
|
|
1658
1869
|
|
|
1659
|
-
// Add all accessor Array functions to the wrapper.
|
|
1660
|
-
|
|
1870
|
+
// Add all accessor `Array` functions to the wrapper.
|
|
1871
|
+
each(['concat', 'join', 'slice'], function(name) {
|
|
1661
1872
|
var method = ArrayProto[name];
|
|
1662
|
-
_.prototype[name] = function() {
|
|
1663
|
-
|
|
1873
|
+
_$1.prototype[name] = function() {
|
|
1874
|
+
var obj = this._wrapped;
|
|
1875
|
+
if (obj != null) obj = method.apply(obj, arguments);
|
|
1876
|
+
return chainResult(this, obj);
|
|
1664
1877
|
};
|
|
1665
1878
|
});
|
|
1666
1879
|
|
|
1667
|
-
//
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1880
|
+
// Named Exports
|
|
1881
|
+
|
|
1882
|
+
var allExports = {
|
|
1883
|
+
__proto__: null,
|
|
1884
|
+
VERSION: VERSION,
|
|
1885
|
+
restArguments: restArguments,
|
|
1886
|
+
isObject: isObject,
|
|
1887
|
+
isNull: isNull,
|
|
1888
|
+
isUndefined: isUndefined,
|
|
1889
|
+
isBoolean: isBoolean,
|
|
1890
|
+
isElement: isElement,
|
|
1891
|
+
isString: isString,
|
|
1892
|
+
isNumber: isNumber,
|
|
1893
|
+
isDate: isDate,
|
|
1894
|
+
isRegExp: isRegExp,
|
|
1895
|
+
isError: isError,
|
|
1896
|
+
isSymbol: isSymbol,
|
|
1897
|
+
isArrayBuffer: isArrayBuffer,
|
|
1898
|
+
isDataView: isDataView$1,
|
|
1899
|
+
isArray: isArray,
|
|
1900
|
+
isFunction: isFunction$1,
|
|
1901
|
+
isArguments: isArguments$1,
|
|
1902
|
+
isFinite: isFinite$1,
|
|
1903
|
+
isNaN: isNaN$1,
|
|
1904
|
+
isTypedArray: isTypedArray$1,
|
|
1905
|
+
isEmpty: isEmpty,
|
|
1906
|
+
isMatch: isMatch,
|
|
1907
|
+
isEqual: isEqual,
|
|
1908
|
+
isMap: isMap,
|
|
1909
|
+
isWeakMap: isWeakMap,
|
|
1910
|
+
isSet: isSet,
|
|
1911
|
+
isWeakSet: isWeakSet,
|
|
1912
|
+
keys: keys,
|
|
1913
|
+
allKeys: allKeys,
|
|
1914
|
+
values: values,
|
|
1915
|
+
pairs: pairs,
|
|
1916
|
+
invert: invert,
|
|
1917
|
+
functions: functions,
|
|
1918
|
+
methods: functions,
|
|
1919
|
+
extend: extend,
|
|
1920
|
+
extendOwn: extendOwn,
|
|
1921
|
+
assign: extendOwn,
|
|
1922
|
+
defaults: defaults,
|
|
1923
|
+
create: create,
|
|
1924
|
+
clone: clone,
|
|
1925
|
+
tap: tap,
|
|
1926
|
+
get: get,
|
|
1927
|
+
has: has,
|
|
1928
|
+
mapObject: mapObject,
|
|
1929
|
+
identity: identity,
|
|
1930
|
+
constant: constant,
|
|
1931
|
+
noop: noop,
|
|
1932
|
+
toPath: toPath$1,
|
|
1933
|
+
property: property,
|
|
1934
|
+
propertyOf: propertyOf,
|
|
1935
|
+
matcher: matcher,
|
|
1936
|
+
matches: matcher,
|
|
1937
|
+
times: times,
|
|
1938
|
+
random: random,
|
|
1939
|
+
now: now,
|
|
1940
|
+
escape: _escape,
|
|
1941
|
+
unescape: _unescape,
|
|
1942
|
+
templateSettings: templateSettings,
|
|
1943
|
+
template: template,
|
|
1944
|
+
result: result,
|
|
1945
|
+
uniqueId: uniqueId,
|
|
1946
|
+
chain: chain,
|
|
1947
|
+
iteratee: iteratee,
|
|
1948
|
+
partial: partial,
|
|
1949
|
+
bind: bind,
|
|
1950
|
+
bindAll: bindAll,
|
|
1951
|
+
memoize: memoize,
|
|
1952
|
+
delay: delay,
|
|
1953
|
+
defer: defer,
|
|
1954
|
+
throttle: throttle,
|
|
1955
|
+
debounce: debounce,
|
|
1956
|
+
wrap: wrap,
|
|
1957
|
+
negate: negate,
|
|
1958
|
+
compose: compose,
|
|
1959
|
+
after: after,
|
|
1960
|
+
before: before,
|
|
1961
|
+
once: once,
|
|
1962
|
+
findKey: findKey,
|
|
1963
|
+
findIndex: findIndex,
|
|
1964
|
+
findLastIndex: findLastIndex,
|
|
1965
|
+
sortedIndex: sortedIndex,
|
|
1966
|
+
indexOf: indexOf,
|
|
1967
|
+
lastIndexOf: lastIndexOf,
|
|
1968
|
+
find: find,
|
|
1969
|
+
detect: find,
|
|
1970
|
+
findWhere: findWhere,
|
|
1971
|
+
each: each,
|
|
1972
|
+
forEach: each,
|
|
1973
|
+
map: map,
|
|
1974
|
+
collect: map,
|
|
1975
|
+
reduce: reduce,
|
|
1976
|
+
foldl: reduce,
|
|
1977
|
+
inject: reduce,
|
|
1978
|
+
reduceRight: reduceRight,
|
|
1979
|
+
foldr: reduceRight,
|
|
1980
|
+
filter: filter,
|
|
1981
|
+
select: filter,
|
|
1982
|
+
reject: reject,
|
|
1983
|
+
every: every,
|
|
1984
|
+
all: every,
|
|
1985
|
+
some: some,
|
|
1986
|
+
any: some,
|
|
1987
|
+
contains: contains,
|
|
1988
|
+
includes: contains,
|
|
1989
|
+
include: contains,
|
|
1990
|
+
invoke: invoke,
|
|
1991
|
+
pluck: pluck,
|
|
1992
|
+
where: where,
|
|
1993
|
+
max: max,
|
|
1994
|
+
min: min,
|
|
1995
|
+
shuffle: shuffle,
|
|
1996
|
+
sample: sample,
|
|
1997
|
+
sortBy: sortBy,
|
|
1998
|
+
groupBy: groupBy,
|
|
1999
|
+
indexBy: indexBy,
|
|
2000
|
+
countBy: countBy,
|
|
2001
|
+
partition: partition,
|
|
2002
|
+
toArray: toArray,
|
|
2003
|
+
size: size,
|
|
2004
|
+
pick: pick,
|
|
2005
|
+
omit: omit,
|
|
2006
|
+
first: first,
|
|
2007
|
+
head: first,
|
|
2008
|
+
take: first,
|
|
2009
|
+
initial: initial,
|
|
2010
|
+
last: last,
|
|
2011
|
+
rest: rest,
|
|
2012
|
+
tail: rest,
|
|
2013
|
+
drop: rest,
|
|
2014
|
+
compact: compact,
|
|
2015
|
+
flatten: flatten,
|
|
2016
|
+
without: without,
|
|
2017
|
+
uniq: uniq,
|
|
2018
|
+
unique: uniq,
|
|
2019
|
+
union: union,
|
|
2020
|
+
intersection: intersection,
|
|
2021
|
+
difference: difference,
|
|
2022
|
+
unzip: unzip,
|
|
2023
|
+
transpose: unzip,
|
|
2024
|
+
zip: zip,
|
|
2025
|
+
object: object,
|
|
2026
|
+
range: range,
|
|
2027
|
+
chunk: chunk,
|
|
2028
|
+
mixin: mixin,
|
|
2029
|
+
'default': _$1
|
|
2030
|
+
};
|
|
2031
|
+
|
|
2032
|
+
// Default Export
|
|
1671
2033
|
|
|
1672
|
-
//
|
|
1673
|
-
|
|
1674
|
-
|
|
2034
|
+
// Add all of the Underscore functions to the wrapper object.
|
|
2035
|
+
var _ = mixin(allExports);
|
|
2036
|
+
// Legacy Node.js API.
|
|
2037
|
+
_._ = _;
|
|
1675
2038
|
|
|
1676
|
-
_
|
|
1677
|
-
return String(this._wrapped);
|
|
1678
|
-
};
|
|
2039
|
+
return _;
|
|
1679
2040
|
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
// practice for AMD registration is to be anonymous, underscore registers
|
|
1683
|
-
// as a named module because, like jQuery, it is a base library that is
|
|
1684
|
-
// popular enough to be bundled in a third party lib, but not be part of
|
|
1685
|
-
// an AMD load request. Those cases could generate an error when an
|
|
1686
|
-
// anonymous define() is called outside of a loader request.
|
|
1687
|
-
if (typeof define == 'function' && define.amd) {
|
|
1688
|
-
define('underscore', [], function() {
|
|
1689
|
-
return _;
|
|
1690
|
-
});
|
|
1691
|
-
}
|
|
1692
|
-
}());
|
|
2041
|
+
})));
|
|
2042
|
+
//# sourceMappingURL=underscore-umd.js.map
|