@mjhls/mjh-framework 1.0.203 → 1.0.205

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.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/AD-e2479b7c.js +31 -0
  3. package/dist/cjs/DeckContent.js +430 -0
  4. package/dist/cjs/DeckQueue.js +366 -0
  5. package/dist/cjs/Dfp-d94f7f73.js +97 -0
  6. package/dist/cjs/GridContent.js +613 -0
  7. package/dist/cjs/GroupDeck.js +156 -0
  8. package/dist/cjs/IssueContentDeck.js +81 -0
  9. package/dist/cjs/IssueDeck.js +144 -0
  10. package/dist/cjs/MasterDeck.js +340 -0
  11. package/dist/cjs/Normal-7dd8c339.js +2374 -0
  12. package/dist/cjs/PublicationDeck.js +81 -0
  13. package/dist/cjs/QueueDeckExpanded.js +559 -0
  14. package/dist/cjs/TaxonomyCard-7b5b4298.js +1045 -0
  15. package/dist/cjs/TaxonomyCard.js +18 -0
  16. package/dist/cjs/TemplateNormal.js +29 -0
  17. package/dist/cjs/ThumbnailCard.js +58 -0
  18. package/dist/cjs/Ustream-0d3dd953.js +122 -0
  19. package/dist/cjs/Ustream.js +10 -0
  20. package/dist/cjs/VideoSeriesListing.js +248 -0
  21. package/dist/cjs/YoutubeGroup-f7707ceb.js +228 -0
  22. package/dist/cjs/YoutubeGroup.js +13 -0
  23. package/dist/cjs/_babelHelpers-f321c258.js +119 -0
  24. package/dist/cjs/_commonjsHelpers-3fc1f64e.js +20 -0
  25. package/dist/cjs/debounce-286eb3fb.js +279 -0
  26. package/dist/cjs/entities-3e0b4a16.js +506 -0
  27. package/dist/cjs/get-06aac51b.js +992 -0
  28. package/dist/cjs/index-0d0efcfa.js +610 -0
  29. package/dist/cjs/index-a4c53ff4.js +551 -0
  30. package/dist/cjs/index.es-2289df51.js +5028 -0
  31. package/dist/cjs/index.esm-340d3792.js +113 -0
  32. package/dist/cjs/index.js +12044 -0
  33. package/dist/cjs/isSymbol-311eb805.js +209 -0
  34. package/dist/cjs/main-58839f4e.js +858 -0
  35. package/dist/cjs/visibility-sensor-5c5a7302.js +2251 -0
  36. package/dist/esm/AD-1b2a3dd3.js +26 -0
  37. package/dist/esm/DeckContent.js +424 -0
  38. package/dist/esm/DeckQueue.js +360 -0
  39. package/dist/esm/Dfp-ab7941d3.js +92 -0
  40. package/dist/esm/GridContent.js +607 -0
  41. package/dist/esm/GroupDeck.js +151 -0
  42. package/dist/esm/IssueContentDeck.js +76 -0
  43. package/dist/esm/IssueDeck.js +139 -0
  44. package/dist/esm/MasterDeck.js +334 -0
  45. package/dist/esm/Normal-403c5666.js +2354 -0
  46. package/dist/esm/PublicationDeck.js +76 -0
  47. package/dist/esm/QueueDeckExpanded.js +553 -0
  48. package/dist/esm/TaxonomyCard-f9c93953.js +1039 -0
  49. package/dist/esm/TaxonomyCard.js +12 -0
  50. package/dist/esm/TemplateNormal.js +23 -0
  51. package/dist/esm/ThumbnailCard.js +53 -0
  52. package/dist/esm/Ustream-6bb45fe7.js +116 -0
  53. package/dist/esm/Ustream.js +4 -0
  54. package/dist/esm/VideoSeriesListing.js +242 -0
  55. package/dist/esm/YoutubeGroup-06df4923.js +222 -0
  56. package/dist/esm/YoutubeGroup.js +7 -0
  57. package/dist/esm/_babelHelpers-67c05996.js +111 -0
  58. package/dist/esm/_commonjsHelpers-ae1b5db5.js +15 -0
  59. package/dist/esm/debounce-a0242b4a.js +277 -0
  60. package/dist/esm/entities-e85d3a4a.js +503 -0
  61. package/dist/esm/get-b684ff61.js +990 -0
  62. package/dist/esm/index-3c1ee9ab.js +605 -0
  63. package/dist/esm/index-ca4ff5cb.js +548 -0
  64. package/dist/esm/index.es-f369b3e8.js +5022 -0
  65. package/dist/esm/index.esm-536609db.js +103 -0
  66. package/dist/esm/index.js +11991 -0
  67. package/dist/esm/isSymbol-c2b7d05a.js +203 -0
  68. package/dist/esm/main-dea495b7.js +851 -0
  69. package/dist/esm/visibility-sensor-3cfe6713.js +2243 -0
  70. package/package.json +8 -7
  71. package/dist/index.es.js +0 -30213
  72. package/dist/index.es.js.map +0 -1
  73. package/dist/index.js +0 -30271
  74. package/dist/index.js.map +0 -1
@@ -0,0 +1,228 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var React = require('react');
6
+ var React__default = _interopDefault(React);
7
+ var _commonjsHelpers = require('./_commonjsHelpers-3fc1f64e.js');
8
+ require('next/link');
9
+ var index$1 = require('./index-0d0efcfa.js');
10
+
11
+ var getYoutubeId = _commonjsHelpers.createCommonjsModule(function (module, exports) {
12
+ (function (root, factory) {
13
+ {
14
+ module.exports = factory();
15
+ }
16
+ }(_commonjsHelpers.commonjsGlobal, function (exports) {
17
+
18
+ return function (url, opts) {
19
+ if (opts == undefined) {
20
+ opts = {fuzzy: true};
21
+ }
22
+
23
+ if (/youtu\.?be/.test(url)) {
24
+
25
+ // Look first for known patterns
26
+ var i;
27
+ var patterns = [
28
+ /youtu\.be\/([^#\&\?]{11})/, // youtu.be/<id>
29
+ /\?v=([^#\&\?]{11})/, // ?v=<id>
30
+ /\&v=([^#\&\?]{11})/, // &v=<id>
31
+ /embed\/([^#\&\?]{11})/, // embed/<id>
32
+ /\/v\/([^#\&\?]{11})/ // /v/<id>
33
+ ];
34
+
35
+ // If any pattern matches, return the ID
36
+ for (i = 0; i < patterns.length; ++i) {
37
+ if (patterns[i].test(url)) {
38
+ return patterns[i].exec(url)[1];
39
+ }
40
+ }
41
+
42
+ if (opts.fuzzy) {
43
+ // If that fails, break it apart by certain characters and look
44
+ // for the 11 character key
45
+ var tokens = url.split(/[\/\&\?=#\.\s]/g);
46
+ for (i = 0; i < tokens.length; ++i) {
47
+ if (/^[^#\&\?]{11}$/.test(tokens[i])) {
48
+ return tokens[i];
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ return null;
55
+ };
56
+
57
+ }));
58
+ });
59
+
60
+ /*
61
+ GROQ query -
62
+ accepts an array of title, URL
63
+ `http://img.youtube.com/vi/${getYouTubeId(vid.url)}/hqdefault.jpg`
64
+ */
65
+ var YoutubeGroup = function YoutubeGroup(props) {
66
+ // Props should be an array of objects containing Thumbnail, title, and URL
67
+ var get2 = props.get2 ? '/' + props.get2 + '/' : '/view/';
68
+
69
+ var variant = props.dark ? 'white' : '#383838';
70
+ function scrollSlider(e, direction) {
71
+ var slide = e.target.parentElement;
72
+ var scrollOffset = slide.scrollLeft;
73
+ var viewableWidth = slide.clientWidth > 700 ? 3 * (document.querySelector('.tile').scrollWidth + 8) : document.querySelector('.tile').scrollWidth + 8;
74
+ var scrollDirection = void 0;
75
+ if (direction === 'next') {
76
+ scrollDirection = scrollOffset + viewableWidth;
77
+ }
78
+ if (direction === 'prev') {
79
+ scrollDirection = scrollOffset - viewableWidth;
80
+ }
81
+ slide.scrollTo({
82
+ left: scrollDirection,
83
+ behavior: 'smooth'
84
+ });
85
+ }
86
+ function handleClick(url, vidIndex) {
87
+ props.setState(url, vidIndex);
88
+ }
89
+ var _props$current = props.current,
90
+ current = _props$current === undefined ? '' : _props$current;
91
+
92
+
93
+ return React__default.createElement(
94
+ 'div',
95
+ { id: 'vid-slider', className: 'col' },
96
+ React__default.createElement(
97
+ 'div',
98
+ { className: 'row' },
99
+ React__default.createElement(
100
+ 'div',
101
+ { onClick: function onClick(e) {
102
+ return scrollSlider(e, 'prev');
103
+ }, className: 'tile__slider-prev', style: { color: variant } },
104
+ React__default.createElement('i', { style: { border: 'solid ' + variant, borderWidth: '0 4px 4px 0' }, className: 'arrow left' })
105
+ ),
106
+ React__default.createElement(
107
+ 'div',
108
+ { onClick: function onClick(e) {
109
+ return scrollSlider(e, 'next');
110
+ }, className: 'tile__slider-next', style: { color: variant } },
111
+ React__default.createElement('i', { style: { border: 'solid ' + variant, borderWidth: '0 4px 4px 0' }, className: 'arrow right' })
112
+ ),
113
+ React__default.createElement(
114
+ 'div',
115
+ { className: 'row__inner' },
116
+ props.dataset && props.dataset.map(function (video, index) {
117
+ // If there is a current prop, means this will overlay a currently playing video
118
+ if (current !== '') {
119
+ var url = video.url;
120
+ var thumbnail = 'http://img.youtube.com/vi/' + getYoutubeId(video.url) + '/hqdefault.jpg';
121
+
122
+ return React__default.createElement(
123
+ 'div',
124
+ { key: index, className: 'tile' },
125
+ current && current === url ? React__default.createElement(
126
+ 'div',
127
+ { className: 'now-playing' },
128
+ 'Now Playing'
129
+ ) : '',
130
+ React__default.createElement(
131
+ 'a',
132
+ { onClick: function onClick() {
133
+ return handleClick(url, index + 1);
134
+ } },
135
+ React__default.createElement(
136
+ 'div',
137
+ { className: 'tile__media' },
138
+ React__default.createElement(
139
+ index$1.LazyLoad,
140
+ null,
141
+ React__default.createElement('img', { className: 'tile__img', src: thumbnail, alt: '' })
142
+ )
143
+ ),
144
+ React__default.createElement(
145
+ 'div',
146
+ { className: 'tile__details' },
147
+ React__default.createElement(
148
+ 'div',
149
+ { className: 'tile__title' },
150
+ React__default.createElement(
151
+ 'div',
152
+ { style: { color: variant }, className: 'tile__title_text' },
153
+ video.title
154
+ )
155
+ )
156
+ ),
157
+ React__default.createElement(
158
+ 'div',
159
+ { style: { color: variant }, className: 'tile__info' },
160
+ video.title
161
+ )
162
+ )
163
+ );
164
+ } else {
165
+ // slider by itself
166
+ var _url = '' + video.link;
167
+ var _thumbnail = 'http://img.youtube.com/vi/' + getYoutubeId(video.url) + '/hqdefault.jpg';
168
+ return React__default.createElement(
169
+ 'div',
170
+ { key: index, className: 'tile' },
171
+ React__default.createElement(
172
+ 'a',
173
+ { href: _url },
174
+ React__default.createElement(
175
+ 'div',
176
+ { className: 'tile__media' },
177
+ React__default.createElement(
178
+ index$1.LazyLoad,
179
+ null,
180
+ React__default.createElement('img', { className: 'tile__img', src: _thumbnail, alt: '' })
181
+ )
182
+ ),
183
+ React__default.createElement(
184
+ 'div',
185
+ { className: 'tile__details' },
186
+ React__default.createElement(
187
+ 'div',
188
+ { className: 'tile__title' },
189
+ React__default.createElement(
190
+ 'div',
191
+ { style: { color: variant }, className: 'tile__title_text' },
192
+ video.title
193
+ )
194
+ )
195
+ ),
196
+ React__default.createElement(
197
+ 'div',
198
+ { style: { color: variant }, className: 'tile__info' },
199
+ props.displayEpisodeNumber ? React__default.createElement(
200
+ 'span',
201
+ null,
202
+ React__default.createElement(
203
+ 'span',
204
+ { style: { fontWeight: 'bold' } },
205
+ 'Ep. ',
206
+ index + 1,
207
+ ':'
208
+ ),
209
+ ' ',
210
+ video.title
211
+ ) : video.title
212
+ )
213
+ )
214
+ );
215
+ }
216
+ })
217
+ )
218
+ ),
219
+ React__default.createElement(
220
+ 'style',
221
+ { jsx: 'true' },
222
+ '\n #vid-slider * {\n box-sizing: border-box;\n }\n #vid-slider {\n position: relative;\n }\n #vid-slider .now-playing {\n position: absolute;\n top: 0.5rem;\n left: 1rem;\n color: white;\n background: rgba(0, 0, 0, 0.75);\n }\n #vid-slider h1,\n #vid-slider p {\n text-align: center;\n width: 100%;\n max-width: 500px;\n margin: auto;\n }\n #vid-slider a:link,\n #vid-slider a:hover,\n #vid-slider a:active,\n #vid-slider a:visited {\n transition: color 150ms;\n color: #95a5a6;\n text-decoration: none;\n }\n #vid-slider a:hover {\n color: #7f8c8d;\n text-decoration: underline;\n }\n #vid-slider .contain {\n width: 100%;\n }\n #vid-slider .row {\n overflow: scroll;\n width: 100%;\n }\n #vid-slider .tile__info {\n white-space: normal !important;\n position: absolute;\n text-align: center;\n color: ' + (props.dark ? 'white' : '#383838') + ';\n opacity: 1;\n font-size: 1rem;\n transition: opacity 0.25s;\n }\n #vid-slider .row__inner {\n transition: 450ms -webkit-transform;\n transition: 450ms transform;\n transition: 450ms transform, 450ms -webkit-transform;\n font-size: 0;\n white-space: nowrap;\n margin: 55px 0;\n padding-bottom: 10px;\n padding-left: 0;\n }\n #vid-slider .tile {\n position: relative;\n display: inline-block;\n width: 250px;\n height: 140.625px;\n margin-right: 10px;\n font-size: 20px;\n cursor: pointer;\n transition: 450ms all;\n -webkit-transform-origin: center left;\n transform-origin: center left;\n }\n #vid-slider .tile__img {\n width: 250px;\n height: 140.625px;\n -o-object-fit: cover;\n object-fit: cover;\n }\n #vid-slider .tile__details {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n top: 0;\n font-size: 10px;\n opacity: 0;\n background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);\n transition: 450ms opacity;\n }\n #vid-slider .tile__details:after,\n #vid-slider .tile__details:before {\n content: \'\';\n position: absolute;\n top: 50%;\n left: 50%;\n display: #000;\n }\n #vid-slider .tile__details:after {\n margin-top: -25px;\n margin-left: -25px;\n width: 50px;\n height: 50px;\n border: 3px solid #ecf0f1;\n line-height: 50px;\n text-align: center;\n border-radius: 100%;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1;\n }\n #vid-slider .tile__details:before {\n content: \'\u25B6\';\n left: 0;\n width: 100%;\n font-size: 30px;\n margin-left: 2px;\n margin-top: -23px;\n text-align: center;\n z-index: 2;\n color: white;\n }\n #vid-slider .tile:hover .tile__details {\n opacity: 1;\n }\n #vid-slider .tile__title {\n position: absolute;\n bottom: 0;\n padding: 10px;\n max-width: 250px;\n }\n #vid-slider .tile__title_text {\n position: relative;\n left: 0;\n white-space: normal;\n }\n #vid-slider .row__inner:hover {\n -webkit-transform: translate3d(-62.5px, 0, 0);\n transform: translate3d(-62.5px, 0, 0);\n }\n #vid-slider .row__inner:hover .tile {\n opacity: 0.3;\n }\n #vid-slider .row__inner:hover .tile:hover {\n -webkit-transform: scale(1.25);\n transform: scale(1.25);\n opacity: 1;\n }\n #vid-slider .tile:hover ~ .tile {\n -webkit-transform: translate3d(62px, 0, 0);\n transform: translate3d(62px, 0, 0);\n }\n #vid-slider .tile:hover .tile__info {\n opacity: 0;\n }\n #vid-slider .tile__slider-prev,\n #vid-slider .tile__slider-next {\n width: 30px;\n background: transparent;\n border: none;\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n z-index: 99;\n cursor: pointer;\n color: ' + (props.dark ? 'white' : 'black') + ';\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 2rem;\n }\n #vid-slider .tile__slider-prev {\n left: -3px;\n }\n #vid-slider .tile__slider-next {\n right: 0;\n }\n #vid-slider,\n #vid-slider .row {\n margin: 0;\n padding: 0 1.2rem;\n }\n #vid-slider .tile:last-child {\n margin-right: 2rem;\n }\n #vid-slider .row::-webkit-scrollbar-thumb {\n background-color: transparent !important;\n }\n #vid-slider i {\n border: solid ' + (props.dark ? 'white' : 'black') + ';\n border-width: 0 4px 4px 0;\n display: inline-block;\n padding: 4px;\n pointer-events: none;\n }\n\n #vid-slider .right {\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n\n #vid-slider .left {\n transform: rotate(135deg);\n -webkit-transform: rotate(135deg);\n }\n '
223
+ )
224
+ );
225
+ };
226
+
227
+ exports.YoutubeGroup = YoutubeGroup;
228
+ exports.getYoutubeId = getYoutubeId;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ require('react');
4
+ require('./_commonjsHelpers-3fc1f64e.js');
5
+ require('prop-types');
6
+ require('next/link');
7
+ require('react-dom');
8
+ require('./index-0d0efcfa.js');
9
+ var YoutubeGroup = require('./YoutubeGroup-f7707ceb.js');
10
+
11
+
12
+
13
+ module.exports = YoutubeGroup.YoutubeGroup;
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ var classCallCheck = function (instance, Constructor) {
4
+ if (!(instance instanceof Constructor)) {
5
+ throw new TypeError("Cannot call a class as a function");
6
+ }
7
+ };
8
+
9
+ var createClass = function () {
10
+ function defineProperties(target, props) {
11
+ for (var i = 0; i < props.length; i++) {
12
+ var descriptor = props[i];
13
+ descriptor.enumerable = descriptor.enumerable || false;
14
+ descriptor.configurable = true;
15
+ if ("value" in descriptor) descriptor.writable = true;
16
+ Object.defineProperty(target, descriptor.key, descriptor);
17
+ }
18
+ }
19
+
20
+ return function (Constructor, protoProps, staticProps) {
21
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
22
+ if (staticProps) defineProperties(Constructor, staticProps);
23
+ return Constructor;
24
+ };
25
+ }();
26
+
27
+ var _extends = Object.assign || function (target) {
28
+ for (var i = 1; i < arguments.length; i++) {
29
+ var source = arguments[i];
30
+
31
+ for (var key in source) {
32
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
33
+ target[key] = source[key];
34
+ }
35
+ }
36
+ }
37
+
38
+ return target;
39
+ };
40
+
41
+ var inherits = function (subClass, superClass) {
42
+ if (typeof superClass !== "function" && superClass !== null) {
43
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
44
+ }
45
+
46
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
47
+ constructor: {
48
+ value: subClass,
49
+ enumerable: false,
50
+ writable: true,
51
+ configurable: true
52
+ }
53
+ });
54
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
55
+ };
56
+
57
+ var possibleConstructorReturn = function (self, call) {
58
+ if (!self) {
59
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
60
+ }
61
+
62
+ return call && (typeof call === "object" || typeof call === "function") ? call : self;
63
+ };
64
+
65
+ var slicedToArray = function () {
66
+ function sliceIterator(arr, i) {
67
+ var _arr = [];
68
+ var _n = true;
69
+ var _d = false;
70
+ var _e = undefined;
71
+
72
+ try {
73
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
74
+ _arr.push(_s.value);
75
+
76
+ if (i && _arr.length === i) break;
77
+ }
78
+ } catch (err) {
79
+ _d = true;
80
+ _e = err;
81
+ } finally {
82
+ try {
83
+ if (!_n && _i["return"]) _i["return"]();
84
+ } finally {
85
+ if (_d) throw _e;
86
+ }
87
+ }
88
+
89
+ return _arr;
90
+ }
91
+
92
+ return function (arr, i) {
93
+ if (Array.isArray(arr)) {
94
+ return arr;
95
+ } else if (Symbol.iterator in Object(arr)) {
96
+ return sliceIterator(arr, i);
97
+ } else {
98
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
99
+ }
100
+ };
101
+ }();
102
+
103
+ var toConsumableArray = function (arr) {
104
+ if (Array.isArray(arr)) {
105
+ for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
106
+
107
+ return arr2;
108
+ } else {
109
+ return Array.from(arr);
110
+ }
111
+ };
112
+
113
+ exports._extends = _extends;
114
+ exports.classCallCheck = classCallCheck;
115
+ exports.createClass = createClass;
116
+ exports.inherits = inherits;
117
+ exports.possibleConstructorReturn = possibleConstructorReturn;
118
+ exports.slicedToArray = slicedToArray;
119
+ exports.toConsumableArray = toConsumableArray;
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
+
5
+ function commonjsRequire () {
6
+ throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
7
+ }
8
+
9
+ function unwrapExports (x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
+ }
12
+
13
+ function createCommonjsModule(fn, module) {
14
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
15
+ }
16
+
17
+ exports.commonjsGlobal = commonjsGlobal;
18
+ exports.commonjsRequire = commonjsRequire;
19
+ exports.createCommonjsModule = createCommonjsModule;
20
+ exports.unwrapExports = unwrapExports;
@@ -0,0 +1,279 @@
1
+ 'use strict';
2
+
3
+ var isSymbol$1 = require('./isSymbol-311eb805.js');
4
+
5
+ /**
6
+ * Gets the timestamp of the number of milliseconds that have elapsed since
7
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
8
+ *
9
+ * @static
10
+ * @memberOf _
11
+ * @since 2.4.0
12
+ * @category Date
13
+ * @returns {number} Returns the timestamp.
14
+ * @example
15
+ *
16
+ * _.defer(function(stamp) {
17
+ * console.log(_.now() - stamp);
18
+ * }, _.now());
19
+ * // => Logs the number of milliseconds it took for the deferred invocation.
20
+ */
21
+ var now = function() {
22
+ return isSymbol$1._root.Date.now();
23
+ };
24
+
25
+ var now_1 = now;
26
+
27
+ /** Used as references for various `Number` constants. */
28
+ var NAN = 0 / 0;
29
+
30
+ /** Used to match leading and trailing whitespace. */
31
+ var reTrim = /^\s+|\s+$/g;
32
+
33
+ /** Used to detect bad signed hexadecimal string values. */
34
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
35
+
36
+ /** Used to detect binary string values. */
37
+ var reIsBinary = /^0b[01]+$/i;
38
+
39
+ /** Used to detect octal string values. */
40
+ var reIsOctal = /^0o[0-7]+$/i;
41
+
42
+ /** Built-in method references without a dependency on `root`. */
43
+ var freeParseInt = parseInt;
44
+
45
+ /**
46
+ * Converts `value` to a number.
47
+ *
48
+ * @static
49
+ * @memberOf _
50
+ * @since 4.0.0
51
+ * @category Lang
52
+ * @param {*} value The value to process.
53
+ * @returns {number} Returns the number.
54
+ * @example
55
+ *
56
+ * _.toNumber(3.2);
57
+ * // => 3.2
58
+ *
59
+ * _.toNumber(Number.MIN_VALUE);
60
+ * // => 5e-324
61
+ *
62
+ * _.toNumber(Infinity);
63
+ * // => Infinity
64
+ *
65
+ * _.toNumber('3.2');
66
+ * // => 3.2
67
+ */
68
+ function toNumber(value) {
69
+ if (typeof value == 'number') {
70
+ return value;
71
+ }
72
+ if (isSymbol$1.isSymbol_1(value)) {
73
+ return NAN;
74
+ }
75
+ if (isSymbol$1.isObject_1(value)) {
76
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
77
+ value = isSymbol$1.isObject_1(other) ? (other + '') : other;
78
+ }
79
+ if (typeof value != 'string') {
80
+ return value === 0 ? value : +value;
81
+ }
82
+ value = value.replace(reTrim, '');
83
+ var isBinary = reIsBinary.test(value);
84
+ return (isBinary || reIsOctal.test(value))
85
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
86
+ : (reIsBadHex.test(value) ? NAN : +value);
87
+ }
88
+
89
+ var toNumber_1 = toNumber;
90
+
91
+ /** Error message constants. */
92
+ var FUNC_ERROR_TEXT = 'Expected a function';
93
+
94
+ /* Built-in method references for those with the same name as other `lodash` methods. */
95
+ var nativeMax = Math.max,
96
+ nativeMin = Math.min;
97
+
98
+ /**
99
+ * Creates a debounced function that delays invoking `func` until after `wait`
100
+ * milliseconds have elapsed since the last time the debounced function was
101
+ * invoked. The debounced function comes with a `cancel` method to cancel
102
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
103
+ * Provide `options` to indicate whether `func` should be invoked on the
104
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
105
+ * with the last arguments provided to the debounced function. Subsequent
106
+ * calls to the debounced function return the result of the last `func`
107
+ * invocation.
108
+ *
109
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
110
+ * invoked on the trailing edge of the timeout only if the debounced function
111
+ * is invoked more than once during the `wait` timeout.
112
+ *
113
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
114
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
115
+ *
116
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
117
+ * for details over the differences between `_.debounce` and `_.throttle`.
118
+ *
119
+ * @static
120
+ * @memberOf _
121
+ * @since 0.1.0
122
+ * @category Function
123
+ * @param {Function} func The function to debounce.
124
+ * @param {number} [wait=0] The number of milliseconds to delay.
125
+ * @param {Object} [options={}] The options object.
126
+ * @param {boolean} [options.leading=false]
127
+ * Specify invoking on the leading edge of the timeout.
128
+ * @param {number} [options.maxWait]
129
+ * The maximum time `func` is allowed to be delayed before it's invoked.
130
+ * @param {boolean} [options.trailing=true]
131
+ * Specify invoking on the trailing edge of the timeout.
132
+ * @returns {Function} Returns the new debounced function.
133
+ * @example
134
+ *
135
+ * // Avoid costly calculations while the window size is in flux.
136
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
137
+ *
138
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
139
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
140
+ * 'leading': true,
141
+ * 'trailing': false
142
+ * }));
143
+ *
144
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
145
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
146
+ * var source = new EventSource('/stream');
147
+ * jQuery(source).on('message', debounced);
148
+ *
149
+ * // Cancel the trailing debounced invocation.
150
+ * jQuery(window).on('popstate', debounced.cancel);
151
+ */
152
+ function debounce(func, wait, options) {
153
+ var lastArgs,
154
+ lastThis,
155
+ maxWait,
156
+ result,
157
+ timerId,
158
+ lastCallTime,
159
+ lastInvokeTime = 0,
160
+ leading = false,
161
+ maxing = false,
162
+ trailing = true;
163
+
164
+ if (typeof func != 'function') {
165
+ throw new TypeError(FUNC_ERROR_TEXT);
166
+ }
167
+ wait = toNumber_1(wait) || 0;
168
+ if (isSymbol$1.isObject_1(options)) {
169
+ leading = !!options.leading;
170
+ maxing = 'maxWait' in options;
171
+ maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait;
172
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
173
+ }
174
+
175
+ function invokeFunc(time) {
176
+ var args = lastArgs,
177
+ thisArg = lastThis;
178
+
179
+ lastArgs = lastThis = undefined;
180
+ lastInvokeTime = time;
181
+ result = func.apply(thisArg, args);
182
+ return result;
183
+ }
184
+
185
+ function leadingEdge(time) {
186
+ // Reset any `maxWait` timer.
187
+ lastInvokeTime = time;
188
+ // Start the timer for the trailing edge.
189
+ timerId = setTimeout(timerExpired, wait);
190
+ // Invoke the leading edge.
191
+ return leading ? invokeFunc(time) : result;
192
+ }
193
+
194
+ function remainingWait(time) {
195
+ var timeSinceLastCall = time - lastCallTime,
196
+ timeSinceLastInvoke = time - lastInvokeTime,
197
+ timeWaiting = wait - timeSinceLastCall;
198
+
199
+ return maxing
200
+ ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
201
+ : timeWaiting;
202
+ }
203
+
204
+ function shouldInvoke(time) {
205
+ var timeSinceLastCall = time - lastCallTime,
206
+ timeSinceLastInvoke = time - lastInvokeTime;
207
+
208
+ // Either this is the first call, activity has stopped and we're at the
209
+ // trailing edge, the system time has gone backwards and we're treating
210
+ // it as the trailing edge, or we've hit the `maxWait` limit.
211
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
212
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
213
+ }
214
+
215
+ function timerExpired() {
216
+ var time = now_1();
217
+ if (shouldInvoke(time)) {
218
+ return trailingEdge(time);
219
+ }
220
+ // Restart the timer.
221
+ timerId = setTimeout(timerExpired, remainingWait(time));
222
+ }
223
+
224
+ function trailingEdge(time) {
225
+ timerId = undefined;
226
+
227
+ // Only invoke if we have `lastArgs` which means `func` has been
228
+ // debounced at least once.
229
+ if (trailing && lastArgs) {
230
+ return invokeFunc(time);
231
+ }
232
+ lastArgs = lastThis = undefined;
233
+ return result;
234
+ }
235
+
236
+ function cancel() {
237
+ if (timerId !== undefined) {
238
+ clearTimeout(timerId);
239
+ }
240
+ lastInvokeTime = 0;
241
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
242
+ }
243
+
244
+ function flush() {
245
+ return timerId === undefined ? result : trailingEdge(now_1());
246
+ }
247
+
248
+ function debounced() {
249
+ var time = now_1(),
250
+ isInvoking = shouldInvoke(time);
251
+
252
+ lastArgs = arguments;
253
+ lastThis = this;
254
+ lastCallTime = time;
255
+
256
+ if (isInvoking) {
257
+ if (timerId === undefined) {
258
+ return leadingEdge(lastCallTime);
259
+ }
260
+ if (maxing) {
261
+ // Handle invocations in a tight loop.
262
+ clearTimeout(timerId);
263
+ timerId = setTimeout(timerExpired, wait);
264
+ return invokeFunc(lastCallTime);
265
+ }
266
+ }
267
+ if (timerId === undefined) {
268
+ timerId = setTimeout(timerExpired, wait);
269
+ }
270
+ return result;
271
+ }
272
+ debounced.cancel = cancel;
273
+ debounced.flush = flush;
274
+ return debounced;
275
+ }
276
+
277
+ var debounce_1 = debounce;
278
+
279
+ exports.debounce_1 = debounce_1;