UNPKG

307 kBJavaScriptView Raw
1(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2(function (global){
3var HOST, PATH, Promise, automation, connect, firstOrNull, httpRe, map, once, pick,
4 slice = [].slice;
5
6map = require("lodash/map");
7
8pick = require("lodash/pick");
9
10once = require("lodash/once");
11
12Promise = require("bluebird");
13
14HOST = "CHANGE_ME_HOST";
15
16PATH = "CHANGE_ME_PATH";
17
18httpRe = /^http/;
19
20firstOrNull = function(cookies) {
21 var ref;
22 return (ref = cookies[0]) != null ? ref : null;
23};
24
25connect = function(host, path, io) {
26 var client, fail, invoke, listenToCookieChanges;
27 if (io == null) {
28 io = global.io;
29 }
30 if (!io) {
31 return;
32 }
33 listenToCookieChanges = once(function() {
34 return chrome.cookies.onChanged.addListener(function(info) {
35 if (info.cause !== "overwrite") {
36 return client.emit("automation:push:request", "change:cookie", info);
37 }
38 });
39 });
40 fail = function(id, err) {
41 return client.emit("automation:response", id, {
42 __error: err.message,
43 __stack: err.stack,
44 __name: err.name
45 });
46 };
47 invoke = function() {
48 var args, id, method, respond;
49 method = arguments[0], id = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
50 respond = function(data) {
51 return client.emit("automation:response", id, {
52 response: data
53 });
54 };
55 return Promise["try"](function() {
56 return automation[method].apply(automation, args.concat(respond));
57 })["catch"](function(err) {
58 return fail(id, err);
59 });
60 };
61 client = io.connect(host, {
62 path: path,
63 transports: ["websocket"]
64 });
65 client.on("automation:request", function(id, msg, data) {
66 switch (msg) {
67 case "get:cookies":
68 return invoke("getCookies", id, data);
69 case "get:cookie":
70 return invoke("getCookie", id, data);
71 case "set:cookie":
72 return invoke("setCookie", id, data);
73 case "clear:cookies":
74 return invoke("clearCookies", id, data);
75 case "clear:cookie":
76 return invoke("clearCookie", id, data);
77 case "is:automation:client:connected":
78 return invoke("verify", id, data);
79 case "focus:browser:window":
80 return invoke("focus", id);
81 case "take:screenshot":
82 return invoke("takeScreenshot", id);
83 default:
84 return fail(id, {
85 message: "No handler registered for: '" + msg + "'"
86 });
87 }
88 });
89 client.on("connect", function() {
90 listenToCookieChanges();
91 return client.emit("automation:client:connected");
92 });
93 return client;
94};
95
96connect(HOST, PATH, global.io);
97
98automation = {
99 connect: connect,
100 getUrl: function(cookie) {
101 var prefix;
102 if (cookie == null) {
103 cookie = {};
104 }
105 prefix = cookie.secure ? "https://" : "http://";
106 return prefix + cookie.domain + cookie.path;
107 },
108 clear: function(filter) {
109 var clear;
110 if (filter == null) {
111 filter = {};
112 }
113 clear = (function(_this) {
114 return function(cookie) {
115 return new Promise(function(resolve, reject) {
116 var props, url;
117 url = _this.getUrl(cookie);
118 props = {
119 url: url,
120 name: cookie.name
121 };
122 return chrome.cookies.remove(props, function(details) {
123 var err, ref;
124 if (details) {
125 return resolve(cookie);
126 } else {
127 err = new Error("Removing cookie failed for: " + (JSON.stringify(props)));
128 return reject((ref = chrome.runtime.lastError) != null ? ref : err);
129 }
130 });
131 });
132 };
133 })(this);
134 return this.getAll(filter).map(clear);
135 },
136 getAll: function(filter) {
137 var get;
138 if (filter == null) {
139 filter = {};
140 }
141 get = function() {
142 return new Promise(function(resolve) {
143 return chrome.cookies.getAll(filter, resolve);
144 });
145 };
146 return get();
147 },
148 getCookies: function(filter, fn) {
149 return this.getAll(filter).then(fn);
150 },
151 getCookie: function(filter, fn) {
152 return this.getAll(filter).then(firstOrNull).then(fn);
153 },
154 setCookie: function(props, fn) {
155 var set;
156 if (props == null) {
157 props = {};
158 }
159 set = (function(_this) {
160 return function() {
161 return new Promise(function(resolve, reject) {
162 if (props.url == null) {
163 props.url = _this.getUrl(props);
164 }
165 return chrome.cookies.set(props, function(details) {
166 var err;
167 switch (false) {
168 case !details:
169 return resolve(details);
170 case !(err = chrome.runtime.lastError):
171 return reject(err);
172 default:
173 return resolve(null);
174 }
175 });
176 });
177 };
178 })(this);
179 return set().then(fn);
180 },
181 clearCookie: function(filter, fn) {
182 return this.clear(filter).then(firstOrNull).then(fn);
183 },
184 clearCookies: function(filter, fn) {
185 return this.clear(filter).then(fn);
186 },
187 focus: function(fn) {
188 return chrome.windows.getCurrent(function(window) {
189 return chrome.windows.update(window.id, {
190 focused: true
191 }, function() {
192 return fn();
193 });
194 });
195 },
196 query: function(data) {
197 var code, query, queryTab;
198 code = "var s; (s = document.getElementById('" + data.element + "')) && s.textContent";
199 query = function() {
200 return new Promise(function(resolve) {
201 return chrome.tabs.query({
202 windowType: "normal"
203 }, resolve);
204 });
205 };
206 queryTab = function(tab) {
207 return new Promise(function(resolve, reject) {
208 return chrome.tabs.executeScript(tab.id, {
209 code: code
210 }, function(result) {
211 if (result && result[0] === data.string) {
212 return resolve();
213 } else {
214 return reject(new Error);
215 }
216 });
217 });
218 };
219 return query().filter(function(tab) {
220 return httpRe.test(tab.url);
221 }).then(function(tabs) {
222 return map(tabs, queryTab);
223 }).any();
224 },
225 verify: function(data, fn) {
226 return this.query(data).then(fn);
227 },
228 lastFocusedWindow: function() {
229 return new Promise(function(resolve) {
230 return chrome.windows.getLastFocused(resolve);
231 });
232 },
233 takeScreenshot: function(fn) {
234 return this.lastFocusedWindow().then(function(win) {
235 return new Promise(function(resolve, reject) {
236 return chrome.tabs.captureVisibleTab(win.id, {
237 format: "png"
238 }, function(dataUrl) {
239 if (dataUrl) {
240 return resolve(dataUrl);
241 } else {
242 return reject(chrome.runtime.lastError);
243 }
244 });
245 });
246 }).then(fn);
247 }
248};
249
250module.exports = automation;
251
252
253}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
254},{"bluebird":2,"lodash/map":135,"lodash/once":137,"lodash/pick":138}],2:[function(require,module,exports){
255(function (process,global){
256/* @preserve
257 * The MIT License (MIT)
258 *
259 * Copyright (c) 2013-2017 Petka Antonov
260 *
261 * Permission is hereby granted, free of charge, to any person obtaining a copy
262 * of this software and associated documentation files (the "Software"), to deal
263 * in the Software without restriction, including without limitation the rights
264 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
265 * copies of the Software, and to permit persons to whom the Software is
266 * furnished to do so, subject to the following conditions:
267 *
268 * The above copyright notice and this permission notice shall be included in
269 * all copies or substantial portions of the Software.
270 *
271 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
272 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
273 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
274 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
275 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
276 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
277 * THE SOFTWARE.
278 *
279 */
280/**
281 * bluebird build version 3.5.0
282 * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each
283*/
284!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
285"use strict";
286module.exports = function(Promise) {
287var SomePromiseArray = Promise._SomePromiseArray;
288function any(promises) {
289 var ret = new SomePromiseArray(promises);
290 var promise = ret.promise();
291 ret.setHowMany(1);
292 ret.setUnwrap();
293 ret.init();
294 return promise;
295}
296
297Promise.any = function (promises) {
298 return any(promises);
299};
300
301Promise.prototype.any = function () {
302 return any(this);
303};
304
305};
306
307},{}],2:[function(_dereq_,module,exports){
308"use strict";
309var firstLineError;
310try {throw new Error(); } catch (e) {firstLineError = e;}
311var schedule = _dereq_("./schedule");
312var Queue = _dereq_("./queue");
313var util = _dereq_("./util");
314
315function Async() {
316 this._customScheduler = false;
317 this._isTickUsed = false;
318 this._lateQueue = new Queue(16);
319 this._normalQueue = new Queue(16);
320 this._haveDrainedQueues = false;
321 this._trampolineEnabled = true;
322 var self = this;
323 this.drainQueues = function () {
324 self._drainQueues();
325 };
326 this._schedule = schedule;
327}
328
329Async.prototype.setScheduler = function(fn) {
330 var prev = this._schedule;
331 this._schedule = fn;
332 this._customScheduler = true;
333 return prev;
334};
335
336Async.prototype.hasCustomScheduler = function() {
337 return this._customScheduler;
338};
339
340Async.prototype.enableTrampoline = function() {
341 this._trampolineEnabled = true;
342};
343
344Async.prototype.disableTrampolineIfNecessary = function() {
345 if (util.hasDevTools) {
346 this._trampolineEnabled = false;
347 }
348};
349
350Async.prototype.haveItemsQueued = function () {
351 return this._isTickUsed || this._haveDrainedQueues;
352};
353
354
355Async.prototype.fatalError = function(e, isNode) {
356 if (isNode) {
357 process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) +
358 "\n");
359 process.exit(2);
360 } else {
361 this.throwLater(e);
362 }
363};
364
365Async.prototype.throwLater = function(fn, arg) {
366 if (arguments.length === 1) {
367 arg = fn;
368 fn = function () { throw arg; };
369 }
370 if (typeof setTimeout !== "undefined") {
371 setTimeout(function() {
372 fn(arg);
373 }, 0);
374 } else try {
375 this._schedule(function() {
376 fn(arg);
377 });
378 } catch (e) {
379 throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
380 }
381};
382
383function AsyncInvokeLater(fn, receiver, arg) {
384 this._lateQueue.push(fn, receiver, arg);
385 this._queueTick();
386}
387
388function AsyncInvoke(fn, receiver, arg) {
389 this._normalQueue.push(fn, receiver, arg);
390 this._queueTick();
391}
392
393function AsyncSettlePromises(promise) {
394 this._normalQueue._pushOne(promise);
395 this._queueTick();
396}
397
398if (!util.hasDevTools) {
399 Async.prototype.invokeLater = AsyncInvokeLater;
400 Async.prototype.invoke = AsyncInvoke;
401 Async.prototype.settlePromises = AsyncSettlePromises;
402} else {
403 Async.prototype.invokeLater = function (fn, receiver, arg) {
404 if (this._trampolineEnabled) {
405 AsyncInvokeLater.call(this, fn, receiver, arg);
406 } else {
407 this._schedule(function() {
408 setTimeout(function() {
409 fn.call(receiver, arg);
410 }, 100);
411 });
412 }
413 };
414
415 Async.prototype.invoke = function (fn, receiver, arg) {
416 if (this._trampolineEnabled) {
417 AsyncInvoke.call(this, fn, receiver, arg);
418 } else {
419 this._schedule(function() {
420 fn.call(receiver, arg);
421 });
422 }
423 };
424
425 Async.prototype.settlePromises = function(promise) {
426 if (this._trampolineEnabled) {
427 AsyncSettlePromises.call(this, promise);
428 } else {
429 this._schedule(function() {
430 promise._settlePromises();
431 });
432 }
433 };
434}
435
436Async.prototype._drainQueue = function(queue) {
437 while (queue.length() > 0) {
438 var fn = queue.shift();
439 if (typeof fn !== "function") {
440 fn._settlePromises();
441 continue;
442 }
443 var receiver = queue.shift();
444 var arg = queue.shift();
445 fn.call(receiver, arg);
446 }
447};
448
449Async.prototype._drainQueues = function () {
450 this._drainQueue(this._normalQueue);
451 this._reset();
452 this._haveDrainedQueues = true;
453 this._drainQueue(this._lateQueue);
454};
455
456Async.prototype._queueTick = function () {
457 if (!this._isTickUsed) {
458 this._isTickUsed = true;
459 this._schedule(this.drainQueues);
460 }
461};
462
463Async.prototype._reset = function () {
464 this._isTickUsed = false;
465};
466
467module.exports = Async;
468module.exports.firstLineError = firstLineError;
469
470},{"./queue":26,"./schedule":29,"./util":36}],3:[function(_dereq_,module,exports){
471"use strict";
472module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
473var calledBind = false;
474var rejectThis = function(_, e) {
475 this._reject(e);
476};
477
478var targetRejected = function(e, context) {
479 context.promiseRejectionQueued = true;
480 context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
481};
482
483var bindingResolved = function(thisArg, context) {
484 if (((this._bitField & 50397184) === 0)) {
485 this._resolveCallback(context.target);
486 }
487};
488
489var bindingRejected = function(e, context) {
490 if (!context.promiseRejectionQueued) this._reject(e);
491};
492
493Promise.prototype.bind = function (thisArg) {
494 if (!calledBind) {
495 calledBind = true;
496 Promise.prototype._propagateFrom = debug.propagateFromFunction();
497 Promise.prototype._boundValue = debug.boundValueFunction();
498 }
499 var maybePromise = tryConvertToPromise(thisArg);
500 var ret = new Promise(INTERNAL);
501 ret._propagateFrom(this, 1);
502 var target = this._target();
503 ret._setBoundTo(maybePromise);
504 if (maybePromise instanceof Promise) {
505 var context = {
506 promiseRejectionQueued: false,
507 promise: ret,
508 target: target,
509 bindingPromise: maybePromise
510 };
511 target._then(INTERNAL, targetRejected, undefined, ret, context);
512 maybePromise._then(
513 bindingResolved, bindingRejected, undefined, ret, context);
514 ret._setOnCancel(maybePromise);
515 } else {
516 ret._resolveCallback(target);
517 }
518 return ret;
519};
520
521Promise.prototype._setBoundTo = function (obj) {
522 if (obj !== undefined) {
523 this._bitField = this._bitField | 2097152;
524 this._boundTo = obj;
525 } else {
526 this._bitField = this._bitField & (~2097152);
527 }
528};
529
530Promise.prototype._isBound = function () {
531 return (this._bitField & 2097152) === 2097152;
532};
533
534Promise.bind = function (thisArg, value) {
535 return Promise.resolve(value).bind(thisArg);
536};
537};
538
539},{}],4:[function(_dereq_,module,exports){
540"use strict";
541var old;
542if (typeof Promise !== "undefined") old = Promise;
543function noConflict() {
544 try { if (Promise === bluebird) Promise = old; }
545 catch (e) {}
546 return bluebird;
547}
548var bluebird = _dereq_("./promise")();
549bluebird.noConflict = noConflict;
550module.exports = bluebird;
551
552},{"./promise":22}],5:[function(_dereq_,module,exports){
553"use strict";
554var cr = Object.create;
555if (cr) {
556 var callerCache = cr(null);
557 var getterCache = cr(null);
558 callerCache[" size"] = getterCache[" size"] = 0;
559}
560
561module.exports = function(Promise) {
562var util = _dereq_("./util");
563var canEvaluate = util.canEvaluate;
564var isIdentifier = util.isIdentifier;
565
566var getMethodCaller;
567var getGetter;
568if (!true) {
569var makeMethodCaller = function (methodName) {
570 return new Function("ensureMethod", " \n\
571 return function(obj) { \n\
572 'use strict' \n\
573 var len = this.length; \n\
574 ensureMethod(obj, 'methodName'); \n\
575 switch(len) { \n\
576 case 1: return obj.methodName(this[0]); \n\
577 case 2: return obj.methodName(this[0], this[1]); \n\
578 case 3: return obj.methodName(this[0], this[1], this[2]); \n\
579 case 0: return obj.methodName(); \n\
580 default: \n\
581 return obj.methodName.apply(obj, this); \n\
582 } \n\
583 }; \n\
584 ".replace(/methodName/g, methodName))(ensureMethod);
585};
586
587var makeGetter = function (propertyName) {
588 return new Function("obj", " \n\
589 'use strict'; \n\
590 return obj.propertyName; \n\
591 ".replace("propertyName", propertyName));
592};
593
594var getCompiled = function(name, compiler, cache) {
595 var ret = cache[name];
596 if (typeof ret !== "function") {
597 if (!isIdentifier(name)) {
598 return null;
599 }
600 ret = compiler(name);
601 cache[name] = ret;
602 cache[" size"]++;
603 if (cache[" size"] > 512) {
604 var keys = Object.keys(cache);
605 for (var i = 0; i < 256; ++i) delete cache[keys[i]];
606 cache[" size"] = keys.length - 256;
607 }
608 }
609 return ret;
610};
611
612getMethodCaller = function(name) {
613 return getCompiled(name, makeMethodCaller, callerCache);
614};
615
616getGetter = function(name) {
617 return getCompiled(name, makeGetter, getterCache);
618};
619}
620
621function ensureMethod(obj, methodName) {
622 var fn;
623 if (obj != null) fn = obj[methodName];
624 if (typeof fn !== "function") {
625 var message = "Object " + util.classString(obj) + " has no method '" +
626 util.toString(methodName) + "'";
627 throw new Promise.TypeError(message);
628 }
629 return fn;
630}
631
632function caller(obj) {
633 var methodName = this.pop();
634 var fn = ensureMethod(obj, methodName);
635 return fn.apply(obj, this);
636}
637Promise.prototype.call = function (methodName) {
638 var args = [].slice.call(arguments, 1);;
639 if (!true) {
640 if (canEvaluate) {
641 var maybeCaller = getMethodCaller(methodName);
642 if (maybeCaller !== null) {
643 return this._then(
644 maybeCaller, undefined, undefined, args, undefined);
645 }
646 }
647 }
648 args.push(methodName);
649 return this._then(caller, undefined, undefined, args, undefined);
650};
651
652function namedGetter(obj) {
653 return obj[this];
654}
655function indexedGetter(obj) {
656 var index = +this;
657 if (index < 0) index = Math.max(0, index + obj.length);
658 return obj[index];
659}
660Promise.prototype.get = function (propertyName) {
661 var isIndex = (typeof propertyName === "number");
662 var getter;
663 if (!isIndex) {
664 if (canEvaluate) {
665 var maybeGetter = getGetter(propertyName);
666 getter = maybeGetter !== null ? maybeGetter : namedGetter;
667 } else {
668 getter = namedGetter;
669 }
670 } else {
671 getter = indexedGetter;
672 }
673 return this._then(getter, undefined, undefined, propertyName, undefined);
674};
675};
676
677},{"./util":36}],6:[function(_dereq_,module,exports){
678"use strict";
679module.exports = function(Promise, PromiseArray, apiRejection, debug) {
680var util = _dereq_("./util");
681var tryCatch = util.tryCatch;
682var errorObj = util.errorObj;
683var async = Promise._async;
684
685Promise.prototype["break"] = Promise.prototype.cancel = function() {
686 if (!debug.cancellation()) return this._warn("cancellation is disabled");
687
688 var promise = this;
689 var child = promise;
690 while (promise._isCancellable()) {
691 if (!promise._cancelBy(child)) {
692 if (child._isFollowing()) {
693 child._followee().cancel();
694 } else {
695 child._cancelBranched();
696 }
697 break;
698 }
699
700 var parent = promise._cancellationParent;
701 if (parent == null || !parent._isCancellable()) {
702 if (promise._isFollowing()) {
703 promise._followee().cancel();
704 } else {
705 promise._cancelBranched();
706 }
707 break;
708 } else {
709 if (promise._isFollowing()) promise._followee().cancel();
710 promise._setWillBeCancelled();
711 child = promise;
712 promise = parent;
713 }
714 }
715};
716
717Promise.prototype._branchHasCancelled = function() {
718 this._branchesRemainingToCancel--;
719};
720
721Promise.prototype._enoughBranchesHaveCancelled = function() {
722 return this._branchesRemainingToCancel === undefined ||
723 this._branchesRemainingToCancel <= 0;
724};
725
726Promise.prototype._cancelBy = function(canceller) {
727 if (canceller === this) {
728 this._branchesRemainingToCancel = 0;
729 this._invokeOnCancel();
730 return true;
731 } else {
732 this._branchHasCancelled();
733 if (this._enoughBranchesHaveCancelled()) {
734 this._invokeOnCancel();
735 return true;
736 }
737 }
738 return false;
739};
740
741Promise.prototype._cancelBranched = function() {
742 if (this._enoughBranchesHaveCancelled()) {
743 this._cancel();
744 }
745};
746
747Promise.prototype._cancel = function() {
748 if (!this._isCancellable()) return;
749 this._setCancelled();
750 async.invoke(this._cancelPromises, this, undefined);
751};
752
753Promise.prototype._cancelPromises = function() {
754 if (this._length() > 0) this._settlePromises();
755};
756
757Promise.prototype._unsetOnCancel = function() {
758 this._onCancelField = undefined;
759};
760
761Promise.prototype._isCancellable = function() {
762 return this.isPending() && !this._isCancelled();
763};
764
765Promise.prototype.isCancellable = function() {
766 return this.isPending() && !this.isCancelled();
767};
768
769Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
770 if (util.isArray(onCancelCallback)) {
771 for (var i = 0; i < onCancelCallback.length; ++i) {
772 this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
773 }
774 } else if (onCancelCallback !== undefined) {
775 if (typeof onCancelCallback === "function") {
776 if (!internalOnly) {
777 var e = tryCatch(onCancelCallback).call(this._boundValue());
778 if (e === errorObj) {
779 this._attachExtraTrace(e.e);
780 async.throwLater(e.e);
781 }
782 }
783 } else {
784 onCancelCallback._resultCancelled(this);
785 }
786 }
787};
788
789Promise.prototype._invokeOnCancel = function() {
790 var onCancelCallback = this._onCancel();
791 this._unsetOnCancel();
792 async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
793};
794
795Promise.prototype._invokeInternalOnCancel = function() {
796 if (this._isCancellable()) {
797 this._doInvokeOnCancel(this._onCancel(), true);
798 this._unsetOnCancel();
799 }
800};
801
802Promise.prototype._resultCancelled = function() {
803 this.cancel();
804};
805
806};
807
808},{"./util":36}],7:[function(_dereq_,module,exports){
809"use strict";
810module.exports = function(NEXT_FILTER) {
811var util = _dereq_("./util");
812var getKeys = _dereq_("./es5").keys;
813var tryCatch = util.tryCatch;
814var errorObj = util.errorObj;
815
816function catchFilter(instances, cb, promise) {
817 return function(e) {
818 var boundTo = promise._boundValue();
819 predicateLoop: for (var i = 0; i < instances.length; ++i) {
820 var item = instances[i];
821
822 if (item === Error ||
823 (item != null && item.prototype instanceof Error)) {
824 if (e instanceof item) {
825 return tryCatch(cb).call(boundTo, e);
826 }
827 } else if (typeof item === "function") {
828 var matchesPredicate = tryCatch(item).call(boundTo, e);
829 if (matchesPredicate === errorObj) {
830 return matchesPredicate;
831 } else if (matchesPredicate) {
832 return tryCatch(cb).call(boundTo, e);
833 }
834 } else if (util.isObject(e)) {
835 var keys = getKeys(item);
836 for (var j = 0; j < keys.length; ++j) {
837 var key = keys[j];
838 if (item[key] != e[key]) {
839 continue predicateLoop;
840 }
841 }
842 return tryCatch(cb).call(boundTo, e);
843 }
844 }
845 return NEXT_FILTER;
846 };
847}
848
849return catchFilter;
850};
851
852},{"./es5":13,"./util":36}],8:[function(_dereq_,module,exports){
853"use strict";
854module.exports = function(Promise) {
855var longStackTraces = false;
856var contextStack = [];
857
858Promise.prototype._promiseCreated = function() {};
859Promise.prototype._pushContext = function() {};
860Promise.prototype._popContext = function() {return null;};
861Promise._peekContext = Promise.prototype._peekContext = function() {};
862
863function Context() {
864 this._trace = new Context.CapturedTrace(peekContext());
865}
866Context.prototype._pushContext = function () {
867 if (this._trace !== undefined) {
868 this._trace._promiseCreated = null;
869 contextStack.push(this._trace);
870 }
871};
872
873Context.prototype._popContext = function () {
874 if (this._trace !== undefined) {
875 var trace = contextStack.pop();
876 var ret = trace._promiseCreated;
877 trace._promiseCreated = null;
878 return ret;
879 }
880 return null;
881};
882
883function createContext() {
884 if (longStackTraces) return new Context();
885}
886
887function peekContext() {
888 var lastIndex = contextStack.length - 1;
889 if (lastIndex >= 0) {
890 return contextStack[lastIndex];
891 }
892 return undefined;
893}
894Context.CapturedTrace = null;
895Context.create = createContext;
896Context.deactivateLongStackTraces = function() {};
897Context.activateLongStackTraces = function() {
898 var Promise_pushContext = Promise.prototype._pushContext;
899 var Promise_popContext = Promise.prototype._popContext;
900 var Promise_PeekContext = Promise._peekContext;
901 var Promise_peekContext = Promise.prototype._peekContext;
902 var Promise_promiseCreated = Promise.prototype._promiseCreated;
903 Context.deactivateLongStackTraces = function() {
904 Promise.prototype._pushContext = Promise_pushContext;
905 Promise.prototype._popContext = Promise_popContext;
906 Promise._peekContext = Promise_PeekContext;
907 Promise.prototype._peekContext = Promise_peekContext;
908 Promise.prototype._promiseCreated = Promise_promiseCreated;
909 longStackTraces = false;
910 };
911 longStackTraces = true;
912 Promise.prototype._pushContext = Context.prototype._pushContext;
913 Promise.prototype._popContext = Context.prototype._popContext;
914 Promise._peekContext = Promise.prototype._peekContext = peekContext;
915 Promise.prototype._promiseCreated = function() {
916 var ctx = this._peekContext();
917 if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this;
918 };
919};
920return Context;
921};
922
923},{}],9:[function(_dereq_,module,exports){
924"use strict";
925module.exports = function(Promise, Context) {
926var getDomain = Promise._getDomain;
927var async = Promise._async;
928var Warning = _dereq_("./errors").Warning;
929var util = _dereq_("./util");
930var canAttachTrace = util.canAttachTrace;
931var unhandledRejectionHandled;
932var possiblyUnhandledRejection;
933var bluebirdFramePattern =
934 /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
935var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/;
936var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/;
937var stackFramePattern = null;
938var formatStack = null;
939var indentStackFrames = false;
940var printWarning;
941var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 &&
942 (true ||
943 util.env("BLUEBIRD_DEBUG") ||
944 util.env("NODE_ENV") === "development"));
945
946var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 &&
947 (debugging || util.env("BLUEBIRD_WARNINGS")));
948
949var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 &&
950 (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES")));
951
952var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 &&
953 (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN"));
954
955Promise.prototype.suppressUnhandledRejections = function() {
956 var target = this._target();
957 target._bitField = ((target._bitField & (~1048576)) |
958 524288);
959};
960
961Promise.prototype._ensurePossibleRejectionHandled = function () {
962 if ((this._bitField & 524288) !== 0) return;
963 this._setRejectionIsUnhandled();
964 async.invokeLater(this._notifyUnhandledRejection, this, undefined);
965};
966
967Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
968 fireRejectionEvent("rejectionHandled",
969 unhandledRejectionHandled, undefined, this);
970};
971
972Promise.prototype._setReturnedNonUndefined = function() {
973 this._bitField = this._bitField | 268435456;
974};
975
976Promise.prototype._returnedNonUndefined = function() {
977 return (this._bitField & 268435456) !== 0;
978};
979
980Promise.prototype._notifyUnhandledRejection = function () {
981 if (this._isRejectionUnhandled()) {
982 var reason = this._settledValue();
983 this._setUnhandledRejectionIsNotified();
984 fireRejectionEvent("unhandledRejection",
985 possiblyUnhandledRejection, reason, this);
986 }
987};
988
989Promise.prototype._setUnhandledRejectionIsNotified = function () {
990 this._bitField = this._bitField | 262144;
991};
992
993Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
994 this._bitField = this._bitField & (~262144);
995};
996
997Promise.prototype._isUnhandledRejectionNotified = function () {
998 return (this._bitField & 262144) > 0;
999};
1000
1001Promise.prototype._setRejectionIsUnhandled = function () {
1002 this._bitField = this._bitField | 1048576;
1003};
1004
1005Promise.prototype._unsetRejectionIsUnhandled = function () {
1006 this._bitField = this._bitField & (~1048576);
1007 if (this._isUnhandledRejectionNotified()) {
1008 this._unsetUnhandledRejectionIsNotified();
1009 this._notifyUnhandledRejectionIsHandled();
1010 }
1011};
1012
1013Promise.prototype._isRejectionUnhandled = function () {
1014 return (this._bitField & 1048576) > 0;
1015};
1016
1017Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) {
1018 return warn(message, shouldUseOwnTrace, promise || this);
1019};
1020
1021Promise.onPossiblyUnhandledRejection = function (fn) {
1022 var domain = getDomain();
1023 possiblyUnhandledRejection =
1024 typeof fn === "function" ? (domain === null ?
1025 fn : util.domainBind(domain, fn))
1026 : undefined;
1027};
1028
1029Promise.onUnhandledRejectionHandled = function (fn) {
1030 var domain = getDomain();
1031 unhandledRejectionHandled =
1032 typeof fn === "function" ? (domain === null ?
1033 fn : util.domainBind(domain, fn))
1034 : undefined;
1035};
1036
1037var disableLongStackTraces = function() {};
1038Promise.longStackTraces = function () {
1039 if (async.haveItemsQueued() && !config.longStackTraces) {
1040 throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
1041 }
1042 if (!config.longStackTraces && longStackTracesIsSupported()) {
1043 var Promise_captureStackTrace = Promise.prototype._captureStackTrace;
1044 var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace;
1045 config.longStackTraces = true;
1046 disableLongStackTraces = function() {
1047 if (async.haveItemsQueued() && !config.longStackTraces) {
1048 throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
1049 }
1050 Promise.prototype._captureStackTrace = Promise_captureStackTrace;
1051 Promise.prototype._attachExtraTrace = Promise_attachExtraTrace;
1052 Context.deactivateLongStackTraces();
1053 async.enableTrampoline();
1054 config.longStackTraces = false;
1055 };
1056 Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace;
1057 Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace;
1058 Context.activateLongStackTraces();
1059 async.disableTrampolineIfNecessary();
1060 }
1061};
1062
1063Promise.hasLongStackTraces = function () {
1064 return config.longStackTraces && longStackTracesIsSupported();
1065};
1066
1067var fireDomEvent = (function() {
1068 try {
1069 if (typeof CustomEvent === "function") {
1070 var event = new CustomEvent("CustomEvent");
1071 util.global.dispatchEvent(event);
1072 return function(name, event) {
1073 var domEvent = new CustomEvent(name.toLowerCase(), {
1074 detail: event,
1075 cancelable: true
1076 });
1077 return !util.global.dispatchEvent(domEvent);
1078 };
1079 } else if (typeof Event === "function") {
1080 var event = new Event("CustomEvent");
1081 util.global.dispatchEvent(event);
1082 return function(name, event) {
1083 var domEvent = new Event(name.toLowerCase(), {
1084 cancelable: true
1085 });
1086 domEvent.detail = event;
1087 return !util.global.dispatchEvent(domEvent);
1088 };
1089 } else {
1090 var event = document.createEvent("CustomEvent");
1091 event.initCustomEvent("testingtheevent", false, true, {});
1092 util.global.dispatchEvent(event);
1093 return function(name, event) {
1094 var domEvent = document.createEvent("CustomEvent");
1095 domEvent.initCustomEvent(name.toLowerCase(), false, true,
1096 event);
1097 return !util.global.dispatchEvent(domEvent);
1098 };
1099 }
1100 } catch (e) {}
1101 return function() {
1102 return false;
1103 };
1104})();
1105
1106var fireGlobalEvent = (function() {
1107 if (util.isNode) {
1108 return function() {
1109 return process.emit.apply(process, arguments);
1110 };
1111 } else {
1112 if (!util.global) {
1113 return function() {
1114 return false;
1115 };
1116 }
1117 return function(name) {
1118 var methodName = "on" + name.toLowerCase();
1119 var method = util.global[methodName];
1120 if (!method) return false;
1121 method.apply(util.global, [].slice.call(arguments, 1));
1122 return true;
1123 };
1124 }
1125})();
1126
1127function generatePromiseLifecycleEventObject(name, promise) {
1128 return {promise: promise};
1129}
1130
1131var eventToObjectGenerator = {
1132 promiseCreated: generatePromiseLifecycleEventObject,
1133 promiseFulfilled: generatePromiseLifecycleEventObject,
1134 promiseRejected: generatePromiseLifecycleEventObject,
1135 promiseResolved: generatePromiseLifecycleEventObject,
1136 promiseCancelled: generatePromiseLifecycleEventObject,
1137 promiseChained: function(name, promise, child) {
1138 return {promise: promise, child: child};
1139 },
1140 warning: function(name, warning) {
1141 return {warning: warning};
1142 },
1143 unhandledRejection: function (name, reason, promise) {
1144 return {reason: reason, promise: promise};
1145 },
1146 rejectionHandled: generatePromiseLifecycleEventObject
1147};
1148
1149var activeFireEvent = function (name) {
1150 var globalEventFired = false;
1151 try {
1152 globalEventFired = fireGlobalEvent.apply(null, arguments);
1153 } catch (e) {
1154 async.throwLater(e);
1155 globalEventFired = true;
1156 }
1157
1158 var domEventFired = false;
1159 try {
1160 domEventFired = fireDomEvent(name,
1161 eventToObjectGenerator[name].apply(null, arguments));
1162 } catch (e) {
1163 async.throwLater(e);
1164 domEventFired = true;
1165 }
1166
1167 return domEventFired || globalEventFired;
1168};
1169
1170Promise.config = function(opts) {
1171 opts = Object(opts);
1172 if ("longStackTraces" in opts) {
1173 if (opts.longStackTraces) {
1174 Promise.longStackTraces();
1175 } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) {
1176 disableLongStackTraces();
1177 }
1178 }
1179 if ("warnings" in opts) {
1180 var warningsOption = opts.warnings;
1181 config.warnings = !!warningsOption;
1182 wForgottenReturn = config.warnings;
1183
1184 if (util.isObject(warningsOption)) {
1185 if ("wForgottenReturn" in warningsOption) {
1186 wForgottenReturn = !!warningsOption.wForgottenReturn;
1187 }
1188 }
1189 }
1190 if ("cancellation" in opts && opts.cancellation && !config.cancellation) {
1191 if (async.haveItemsQueued()) {
1192 throw new Error(
1193 "cannot enable cancellation after promises are in use");
1194 }
1195 Promise.prototype._clearCancellationData =
1196 cancellationClearCancellationData;
1197 Promise.prototype._propagateFrom = cancellationPropagateFrom;
1198 Promise.prototype._onCancel = cancellationOnCancel;
1199 Promise.prototype._setOnCancel = cancellationSetOnCancel;
1200 Promise.prototype._attachCancellationCallback =
1201 cancellationAttachCancellationCallback;
1202 Promise.prototype._execute = cancellationExecute;
1203 propagateFromFunction = cancellationPropagateFrom;
1204 config.cancellation = true;
1205 }
1206 if ("monitoring" in opts) {
1207 if (opts.monitoring && !config.monitoring) {
1208 config.monitoring = true;
1209 Promise.prototype._fireEvent = activeFireEvent;
1210 } else if (!opts.monitoring && config.monitoring) {
1211 config.monitoring = false;
1212 Promise.prototype._fireEvent = defaultFireEvent;
1213 }
1214 }
1215 return Promise;
1216};
1217
1218function defaultFireEvent() { return false; }
1219
1220Promise.prototype._fireEvent = defaultFireEvent;
1221Promise.prototype._execute = function(executor, resolve, reject) {
1222 try {
1223 executor(resolve, reject);
1224 } catch (e) {
1225 return e;
1226 }
1227};
1228Promise.prototype._onCancel = function () {};
1229Promise.prototype._setOnCancel = function (handler) { ; };
1230Promise.prototype._attachCancellationCallback = function(onCancel) {
1231 ;
1232};
1233Promise.prototype._captureStackTrace = function () {};
1234Promise.prototype._attachExtraTrace = function () {};
1235Promise.prototype._clearCancellationData = function() {};
1236Promise.prototype._propagateFrom = function (parent, flags) {
1237 ;
1238 ;
1239};
1240
1241function cancellationExecute(executor, resolve, reject) {
1242 var promise = this;
1243 try {
1244 executor(resolve, reject, function(onCancel) {
1245 if (typeof onCancel !== "function") {
1246 throw new TypeError("onCancel must be a function, got: " +
1247 util.toString(onCancel));
1248 }
1249 promise._attachCancellationCallback(onCancel);
1250 });
1251 } catch (e) {
1252 return e;
1253 }
1254}
1255
1256function cancellationAttachCancellationCallback(onCancel) {
1257 if (!this._isCancellable()) return this;
1258
1259 var previousOnCancel = this._onCancel();
1260 if (previousOnCancel !== undefined) {
1261 if (util.isArray(previousOnCancel)) {
1262 previousOnCancel.push(onCancel);
1263 } else {
1264 this._setOnCancel([previousOnCancel, onCancel]);
1265 }
1266 } else {
1267 this._setOnCancel(onCancel);
1268 }
1269}
1270
1271function cancellationOnCancel() {
1272 return this._onCancelField;
1273}
1274
1275function cancellationSetOnCancel(onCancel) {
1276 this._onCancelField = onCancel;
1277}
1278
1279function cancellationClearCancellationData() {
1280 this._cancellationParent = undefined;
1281 this._onCancelField = undefined;
1282}
1283
1284function cancellationPropagateFrom(parent, flags) {
1285 if ((flags & 1) !== 0) {
1286 this._cancellationParent = parent;
1287 var branchesRemainingToCancel = parent._branchesRemainingToCancel;
1288 if (branchesRemainingToCancel === undefined) {
1289 branchesRemainingToCancel = 0;
1290 }
1291 parent._branchesRemainingToCancel = branchesRemainingToCancel + 1;
1292 }
1293 if ((flags & 2) !== 0 && parent._isBound()) {
1294 this._setBoundTo(parent._boundTo);
1295 }
1296}
1297
1298function bindingPropagateFrom(parent, flags) {
1299 if ((flags & 2) !== 0 && parent._isBound()) {
1300 this._setBoundTo(parent._boundTo);
1301 }
1302}
1303var propagateFromFunction = bindingPropagateFrom;
1304
1305function boundValueFunction() {
1306 var ret = this._boundTo;
1307 if (ret !== undefined) {
1308 if (ret instanceof Promise) {
1309 if (ret.isFulfilled()) {
1310 return ret.value();
1311 } else {
1312 return undefined;
1313 }
1314 }
1315 }
1316 return ret;
1317}
1318
1319function longStackTracesCaptureStackTrace() {
1320 this._trace = new CapturedTrace(this._peekContext());
1321}
1322
1323function longStackTracesAttachExtraTrace(error, ignoreSelf) {
1324 if (canAttachTrace(error)) {
1325 var trace = this._trace;
1326 if (trace !== undefined) {
1327 if (ignoreSelf) trace = trace._parent;
1328 }
1329 if (trace !== undefined) {
1330 trace.attachExtraTrace(error);
1331 } else if (!error.__stackCleaned__) {
1332 var parsed = parseStackAndMessage(error);
1333 util.notEnumerableProp(error, "stack",
1334 parsed.message + "\n" + parsed.stack.join("\n"));
1335 util.notEnumerableProp(error, "__stackCleaned__", true);
1336 }
1337 }
1338}
1339
1340function checkForgottenReturns(returnValue, promiseCreated, name, promise,
1341 parent) {
1342 if (returnValue === undefined && promiseCreated !== null &&
1343 wForgottenReturn) {
1344 if (parent !== undefined && parent._returnedNonUndefined()) return;
1345 if ((promise._bitField & 65535) === 0) return;
1346
1347 if (name) name = name + " ";
1348 var handlerLine = "";
1349 var creatorLine = "";
1350 if (promiseCreated._trace) {
1351 var traceLines = promiseCreated._trace.stack.split("\n");
1352 var stack = cleanStack(traceLines);
1353 for (var i = stack.length - 1; i >= 0; --i) {
1354 var line = stack[i];
1355 if (!nodeFramePattern.test(line)) {
1356 var lineMatches = line.match(parseLinePattern);
1357 if (lineMatches) {
1358 handlerLine = "at " + lineMatches[1] +
1359 ":" + lineMatches[2] + ":" + lineMatches[3] + " ";
1360 }
1361 break;
1362 }
1363 }
1364
1365 if (stack.length > 0) {
1366 var firstUserLine = stack[0];
1367 for (var i = 0; i < traceLines.length; ++i) {
1368
1369 if (traceLines[i] === firstUserLine) {
1370 if (i > 0) {
1371 creatorLine = "\n" + traceLines[i - 1];
1372 }
1373 break;
1374 }
1375 }
1376
1377 }
1378 }
1379 var msg = "a promise was created in a " + name +
1380 "handler " + handlerLine + "but was not returned from it, " +
1381 "see http://goo.gl/rRqMUw" +
1382 creatorLine;
1383 promise._warn(msg, true, promiseCreated);
1384 }
1385}
1386
1387function deprecated(name, replacement) {
1388 var message = name +
1389 " is deprecated and will be removed in a future version.";
1390 if (replacement) message += " Use " + replacement + " instead.";
1391 return warn(message);
1392}
1393
1394function warn(message, shouldUseOwnTrace, promise) {
1395 if (!config.warnings) return;
1396 var warning = new Warning(message);
1397 var ctx;
1398 if (shouldUseOwnTrace) {
1399 promise._attachExtraTrace(warning);
1400 } else if (config.longStackTraces && (ctx = Promise._peekContext())) {
1401 ctx.attachExtraTrace(warning);
1402 } else {
1403 var parsed = parseStackAndMessage(warning);
1404 warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
1405 }
1406
1407 if (!activeFireEvent("warning", warning)) {
1408 formatAndLogError(warning, "", true);
1409 }
1410}
1411
1412function reconstructStack(message, stacks) {
1413 for (var i = 0; i < stacks.length - 1; ++i) {
1414 stacks[i].push("From previous event:");
1415 stacks[i] = stacks[i].join("\n");
1416 }
1417 if (i < stacks.length) {
1418 stacks[i] = stacks[i].join("\n");
1419 }
1420 return message + "\n" + stacks.join("\n");
1421}
1422
1423function removeDuplicateOrEmptyJumps(stacks) {
1424 for (var i = 0; i < stacks.length; ++i) {
1425 if (stacks[i].length === 0 ||
1426 ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
1427 stacks.splice(i, 1);
1428 i--;
1429 }
1430 }
1431}
1432
1433function removeCommonRoots(stacks) {
1434 var current = stacks[0];
1435 for (var i = 1; i < stacks.length; ++i) {
1436 var prev = stacks[i];
1437 var currentLastIndex = current.length - 1;
1438 var currentLastLine = current[currentLastIndex];
1439 var commonRootMeetPoint = -1;
1440
1441 for (var j = prev.length - 1; j >= 0; --j) {
1442 if (prev[j] === currentLastLine) {
1443 commonRootMeetPoint = j;
1444 break;
1445 }
1446 }
1447
1448 for (var j = commonRootMeetPoint; j >= 0; --j) {
1449 var line = prev[j];
1450 if (current[currentLastIndex] === line) {
1451 current.pop();
1452 currentLastIndex--;
1453 } else {
1454 break;
1455 }
1456 }
1457 current = prev;
1458 }
1459}
1460
1461function cleanStack(stack) {
1462 var ret = [];
1463 for (var i = 0; i < stack.length; ++i) {
1464 var line = stack[i];
1465 var isTraceLine = " (No stack trace)" === line ||
1466 stackFramePattern.test(line);
1467 var isInternalFrame = isTraceLine && shouldIgnore(line);
1468 if (isTraceLine && !isInternalFrame) {
1469 if (indentStackFrames && line.charAt(0) !== " ") {
1470 line = " " + line;
1471 }
1472 ret.push(line);
1473 }
1474 }
1475 return ret;
1476}
1477
1478function stackFramesAsArray(error) {
1479 var stack = error.stack.replace(/\s+$/g, "").split("\n");
1480 for (var i = 0; i < stack.length; ++i) {
1481 var line = stack[i];
1482 if (" (No stack trace)" === line || stackFramePattern.test(line)) {
1483 break;
1484 }
1485 }
1486 if (i > 0 && error.name != "SyntaxError") {
1487 stack = stack.slice(i);
1488 }
1489 return stack;
1490}
1491
1492function parseStackAndMessage(error) {
1493 var stack = error.stack;
1494 var message = error.toString();
1495 stack = typeof stack === "string" && stack.length > 0
1496 ? stackFramesAsArray(error) : [" (No stack trace)"];
1497 return {
1498 message: message,
1499 stack: error.name == "SyntaxError" ? stack : cleanStack(stack)
1500 };
1501}
1502
1503function formatAndLogError(error, title, isSoft) {
1504 if (typeof console !== "undefined") {
1505 var message;
1506 if (util.isObject(error)) {
1507 var stack = error.stack;
1508 message = title + formatStack(stack, error);
1509 } else {
1510 message = title + String(error);
1511 }
1512 if (typeof printWarning === "function") {
1513 printWarning(message, isSoft);
1514 } else if (typeof console.log === "function" ||
1515 typeof console.log === "object") {
1516 console.log(message);
1517 }
1518 }
1519}
1520
1521function fireRejectionEvent(name, localHandler, reason, promise) {
1522 var localEventFired = false;
1523 try {
1524 if (typeof localHandler === "function") {
1525 localEventFired = true;
1526 if (name === "rejectionHandled") {
1527 localHandler(promise);
1528 } else {
1529 localHandler(reason, promise);
1530 }
1531 }
1532 } catch (e) {
1533 async.throwLater(e);
1534 }
1535
1536 if (name === "unhandledRejection") {
1537 if (!activeFireEvent(name, reason, promise) && !localEventFired) {
1538 formatAndLogError(reason, "Unhandled rejection ");
1539 }
1540 } else {
1541 activeFireEvent(name, promise);
1542 }
1543}
1544
1545function formatNonError(obj) {
1546 var str;
1547 if (typeof obj === "function") {
1548 str = "[function " +
1549 (obj.name || "anonymous") +
1550 "]";
1551 } else {
1552 str = obj && typeof obj.toString === "function"
1553 ? obj.toString() : util.toString(obj);
1554 var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
1555 if (ruselessToString.test(str)) {
1556 try {
1557 var newStr = JSON.stringify(obj);
1558 str = newStr;
1559 }
1560 catch(e) {
1561
1562 }
1563 }
1564 if (str.length === 0) {
1565 str = "(empty array)";
1566 }
1567 }
1568 return ("(<" + snip(str) + ">, no stack trace)");
1569}
1570
1571function snip(str) {
1572 var maxChars = 41;
1573 if (str.length < maxChars) {
1574 return str;
1575 }
1576 return str.substr(0, maxChars - 3) + "...";
1577}
1578
1579function longStackTracesIsSupported() {
1580 return typeof captureStackTrace === "function";
1581}
1582
1583var shouldIgnore = function() { return false; };
1584var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
1585function parseLineInfo(line) {
1586 var matches = line.match(parseLineInfoRegex);
1587 if (matches) {
1588 return {
1589 fileName: matches[1],
1590 line: parseInt(matches[2], 10)
1591 };
1592 }
1593}
1594
1595function setBounds(firstLineError, lastLineError) {
1596 if (!longStackTracesIsSupported()) return;
1597 var firstStackLines = firstLineError.stack.split("\n");
1598 var lastStackLines = lastLineError.stack.split("\n");
1599 var firstIndex = -1;
1600 var lastIndex = -1;
1601 var firstFileName;
1602 var lastFileName;
1603 for (var i = 0; i < firstStackLines.length; ++i) {
1604 var result = parseLineInfo(firstStackLines[i]);
1605 if (result) {
1606 firstFileName = result.fileName;
1607 firstIndex = result.line;
1608 break;
1609 }
1610 }
1611 for (var i = 0; i < lastStackLines.length; ++i) {
1612 var result = parseLineInfo(lastStackLines[i]);
1613 if (result) {
1614 lastFileName = result.fileName;
1615 lastIndex = result.line;
1616 break;
1617 }
1618 }
1619 if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
1620 firstFileName !== lastFileName || firstIndex >= lastIndex) {
1621 return;
1622 }
1623
1624 shouldIgnore = function(line) {
1625 if (bluebirdFramePattern.test(line)) return true;
1626 var info = parseLineInfo(line);
1627 if (info) {
1628 if (info.fileName === firstFileName &&
1629 (firstIndex <= info.line && info.line <= lastIndex)) {
1630 return true;
1631 }
1632 }
1633 return false;
1634 };
1635}
1636
1637function CapturedTrace(parent) {
1638 this._parent = parent;
1639 this._promisesCreated = 0;
1640 var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
1641 captureStackTrace(this, CapturedTrace);
1642 if (length > 32) this.uncycle();
1643}
1644util.inherits(CapturedTrace, Error);
1645Context.CapturedTrace = CapturedTrace;
1646
1647CapturedTrace.prototype.uncycle = function() {
1648 var length = this._length;
1649 if (length < 2) return;
1650 var nodes = [];
1651 var stackToIndex = {};
1652
1653 for (var i = 0, node = this; node !== undefined; ++i) {
1654 nodes.push(node);
1655 node = node._parent;
1656 }
1657 length = this._length = i;
1658 for (var i = length - 1; i >= 0; --i) {
1659 var stack = nodes[i].stack;
1660 if (stackToIndex[stack] === undefined) {
1661 stackToIndex[stack] = i;
1662 }
1663 }
1664 for (var i = 0; i < length; ++i) {
1665 var currentStack = nodes[i].stack;
1666 var index = stackToIndex[currentStack];
1667 if (index !== undefined && index !== i) {
1668 if (index > 0) {
1669 nodes[index - 1]._parent = undefined;
1670 nodes[index - 1]._length = 1;
1671 }
1672 nodes[i]._parent = undefined;
1673 nodes[i]._length = 1;
1674 var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
1675
1676 if (index < length - 1) {
1677 cycleEdgeNode._parent = nodes[index + 1];
1678 cycleEdgeNode._parent.uncycle();
1679 cycleEdgeNode._length =
1680 cycleEdgeNode._parent._length + 1;
1681 } else {
1682 cycleEdgeNode._parent = undefined;
1683 cycleEdgeNode._length = 1;
1684 }
1685 var currentChildLength = cycleEdgeNode._length + 1;
1686 for (var j = i - 2; j >= 0; --j) {
1687 nodes[j]._length = currentChildLength;
1688 currentChildLength++;
1689 }
1690 return;
1691 }
1692 }
1693};
1694
1695CapturedTrace.prototype.attachExtraTrace = function(error) {
1696 if (error.__stackCleaned__) return;
1697 this.uncycle();
1698 var parsed = parseStackAndMessage(error);
1699 var message = parsed.message;
1700 var stacks = [parsed.stack];
1701
1702 var trace = this;
1703 while (trace !== undefined) {
1704 stacks.push(cleanStack(trace.stack.split("\n")));
1705 trace = trace._parent;
1706 }
1707 removeCommonRoots(stacks);
1708 removeDuplicateOrEmptyJumps(stacks);
1709 util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
1710 util.notEnumerableProp(error, "__stackCleaned__", true);
1711};
1712
1713var captureStackTrace = (function stackDetection() {
1714 var v8stackFramePattern = /^\s*at\s*/;
1715 var v8stackFormatter = function(stack, error) {
1716 if (typeof stack === "string") return stack;
1717
1718 if (error.name !== undefined &&
1719 error.message !== undefined) {
1720 return error.toString();
1721 }
1722 return formatNonError(error);
1723 };
1724
1725 if (typeof Error.stackTraceLimit === "number" &&
1726 typeof Error.captureStackTrace === "function") {
1727 Error.stackTraceLimit += 6;
1728 stackFramePattern = v8stackFramePattern;
1729 formatStack = v8stackFormatter;
1730 var captureStackTrace = Error.captureStackTrace;
1731
1732 shouldIgnore = function(line) {
1733 return bluebirdFramePattern.test(line);
1734 };
1735 return function(receiver, ignoreUntil) {
1736 Error.stackTraceLimit += 6;
1737 captureStackTrace(receiver, ignoreUntil);
1738 Error.stackTraceLimit -= 6;
1739 };
1740 }
1741 var err = new Error();
1742
1743 if (typeof err.stack === "string" &&
1744 err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
1745 stackFramePattern = /@/;
1746 formatStack = v8stackFormatter;
1747 indentStackFrames = true;
1748 return function captureStackTrace(o) {
1749 o.stack = new Error().stack;
1750 };
1751 }
1752
1753 var hasStackAfterThrow;
1754 try { throw new Error(); }
1755 catch(e) {
1756 hasStackAfterThrow = ("stack" in e);
1757 }
1758 if (!("stack" in err) && hasStackAfterThrow &&
1759 typeof Error.stackTraceLimit === "number") {
1760 stackFramePattern = v8stackFramePattern;
1761 formatStack = v8stackFormatter;
1762 return function captureStackTrace(o) {
1763 Error.stackTraceLimit += 6;
1764 try { throw new Error(); }
1765 catch(e) { o.stack = e.stack; }
1766 Error.stackTraceLimit -= 6;
1767 };
1768 }
1769
1770 formatStack = function(stack, error) {
1771 if (typeof stack === "string") return stack;
1772
1773 if ((typeof error === "object" ||
1774 typeof error === "function") &&
1775 error.name !== undefined &&
1776 error.message !== undefined) {
1777 return error.toString();
1778 }
1779 return formatNonError(error);
1780 };
1781
1782 return null;
1783
1784})([]);
1785
1786if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
1787 printWarning = function (message) {
1788 console.warn(message);
1789 };
1790 if (util.isNode && process.stderr.isTTY) {
1791 printWarning = function(message, isSoft) {
1792 var color = isSoft ? "\u001b[33m" : "\u001b[31m";
1793 console.warn(color + message + "\u001b[0m\n");
1794 };
1795 } else if (!util.isNode && typeof (new Error().stack) === "string") {
1796 printWarning = function(message, isSoft) {
1797 console.warn("%c" + message,
1798 isSoft ? "color: darkorange" : "color: red");
1799 };
1800 }
1801}
1802
1803var config = {
1804 warnings: warnings,
1805 longStackTraces: false,
1806 cancellation: false,
1807 monitoring: false
1808};
1809
1810if (longStackTraces) Promise.longStackTraces();
1811
1812return {
1813 longStackTraces: function() {
1814 return config.longStackTraces;
1815 },
1816 warnings: function() {
1817 return config.warnings;
1818 },
1819 cancellation: function() {
1820 return config.cancellation;
1821 },
1822 monitoring: function() {
1823 return config.monitoring;
1824 },
1825 propagateFromFunction: function() {
1826 return propagateFromFunction;
1827 },
1828 boundValueFunction: function() {
1829 return boundValueFunction;
1830 },
1831 checkForgottenReturns: checkForgottenReturns,
1832 setBounds: setBounds,
1833 warn: warn,
1834 deprecated: deprecated,
1835 CapturedTrace: CapturedTrace,
1836 fireDomEvent: fireDomEvent,
1837 fireGlobalEvent: fireGlobalEvent
1838};
1839};
1840
1841},{"./errors":12,"./util":36}],10:[function(_dereq_,module,exports){
1842"use strict";
1843module.exports = function(Promise) {
1844function returner() {
1845 return this.value;
1846}
1847function thrower() {
1848 throw this.reason;
1849}
1850
1851Promise.prototype["return"] =
1852Promise.prototype.thenReturn = function (value) {
1853 if (value instanceof Promise) value.suppressUnhandledRejections();
1854 return this._then(
1855 returner, undefined, undefined, {value: value}, undefined);
1856};
1857
1858Promise.prototype["throw"] =
1859Promise.prototype.thenThrow = function (reason) {
1860 return this._then(
1861 thrower, undefined, undefined, {reason: reason}, undefined);
1862};
1863
1864Promise.prototype.catchThrow = function (reason) {
1865 if (arguments.length <= 1) {
1866 return this._then(
1867 undefined, thrower, undefined, {reason: reason}, undefined);
1868 } else {
1869 var _reason = arguments[1];
1870 var handler = function() {throw _reason;};
1871 return this.caught(reason, handler);
1872 }
1873};
1874
1875Promise.prototype.catchReturn = function (value) {
1876 if (arguments.length <= 1) {
1877 if (value instanceof Promise) value.suppressUnhandledRejections();
1878 return this._then(
1879 undefined, returner, undefined, {value: value}, undefined);
1880 } else {
1881 var _value = arguments[1];
1882 if (_value instanceof Promise) _value.suppressUnhandledRejections();
1883 var handler = function() {return _value;};
1884 return this.caught(value, handler);
1885 }
1886};
1887};
1888
1889},{}],11:[function(_dereq_,module,exports){
1890"use strict";
1891module.exports = function(Promise, INTERNAL) {
1892var PromiseReduce = Promise.reduce;
1893var PromiseAll = Promise.all;
1894
1895function promiseAllThis() {
1896 return PromiseAll(this);
1897}
1898
1899function PromiseMapSeries(promises, fn) {
1900 return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
1901}
1902
1903Promise.prototype.each = function (fn) {
1904 return PromiseReduce(this, fn, INTERNAL, 0)
1905 ._then(promiseAllThis, undefined, undefined, this, undefined);
1906};
1907
1908Promise.prototype.mapSeries = function (fn) {
1909 return PromiseReduce(this, fn, INTERNAL, INTERNAL);
1910};
1911
1912Promise.each = function (promises, fn) {
1913 return PromiseReduce(promises, fn, INTERNAL, 0)
1914 ._then(promiseAllThis, undefined, undefined, promises, undefined);
1915};
1916
1917Promise.mapSeries = PromiseMapSeries;
1918};
1919
1920
1921},{}],12:[function(_dereq_,module,exports){
1922"use strict";
1923var es5 = _dereq_("./es5");
1924var Objectfreeze = es5.freeze;
1925var util = _dereq_("./util");
1926var inherits = util.inherits;
1927var notEnumerableProp = util.notEnumerableProp;
1928
1929function subError(nameProperty, defaultMessage) {
1930 function SubError(message) {
1931 if (!(this instanceof SubError)) return new SubError(message);
1932 notEnumerableProp(this, "message",
1933 typeof message === "string" ? message : defaultMessage);
1934 notEnumerableProp(this, "name", nameProperty);
1935 if (Error.captureStackTrace) {
1936 Error.captureStackTrace(this, this.constructor);
1937 } else {
1938 Error.call(this);
1939 }
1940 }
1941 inherits(SubError, Error);
1942 return SubError;
1943}
1944
1945var _TypeError, _RangeError;
1946var Warning = subError("Warning", "warning");
1947var CancellationError = subError("CancellationError", "cancellation error");
1948var TimeoutError = subError("TimeoutError", "timeout error");
1949var AggregateError = subError("AggregateError", "aggregate error");
1950try {
1951 _TypeError = TypeError;
1952 _RangeError = RangeError;
1953} catch(e) {
1954 _TypeError = subError("TypeError", "type error");
1955 _RangeError = subError("RangeError", "range error");
1956}
1957
1958var methods = ("join pop push shift unshift slice filter forEach some " +
1959 "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
1960
1961for (var i = 0; i < methods.length; ++i) {
1962 if (typeof Array.prototype[methods[i]] === "function") {
1963 AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
1964 }
1965}
1966
1967es5.defineProperty(AggregateError.prototype, "length", {
1968 value: 0,
1969 configurable: false,
1970 writable: true,
1971 enumerable: true
1972});
1973AggregateError.prototype["isOperational"] = true;
1974var level = 0;
1975AggregateError.prototype.toString = function() {
1976 var indent = Array(level * 4 + 1).join(" ");
1977 var ret = "\n" + indent + "AggregateError of:" + "\n";
1978 level++;
1979 indent = Array(level * 4 + 1).join(" ");
1980 for (var i = 0; i < this.length; ++i) {
1981 var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
1982 var lines = str.split("\n");
1983 for (var j = 0; j < lines.length; ++j) {
1984 lines[j] = indent + lines[j];
1985 }
1986 str = lines.join("\n");
1987 ret += str + "\n";
1988 }
1989 level--;
1990 return ret;
1991};
1992
1993function OperationalError(message) {
1994 if (!(this instanceof OperationalError))
1995 return new OperationalError(message);
1996 notEnumerableProp(this, "name", "OperationalError");
1997 notEnumerableProp(this, "message", message);
1998 this.cause = message;
1999 this["isOperational"] = true;
2000
2001 if (message instanceof Error) {
2002 notEnumerableProp(this, "message", message.message);
2003 notEnumerableProp(this, "stack", message.stack);
2004 } else if (Error.captureStackTrace) {
2005 Error.captureStackTrace(this, this.constructor);
2006 }
2007
2008}
2009inherits(OperationalError, Error);
2010
2011var errorTypes = Error["__BluebirdErrorTypes__"];
2012if (!errorTypes) {
2013 errorTypes = Objectfreeze({
2014 CancellationError: CancellationError,
2015 TimeoutError: TimeoutError,
2016 OperationalError: OperationalError,
2017 RejectionError: OperationalError,
2018 AggregateError: AggregateError
2019 });
2020 es5.defineProperty(Error, "__BluebirdErrorTypes__", {
2021 value: errorTypes,
2022 writable: false,
2023 enumerable: false,
2024 configurable: false
2025 });
2026}
2027
2028module.exports = {
2029 Error: Error,
2030 TypeError: _TypeError,
2031 RangeError: _RangeError,
2032 CancellationError: errorTypes.CancellationError,
2033 OperationalError: errorTypes.OperationalError,
2034 TimeoutError: errorTypes.TimeoutError,
2035 AggregateError: errorTypes.AggregateError,
2036 Warning: Warning
2037};
2038
2039},{"./es5":13,"./util":36}],13:[function(_dereq_,module,exports){
2040var isES5 = (function(){
2041 "use strict";
2042 return this === undefined;
2043})();
2044
2045if (isES5) {
2046 module.exports = {
2047 freeze: Object.freeze,
2048 defineProperty: Object.defineProperty,
2049 getDescriptor: Object.getOwnPropertyDescriptor,
2050 keys: Object.keys,
2051 names: Object.getOwnPropertyNames,
2052 getPrototypeOf: Object.getPrototypeOf,
2053 isArray: Array.isArray,
2054 isES5: isES5,
2055 propertyIsWritable: function(obj, prop) {
2056 var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
2057 return !!(!descriptor || descriptor.writable || descriptor.set);
2058 }
2059 };
2060} else {
2061 var has = {}.hasOwnProperty;
2062 var str = {}.toString;
2063 var proto = {}.constructor.prototype;
2064
2065 var ObjectKeys = function (o) {
2066 var ret = [];
2067 for (var key in o) {
2068 if (has.call(o, key)) {
2069 ret.push(key);
2070 }
2071 }
2072 return ret;
2073 };
2074
2075 var ObjectGetDescriptor = function(o, key) {
2076 return {value: o[key]};
2077 };
2078
2079 var ObjectDefineProperty = function (o, key, desc) {
2080 o[key] = desc.value;
2081 return o;
2082 };
2083
2084 var ObjectFreeze = function (obj) {
2085 return obj;
2086 };
2087
2088 var ObjectGetPrototypeOf = function (obj) {
2089 try {
2090 return Object(obj).constructor.prototype;
2091 }
2092 catch (e) {
2093 return proto;
2094 }
2095 };
2096
2097 var ArrayIsArray = function (obj) {
2098 try {
2099 return str.call(obj) === "[object Array]";
2100 }
2101 catch(e) {
2102 return false;
2103 }
2104 };
2105
2106 module.exports = {
2107 isArray: ArrayIsArray,
2108 keys: ObjectKeys,
2109 names: ObjectKeys,
2110 defineProperty: ObjectDefineProperty,
2111 getDescriptor: ObjectGetDescriptor,
2112 freeze: ObjectFreeze,
2113 getPrototypeOf: ObjectGetPrototypeOf,
2114 isES5: isES5,
2115 propertyIsWritable: function() {
2116 return true;
2117 }
2118 };
2119}
2120
2121},{}],14:[function(_dereq_,module,exports){
2122"use strict";
2123module.exports = function(Promise, INTERNAL) {
2124var PromiseMap = Promise.map;
2125
2126Promise.prototype.filter = function (fn, options) {
2127 return PromiseMap(this, fn, options, INTERNAL);
2128};
2129
2130Promise.filter = function (promises, fn, options) {
2131 return PromiseMap(promises, fn, options, INTERNAL);
2132};
2133};
2134
2135},{}],15:[function(_dereq_,module,exports){
2136"use strict";
2137module.exports = function(Promise, tryConvertToPromise, NEXT_FILTER) {
2138var util = _dereq_("./util");
2139var CancellationError = Promise.CancellationError;
2140var errorObj = util.errorObj;
2141var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER);
2142
2143function PassThroughHandlerContext(promise, type, handler) {
2144 this.promise = promise;
2145 this.type = type;
2146 this.handler = handler;
2147 this.called = false;
2148 this.cancelPromise = null;
2149}
2150
2151PassThroughHandlerContext.prototype.isFinallyHandler = function() {
2152 return this.type === 0;
2153};
2154
2155function FinallyHandlerCancelReaction(finallyHandler) {
2156 this.finallyHandler = finallyHandler;
2157}
2158
2159FinallyHandlerCancelReaction.prototype._resultCancelled = function() {
2160 checkCancel(this.finallyHandler);
2161};
2162
2163function checkCancel(ctx, reason) {
2164 if (ctx.cancelPromise != null) {
2165 if (arguments.length > 1) {
2166 ctx.cancelPromise._reject(reason);
2167 } else {
2168 ctx.cancelPromise._cancel();
2169 }
2170 ctx.cancelPromise = null;
2171 return true;
2172 }
2173 return false;
2174}
2175
2176function succeed() {
2177 return finallyHandler.call(this, this.promise._target()._settledValue());
2178}
2179function fail(reason) {
2180 if (checkCancel(this, reason)) return;
2181 errorObj.e = reason;
2182 return errorObj;
2183}
2184function finallyHandler(reasonOrValue) {
2185 var promise = this.promise;
2186 var handler = this.handler;
2187
2188 if (!this.called) {
2189 this.called = true;
2190 var ret = this.isFinallyHandler()
2191 ? handler.call(promise._boundValue())
2192 : handler.call(promise._boundValue(), reasonOrValue);
2193 if (ret === NEXT_FILTER) {
2194 return ret;
2195 } else if (ret !== undefined) {
2196 promise._setReturnedNonUndefined();
2197 var maybePromise = tryConvertToPromise(ret, promise);
2198 if (maybePromise instanceof Promise) {
2199 if (this.cancelPromise != null) {
2200 if (maybePromise._isCancelled()) {
2201 var reason =
2202 new CancellationError("late cancellation observer");
2203 promise._attachExtraTrace(reason);
2204 errorObj.e = reason;
2205 return errorObj;
2206 } else if (maybePromise.isPending()) {
2207 maybePromise._attachCancellationCallback(
2208 new FinallyHandlerCancelReaction(this));
2209 }
2210 }
2211 return maybePromise._then(
2212 succeed, fail, undefined, this, undefined);
2213 }
2214 }
2215 }
2216
2217 if (promise.isRejected()) {
2218 checkCancel(this);
2219 errorObj.e = reasonOrValue;
2220 return errorObj;
2221 } else {
2222 checkCancel(this);
2223 return reasonOrValue;
2224 }
2225}
2226
2227Promise.prototype._passThrough = function(handler, type, success, fail) {
2228 if (typeof handler !== "function") return this.then();
2229 return this._then(success,
2230 fail,
2231 undefined,
2232 new PassThroughHandlerContext(this, type, handler),
2233 undefined);
2234};
2235
2236Promise.prototype.lastly =
2237Promise.prototype["finally"] = function (handler) {
2238 return this._passThrough(handler,
2239 0,
2240 finallyHandler,
2241 finallyHandler);
2242};
2243
2244
2245Promise.prototype.tap = function (handler) {
2246 return this._passThrough(handler, 1, finallyHandler);
2247};
2248
2249Promise.prototype.tapCatch = function (handlerOrPredicate) {
2250 var len = arguments.length;
2251 if(len === 1) {
2252 return this._passThrough(handlerOrPredicate,
2253 1,
2254 undefined,
2255 finallyHandler);
2256 } else {
2257 var catchInstances = new Array(len - 1),
2258 j = 0, i;
2259 for (i = 0; i < len - 1; ++i) {
2260 var item = arguments[i];
2261 if (util.isObject(item)) {
2262 catchInstances[j++] = item;
2263 } else {
2264 return Promise.reject(new TypeError(
2265 "tapCatch statement predicate: "
2266 + "expecting an object but got " + util.classString(item)
2267 ));
2268 }
2269 }
2270 catchInstances.length = j;
2271 var handler = arguments[i];
2272 return this._passThrough(catchFilter(catchInstances, handler, this),
2273 1,
2274 undefined,
2275 finallyHandler);
2276 }
2277
2278};
2279
2280return PassThroughHandlerContext;
2281};
2282
2283},{"./catch_filter":7,"./util":36}],16:[function(_dereq_,module,exports){
2284"use strict";
2285module.exports = function(Promise,
2286 apiRejection,
2287 INTERNAL,
2288 tryConvertToPromise,
2289 Proxyable,
2290 debug) {
2291var errors = _dereq_("./errors");
2292var TypeError = errors.TypeError;
2293var util = _dereq_("./util");
2294var errorObj = util.errorObj;
2295var tryCatch = util.tryCatch;
2296var yieldHandlers = [];
2297
2298function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
2299 for (var i = 0; i < yieldHandlers.length; ++i) {
2300 traceParent._pushContext();
2301 var result = tryCatch(yieldHandlers[i])(value);
2302 traceParent._popContext();
2303 if (result === errorObj) {
2304 traceParent._pushContext();
2305 var ret = Promise.reject(errorObj.e);
2306 traceParent._popContext();
2307 return ret;
2308 }
2309 var maybePromise = tryConvertToPromise(result, traceParent);
2310 if (maybePromise instanceof Promise) return maybePromise;
2311 }
2312 return null;
2313}
2314
2315function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
2316 if (debug.cancellation()) {
2317 var internal = new Promise(INTERNAL);
2318 var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
2319 this._promise = internal.lastly(function() {
2320 return _finallyPromise;
2321 });
2322 internal._captureStackTrace();
2323 internal._setOnCancel(this);
2324 } else {
2325 var promise = this._promise = new Promise(INTERNAL);
2326 promise._captureStackTrace();
2327 }
2328 this._stack = stack;
2329 this._generatorFunction = generatorFunction;
2330 this._receiver = receiver;
2331 this._generator = undefined;
2332 this._yieldHandlers = typeof yieldHandler === "function"
2333 ? [yieldHandler].concat(yieldHandlers)
2334 : yieldHandlers;
2335 this._yieldedPromise = null;
2336 this._cancellationPhase = false;
2337}
2338util.inherits(PromiseSpawn, Proxyable);
2339
2340PromiseSpawn.prototype._isResolved = function() {
2341 return this._promise === null;
2342};
2343
2344PromiseSpawn.prototype._cleanup = function() {
2345 this._promise = this._generator = null;
2346 if (debug.cancellation() && this._finallyPromise !== null) {
2347 this._finallyPromise._fulfill();
2348 this._finallyPromise = null;
2349 }
2350};
2351
2352PromiseSpawn.prototype._promiseCancelled = function() {
2353 if (this._isResolved()) return;
2354 var implementsReturn = typeof this._generator["return"] !== "undefined";
2355
2356 var result;
2357 if (!implementsReturn) {
2358 var reason = new Promise.CancellationError(
2359 "generator .return() sentinel");
2360 Promise.coroutine.returnSentinel = reason;
2361 this._promise._attachExtraTrace(reason);
2362 this._promise._pushContext();
2363 result = tryCatch(this._generator["throw"]).call(this._generator,
2364 reason);
2365 this._promise._popContext();
2366 } else {
2367 this._promise._pushContext();
2368 result = tryCatch(this._generator["return"]).call(this._generator,
2369 undefined);
2370 this._promise._popContext();
2371 }
2372 this._cancellationPhase = true;
2373 this._yieldedPromise = null;
2374 this._continue(result);
2375};
2376
2377PromiseSpawn.prototype._promiseFulfilled = function(value) {
2378 this._yieldedPromise = null;
2379 this._promise._pushContext();
2380 var result = tryCatch(this._generator.next).call(this._generator, value);
2381 this._promise._popContext();
2382 this._continue(result);
2383};
2384
2385PromiseSpawn.prototype._promiseRejected = function(reason) {
2386 this._yieldedPromise = null;
2387 this._promise._attachExtraTrace(reason);
2388 this._promise._pushContext();
2389 var result = tryCatch(this._generator["throw"])
2390 .call(this._generator, reason);
2391 this._promise._popContext();
2392 this._continue(result);
2393};
2394
2395PromiseSpawn.prototype._resultCancelled = function() {
2396 if (this._yieldedPromise instanceof Promise) {
2397 var promise = this._yieldedPromise;
2398 this._yieldedPromise = null;
2399 promise.cancel();
2400 }
2401};
2402
2403PromiseSpawn.prototype.promise = function () {
2404 return this._promise;
2405};
2406
2407PromiseSpawn.prototype._run = function () {
2408 this._generator = this._generatorFunction.call(this._receiver);
2409 this._receiver =
2410 this._generatorFunction = undefined;
2411 this._promiseFulfilled(undefined);
2412};
2413
2414PromiseSpawn.prototype._continue = function (result) {
2415 var promise = this._promise;
2416 if (result === errorObj) {
2417 this._cleanup();
2418 if (this._cancellationPhase) {
2419 return promise.cancel();
2420 } else {
2421 return promise._rejectCallback(result.e, false);
2422 }
2423 }
2424
2425 var value = result.value;
2426 if (result.done === true) {
2427 this._cleanup();
2428 if (this._cancellationPhase) {
2429 return promise.cancel();
2430 } else {
2431 return promise._resolveCallback(value);
2432 }
2433 } else {
2434 var maybePromise = tryConvertToPromise(value, this._promise);
2435 if (!(maybePromise instanceof Promise)) {
2436 maybePromise =
2437 promiseFromYieldHandler(maybePromise,
2438 this._yieldHandlers,
2439 this._promise);
2440 if (maybePromise === null) {
2441 this._promiseRejected(
2442 new TypeError(
2443 "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) +
2444 "From coroutine:\u000a" +
2445 this._stack.split("\n").slice(1, -7).join("\n")
2446 )
2447 );
2448 return;
2449 }
2450 }
2451 maybePromise = maybePromise._target();
2452 var bitField = maybePromise._bitField;
2453 ;
2454 if (((bitField & 50397184) === 0)) {
2455 this._yieldedPromise = maybePromise;
2456 maybePromise._proxy(this, null);
2457 } else if (((bitField & 33554432) !== 0)) {
2458 Promise._async.invoke(
2459 this._promiseFulfilled, this, maybePromise._value()
2460 );
2461 } else if (((bitField & 16777216) !== 0)) {
2462 Promise._async.invoke(
2463 this._promiseRejected, this, maybePromise._reason()
2464 );
2465 } else {
2466 this._promiseCancelled();
2467 }
2468 }
2469};
2470
2471Promise.coroutine = function (generatorFunction, options) {
2472 if (typeof generatorFunction !== "function") {
2473 throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
2474 }
2475 var yieldHandler = Object(options).yieldHandler;
2476 var PromiseSpawn$ = PromiseSpawn;
2477 var stack = new Error().stack;
2478 return function () {
2479 var generator = generatorFunction.apply(this, arguments);
2480 var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
2481 stack);
2482 var ret = spawn.promise();
2483 spawn._generator = generator;
2484 spawn._promiseFulfilled(undefined);
2485 return ret;
2486 };
2487};
2488
2489Promise.coroutine.addYieldHandler = function(fn) {
2490 if (typeof fn !== "function") {
2491 throw new TypeError("expecting a function but got " + util.classString(fn));
2492 }
2493 yieldHandlers.push(fn);
2494};
2495
2496Promise.spawn = function (generatorFunction) {
2497 debug.deprecated("Promise.spawn()", "Promise.coroutine()");
2498 if (typeof generatorFunction !== "function") {
2499 return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
2500 }
2501 var spawn = new PromiseSpawn(generatorFunction, this);
2502 var ret = spawn.promise();
2503 spawn._run(Promise.spawn);
2504 return ret;
2505};
2506};
2507
2508},{"./errors":12,"./util":36}],17:[function(_dereq_,module,exports){
2509"use strict";
2510module.exports =
2511function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async,
2512 getDomain) {
2513var util = _dereq_("./util");
2514var canEvaluate = util.canEvaluate;
2515var tryCatch = util.tryCatch;
2516var errorObj = util.errorObj;
2517var reject;
2518
2519if (!true) {
2520if (canEvaluate) {
2521 var thenCallback = function(i) {
2522 return new Function("value", "holder", " \n\
2523 'use strict'; \n\
2524 holder.pIndex = value; \n\
2525 holder.checkFulfillment(this); \n\
2526 ".replace(/Index/g, i));
2527 };
2528
2529 var promiseSetter = function(i) {
2530 return new Function("promise", "holder", " \n\
2531 'use strict'; \n\
2532 holder.pIndex = promise; \n\
2533 ".replace(/Index/g, i));
2534 };
2535
2536 var generateHolderClass = function(total) {
2537 var props = new Array(total);
2538 for (var i = 0; i < props.length; ++i) {
2539 props[i] = "this.p" + (i+1);
2540 }
2541 var assignment = props.join(" = ") + " = null;";
2542 var cancellationCode= "var promise;\n" + props.map(function(prop) {
2543 return " \n\
2544 promise = " + prop + "; \n\
2545 if (promise instanceof Promise) { \n\
2546 promise.cancel(); \n\
2547 } \n\
2548 ";
2549 }).join("\n");
2550 var passedArguments = props.join(", ");
2551 var name = "Holder$" + total;
2552
2553
2554 var code = "return function(tryCatch, errorObj, Promise, async) { \n\
2555 'use strict'; \n\
2556 function [TheName](fn) { \n\
2557 [TheProperties] \n\
2558 this.fn = fn; \n\
2559 this.asyncNeeded = true; \n\
2560 this.now = 0; \n\
2561 } \n\
2562 \n\
2563 [TheName].prototype._callFunction = function(promise) { \n\
2564 promise._pushContext(); \n\
2565 var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
2566 promise._popContext(); \n\
2567 if (ret === errorObj) { \n\
2568 promise._rejectCallback(ret.e, false); \n\
2569 } else { \n\
2570 promise._resolveCallback(ret); \n\
2571 } \n\
2572 }; \n\
2573 \n\
2574 [TheName].prototype.checkFulfillment = function(promise) { \n\
2575 var now = ++this.now; \n\
2576 if (now === [TheTotal]) { \n\
2577 if (this.asyncNeeded) { \n\
2578 async.invoke(this._callFunction, this, promise); \n\
2579 } else { \n\
2580 this._callFunction(promise); \n\
2581 } \n\
2582 \n\
2583 } \n\
2584 }; \n\
2585 \n\
2586 [TheName].prototype._resultCancelled = function() { \n\
2587 [CancellationCode] \n\
2588 }; \n\
2589 \n\
2590 return [TheName]; \n\
2591 }(tryCatch, errorObj, Promise, async); \n\
2592 ";
2593
2594 code = code.replace(/\[TheName\]/g, name)
2595 .replace(/\[TheTotal\]/g, total)
2596 .replace(/\[ThePassedArguments\]/g, passedArguments)
2597 .replace(/\[TheProperties\]/g, assignment)
2598 .replace(/\[CancellationCode\]/g, cancellationCode);
2599
2600 return new Function("tryCatch", "errorObj", "Promise", "async", code)
2601 (tryCatch, errorObj, Promise, async);
2602 };
2603
2604 var holderClasses = [];
2605 var thenCallbacks = [];
2606 var promiseSetters = [];
2607
2608 for (var i = 0; i < 8; ++i) {
2609 holderClasses.push(generateHolderClass(i + 1));
2610 thenCallbacks.push(thenCallback(i + 1));
2611 promiseSetters.push(promiseSetter(i + 1));
2612 }
2613
2614 reject = function (reason) {
2615 this._reject(reason);
2616 };
2617}}
2618
2619Promise.join = function () {
2620 var last = arguments.length - 1;
2621 var fn;
2622 if (last > 0 && typeof arguments[last] === "function") {
2623 fn = arguments[last];
2624 if (!true) {
2625 if (last <= 8 && canEvaluate) {
2626 var ret = new Promise(INTERNAL);
2627 ret._captureStackTrace();
2628 var HolderClass = holderClasses[last - 1];
2629 var holder = new HolderClass(fn);
2630 var callbacks = thenCallbacks;
2631
2632 for (var i = 0; i < last; ++i) {
2633 var maybePromise = tryConvertToPromise(arguments[i], ret);
2634 if (maybePromise instanceof Promise) {
2635 maybePromise = maybePromise._target();
2636 var bitField = maybePromise._bitField;
2637 ;
2638 if (((bitField & 50397184) === 0)) {
2639 maybePromise._then(callbacks[i], reject,
2640 undefined, ret, holder);
2641 promiseSetters[i](maybePromise, holder);
2642 holder.asyncNeeded = false;
2643 } else if (((bitField & 33554432) !== 0)) {
2644 callbacks[i].call(ret,
2645 maybePromise._value(), holder);
2646 } else if (((bitField & 16777216) !== 0)) {
2647 ret._reject(maybePromise._reason());
2648 } else {
2649 ret._cancel();
2650 }
2651 } else {
2652 callbacks[i].call(ret, maybePromise, holder);
2653 }
2654 }
2655
2656 if (!ret._isFateSealed()) {
2657 if (holder.asyncNeeded) {
2658 var domain = getDomain();
2659 if (domain !== null) {
2660 holder.fn = util.domainBind(domain, holder.fn);
2661 }
2662 }
2663 ret._setAsyncGuaranteed();
2664 ret._setOnCancel(holder);
2665 }
2666 return ret;
2667 }
2668 }
2669 }
2670 var args = [].slice.call(arguments);;
2671 if (fn) args.pop();
2672 var ret = new PromiseArray(args).promise();
2673 return fn !== undefined ? ret.spread(fn) : ret;
2674};
2675
2676};
2677
2678},{"./util":36}],18:[function(_dereq_,module,exports){
2679"use strict";
2680module.exports = function(Promise,
2681 PromiseArray,
2682 apiRejection,
2683 tryConvertToPromise,
2684 INTERNAL,
2685 debug) {
2686var getDomain = Promise._getDomain;
2687var util = _dereq_("./util");
2688var tryCatch = util.tryCatch;
2689var errorObj = util.errorObj;
2690var async = Promise._async;
2691
2692function MappingPromiseArray(promises, fn, limit, _filter) {
2693 this.constructor$(promises);
2694 this._promise._captureStackTrace();
2695 var domain = getDomain();
2696 this._callback = domain === null ? fn : util.domainBind(domain, fn);
2697 this._preservedValues = _filter === INTERNAL
2698 ? new Array(this.length())
2699 : null;
2700 this._limit = limit;
2701 this._inFlight = 0;
2702 this._queue = [];
2703 async.invoke(this._asyncInit, this, undefined);
2704}
2705util.inherits(MappingPromiseArray, PromiseArray);
2706
2707MappingPromiseArray.prototype._asyncInit = function() {
2708 this._init$(undefined, -2);
2709};
2710
2711MappingPromiseArray.prototype._init = function () {};
2712
2713MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
2714 var values = this._values;
2715 var length = this.length();
2716 var preservedValues = this._preservedValues;
2717 var limit = this._limit;
2718
2719 if (index < 0) {
2720 index = (index * -1) - 1;
2721 values[index] = value;
2722 if (limit >= 1) {
2723 this._inFlight--;
2724 this._drainQueue();
2725 if (this._isResolved()) return true;
2726 }
2727 } else {
2728 if (limit >= 1 && this._inFlight >= limit) {
2729 values[index] = value;
2730 this._queue.push(index);
2731 return false;
2732 }
2733 if (preservedValues !== null) preservedValues[index] = value;
2734
2735 var promise = this._promise;
2736 var callback = this._callback;
2737 var receiver = promise._boundValue();
2738 promise._pushContext();
2739 var ret = tryCatch(callback).call(receiver, value, index, length);
2740 var promiseCreated = promise._popContext();
2741 debug.checkForgottenReturns(
2742 ret,
2743 promiseCreated,
2744 preservedValues !== null ? "Promise.filter" : "Promise.map",
2745 promise
2746 );
2747 if (ret === errorObj) {
2748 this._reject(ret.e);
2749 return true;
2750 }
2751
2752 var maybePromise = tryConvertToPromise(ret, this._promise);
2753 if (maybePromise instanceof Promise) {
2754 maybePromise = maybePromise._target();
2755 var bitField = maybePromise._bitField;
2756 ;
2757 if (((bitField & 50397184) === 0)) {
2758 if (limit >= 1) this._inFlight++;
2759 values[index] = maybePromise;
2760 maybePromise._proxy(this, (index + 1) * -1);
2761 return false;
2762 } else if (((bitField & 33554432) !== 0)) {
2763 ret = maybePromise._value();
2764 } else if (((bitField & 16777216) !== 0)) {
2765 this._reject(maybePromise._reason());
2766 return true;
2767 } else {
2768 this._cancel();
2769 return true;
2770 }
2771 }
2772 values[index] = ret;
2773 }
2774 var totalResolved = ++this._totalResolved;
2775 if (totalResolved >= length) {
2776 if (preservedValues !== null) {
2777 this._filter(values, preservedValues);
2778 } else {
2779 this._resolve(values);
2780 }
2781 return true;
2782 }
2783 return false;
2784};
2785
2786MappingPromiseArray.prototype._drainQueue = function () {
2787 var queue = this._queue;
2788 var limit = this._limit;
2789 var values = this._values;
2790 while (queue.length > 0 && this._inFlight < limit) {
2791 if (this._isResolved()) return;
2792 var index = queue.pop();
2793 this._promiseFulfilled(values[index], index);
2794 }
2795};
2796
2797MappingPromiseArray.prototype._filter = function (booleans, values) {
2798 var len = values.length;
2799 var ret = new Array(len);
2800 var j = 0;
2801 for (var i = 0; i < len; ++i) {
2802 if (booleans[i]) ret[j++] = values[i];
2803 }
2804 ret.length = j;
2805 this._resolve(ret);
2806};
2807
2808MappingPromiseArray.prototype.preservedValues = function () {
2809 return this._preservedValues;
2810};
2811
2812function map(promises, fn, options, _filter) {
2813 if (typeof fn !== "function") {
2814 return apiRejection("expecting a function but got " + util.classString(fn));
2815 }
2816
2817 var limit = 0;
2818 if (options !== undefined) {
2819 if (typeof options === "object" && options !== null) {
2820 if (typeof options.concurrency !== "number") {
2821 return Promise.reject(
2822 new TypeError("'concurrency' must be a number but it is " +
2823 util.classString(options.concurrency)));
2824 }
2825 limit = options.concurrency;
2826 } else {
2827 return Promise.reject(new TypeError(
2828 "options argument must be an object but it is " +
2829 util.classString(options)));
2830 }
2831 }
2832 limit = typeof limit === "number" &&
2833 isFinite(limit) && limit >= 1 ? limit : 0;
2834 return new MappingPromiseArray(promises, fn, limit, _filter).promise();
2835}
2836
2837Promise.prototype.map = function (fn, options) {
2838 return map(this, fn, options, null);
2839};
2840
2841Promise.map = function (promises, fn, options, _filter) {
2842 return map(promises, fn, options, _filter);
2843};
2844
2845
2846};
2847
2848},{"./util":36}],19:[function(_dereq_,module,exports){
2849"use strict";
2850module.exports =
2851function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
2852var util = _dereq_("./util");
2853var tryCatch = util.tryCatch;
2854
2855Promise.method = function (fn) {
2856 if (typeof fn !== "function") {
2857 throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
2858 }
2859 return function () {
2860 var ret = new Promise(INTERNAL);
2861 ret._captureStackTrace();
2862 ret._pushContext();
2863 var value = tryCatch(fn).apply(this, arguments);
2864 var promiseCreated = ret._popContext();
2865 debug.checkForgottenReturns(
2866 value, promiseCreated, "Promise.method", ret);
2867 ret._resolveFromSyncValue(value);
2868 return ret;
2869 };
2870};
2871
2872Promise.attempt = Promise["try"] = function (fn) {
2873 if (typeof fn !== "function") {
2874 return apiRejection("expecting a function but got " + util.classString(fn));
2875 }
2876 var ret = new Promise(INTERNAL);
2877 ret._captureStackTrace();
2878 ret._pushContext();
2879 var value;
2880 if (arguments.length > 1) {
2881 debug.deprecated("calling Promise.try with more than 1 argument");
2882 var arg = arguments[1];
2883 var ctx = arguments[2];
2884 value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
2885 : tryCatch(fn).call(ctx, arg);
2886 } else {
2887 value = tryCatch(fn)();
2888 }
2889 var promiseCreated = ret._popContext();
2890 debug.checkForgottenReturns(
2891 value, promiseCreated, "Promise.try", ret);
2892 ret._resolveFromSyncValue(value);
2893 return ret;
2894};
2895
2896Promise.prototype._resolveFromSyncValue = function (value) {
2897 if (value === util.errorObj) {
2898 this._rejectCallback(value.e, false);
2899 } else {
2900 this._resolveCallback(value, true);
2901 }
2902};
2903};
2904
2905},{"./util":36}],20:[function(_dereq_,module,exports){
2906"use strict";
2907var util = _dereq_("./util");
2908var maybeWrapAsError = util.maybeWrapAsError;
2909var errors = _dereq_("./errors");
2910var OperationalError = errors.OperationalError;
2911var es5 = _dereq_("./es5");
2912
2913function isUntypedError(obj) {
2914 return obj instanceof Error &&
2915 es5.getPrototypeOf(obj) === Error.prototype;
2916}
2917
2918var rErrorKey = /^(?:name|message|stack|cause)$/;
2919function wrapAsOperationalError(obj) {
2920 var ret;
2921 if (isUntypedError(obj)) {
2922 ret = new OperationalError(obj);
2923 ret.name = obj.name;
2924 ret.message = obj.message;
2925 ret.stack = obj.stack;
2926 var keys = es5.keys(obj);
2927 for (var i = 0; i < keys.length; ++i) {
2928 var key = keys[i];
2929 if (!rErrorKey.test(key)) {
2930 ret[key] = obj[key];
2931 }
2932 }
2933 return ret;
2934 }
2935 util.markAsOriginatingFromRejection(obj);
2936 return obj;
2937}
2938
2939function nodebackForPromise(promise, multiArgs) {
2940 return function(err, value) {
2941 if (promise === null) return;
2942 if (err) {
2943 var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
2944 promise._attachExtraTrace(wrapped);
2945 promise._reject(wrapped);
2946 } else if (!multiArgs) {
2947 promise._fulfill(value);
2948 } else {
2949 var args = [].slice.call(arguments, 1);;
2950 promise._fulfill(args);
2951 }
2952 promise = null;
2953 };
2954}
2955
2956module.exports = nodebackForPromise;
2957
2958},{"./errors":12,"./es5":13,"./util":36}],21:[function(_dereq_,module,exports){
2959"use strict";
2960module.exports = function(Promise) {
2961var util = _dereq_("./util");
2962var async = Promise._async;
2963var tryCatch = util.tryCatch;
2964var errorObj = util.errorObj;
2965
2966function spreadAdapter(val, nodeback) {
2967 var promise = this;
2968 if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
2969 var ret =
2970 tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
2971 if (ret === errorObj) {
2972 async.throwLater(ret.e);
2973 }
2974}
2975
2976function successAdapter(val, nodeback) {
2977 var promise = this;
2978 var receiver = promise._boundValue();
2979 var ret = val === undefined
2980 ? tryCatch(nodeback).call(receiver, null)
2981 : tryCatch(nodeback).call(receiver, null, val);
2982 if (ret === errorObj) {
2983 async.throwLater(ret.e);
2984 }
2985}
2986function errorAdapter(reason, nodeback) {
2987 var promise = this;
2988 if (!reason) {
2989 var newReason = new Error(reason + "");
2990 newReason.cause = reason;
2991 reason = newReason;
2992 }
2993 var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
2994 if (ret === errorObj) {
2995 async.throwLater(ret.e);
2996 }
2997}
2998
2999Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
3000 options) {
3001 if (typeof nodeback == "function") {
3002 var adapter = successAdapter;
3003 if (options !== undefined && Object(options).spread) {
3004 adapter = spreadAdapter;
3005 }
3006 this._then(
3007 adapter,
3008 errorAdapter,
3009 undefined,
3010 this,
3011 nodeback
3012 );
3013 }
3014 return this;
3015};
3016};
3017
3018},{"./util":36}],22:[function(_dereq_,module,exports){
3019"use strict";
3020module.exports = function() {
3021var makeSelfResolutionError = function () {
3022 return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
3023};
3024var reflectHandler = function() {
3025 return new Promise.PromiseInspection(this._target());
3026};
3027var apiRejection = function(msg) {
3028 return Promise.reject(new TypeError(msg));
3029};
3030function Proxyable() {}
3031var UNDEFINED_BINDING = {};
3032var util = _dereq_("./util");
3033
3034var getDomain;
3035if (util.isNode) {
3036 getDomain = function() {
3037 var ret = process.domain;
3038 if (ret === undefined) ret = null;
3039 return ret;
3040 };
3041} else {
3042 getDomain = function() {
3043 return null;
3044 };
3045}
3046util.notEnumerableProp(Promise, "_getDomain", getDomain);
3047
3048var es5 = _dereq_("./es5");
3049var Async = _dereq_("./async");
3050var async = new Async();
3051es5.defineProperty(Promise, "_async", {value: async});
3052var errors = _dereq_("./errors");
3053var TypeError = Promise.TypeError = errors.TypeError;
3054Promise.RangeError = errors.RangeError;
3055var CancellationError = Promise.CancellationError = errors.CancellationError;
3056Promise.TimeoutError = errors.TimeoutError;
3057Promise.OperationalError = errors.OperationalError;
3058Promise.RejectionError = errors.OperationalError;
3059Promise.AggregateError = errors.AggregateError;
3060var INTERNAL = function(){};
3061var APPLY = {};
3062var NEXT_FILTER = {};
3063var tryConvertToPromise = _dereq_("./thenables")(Promise, INTERNAL);
3064var PromiseArray =
3065 _dereq_("./promise_array")(Promise, INTERNAL,
3066 tryConvertToPromise, apiRejection, Proxyable);
3067var Context = _dereq_("./context")(Promise);
3068 /*jshint unused:false*/
3069var createContext = Context.create;
3070var debug = _dereq_("./debuggability")(Promise, Context);
3071var CapturedTrace = debug.CapturedTrace;
3072var PassThroughHandlerContext =
3073 _dereq_("./finally")(Promise, tryConvertToPromise, NEXT_FILTER);
3074var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER);
3075var nodebackForPromise = _dereq_("./nodeback");
3076var errorObj = util.errorObj;
3077var tryCatch = util.tryCatch;
3078function check(self, executor) {
3079 if (self == null || self.constructor !== Promise) {
3080 throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
3081 }
3082 if (typeof executor !== "function") {
3083 throw new TypeError("expecting a function but got " + util.classString(executor));
3084 }
3085
3086}
3087
3088function Promise(executor) {
3089 if (executor !== INTERNAL) {
3090 check(this, executor);
3091 }
3092 this._bitField = 0;
3093 this._fulfillmentHandler0 = undefined;
3094 this._rejectionHandler0 = undefined;
3095 this._promise0 = undefined;
3096 this._receiver0 = undefined;
3097 this._resolveFromExecutor(executor);
3098 this._promiseCreated();
3099 this._fireEvent("promiseCreated", this);
3100}
3101
3102Promise.prototype.toString = function () {
3103 return "[object Promise]";
3104};
3105
3106Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
3107 var len = arguments.length;
3108 if (len > 1) {
3109 var catchInstances = new Array(len - 1),
3110 j = 0, i;
3111 for (i = 0; i < len - 1; ++i) {
3112 var item = arguments[i];
3113 if (util.isObject(item)) {
3114 catchInstances[j++] = item;
3115 } else {
3116 return apiRejection("Catch statement predicate: " +
3117 "expecting an object but got " + util.classString(item));
3118 }
3119 }
3120 catchInstances.length = j;
3121 fn = arguments[i];
3122 return this.then(undefined, catchFilter(catchInstances, fn, this));
3123 }
3124 return this.then(undefined, fn);
3125};
3126
3127Promise.prototype.reflect = function () {
3128 return this._then(reflectHandler,
3129 reflectHandler, undefined, this, undefined);
3130};
3131
3132Promise.prototype.then = function (didFulfill, didReject) {
3133 if (debug.warnings() && arguments.length > 0 &&
3134 typeof didFulfill !== "function" &&
3135 typeof didReject !== "function") {
3136 var msg = ".then() only accepts functions but was passed: " +
3137 util.classString(didFulfill);
3138 if (arguments.length > 1) {
3139 msg += ", " + util.classString(didReject);
3140 }
3141 this._warn(msg);
3142 }
3143 return this._then(didFulfill, didReject, undefined, undefined, undefined);
3144};
3145
3146Promise.prototype.done = function (didFulfill, didReject) {
3147 var promise =
3148 this._then(didFulfill, didReject, undefined, undefined, undefined);
3149 promise._setIsFinal();
3150};
3151
3152Promise.prototype.spread = function (fn) {
3153 if (typeof fn !== "function") {
3154 return apiRejection("expecting a function but got " + util.classString(fn));
3155 }
3156 return this.all()._then(fn, undefined, undefined, APPLY, undefined);
3157};
3158
3159Promise.prototype.toJSON = function () {
3160 var ret = {
3161 isFulfilled: false,
3162 isRejected: false,
3163 fulfillmentValue: undefined,
3164 rejectionReason: undefined
3165 };
3166 if (this.isFulfilled()) {
3167 ret.fulfillmentValue = this.value();
3168 ret.isFulfilled = true;
3169 } else if (this.isRejected()) {
3170 ret.rejectionReason = this.reason();
3171 ret.isRejected = true;
3172 }
3173 return ret;
3174};
3175
3176Promise.prototype.all = function () {
3177 if (arguments.length > 0) {
3178 this._warn(".all() was passed arguments but it does not take any");
3179 }
3180 return new PromiseArray(this).promise();
3181};
3182
3183Promise.prototype.error = function (fn) {
3184 return this.caught(util.originatesFromRejection, fn);
3185};
3186
3187Promise.getNewLibraryCopy = module.exports;
3188
3189Promise.is = function (val) {
3190 return val instanceof Promise;
3191};
3192
3193Promise.fromNode = Promise.fromCallback = function(fn) {
3194 var ret = new Promise(INTERNAL);
3195 ret._captureStackTrace();
3196 var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
3197 : false;
3198 var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
3199 if (result === errorObj) {
3200 ret._rejectCallback(result.e, true);
3201 }
3202 if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
3203 return ret;
3204};
3205
3206Promise.all = function (promises) {
3207 return new PromiseArray(promises).promise();
3208};
3209
3210Promise.cast = function (obj) {
3211 var ret = tryConvertToPromise(obj);
3212 if (!(ret instanceof Promise)) {
3213 ret = new Promise(INTERNAL);
3214 ret._captureStackTrace();
3215 ret._setFulfilled();
3216 ret._rejectionHandler0 = obj;
3217 }
3218 return ret;
3219};
3220
3221Promise.resolve = Promise.fulfilled = Promise.cast;
3222
3223Promise.reject = Promise.rejected = function (reason) {
3224 var ret = new Promise(INTERNAL);
3225 ret._captureStackTrace();
3226 ret._rejectCallback(reason, true);
3227 return ret;
3228};
3229
3230Promise.setScheduler = function(fn) {
3231 if (typeof fn !== "function") {
3232 throw new TypeError("expecting a function but got " + util.classString(fn));
3233 }
3234 return async.setScheduler(fn);
3235};
3236
3237Promise.prototype._then = function (
3238 didFulfill,
3239 didReject,
3240 _, receiver,
3241 internalData
3242) {
3243 var haveInternalData = internalData !== undefined;
3244 var promise = haveInternalData ? internalData : new Promise(INTERNAL);
3245 var target = this._target();
3246 var bitField = target._bitField;
3247
3248 if (!haveInternalData) {
3249 promise._propagateFrom(this, 3);
3250 promise._captureStackTrace();
3251 if (receiver === undefined &&
3252 ((this._bitField & 2097152) !== 0)) {
3253 if (!((bitField & 50397184) === 0)) {
3254 receiver = this._boundValue();
3255 } else {
3256 receiver = target === this ? undefined : this._boundTo;
3257 }
3258 }
3259 this._fireEvent("promiseChained", this, promise);
3260 }
3261
3262 var domain = getDomain();
3263 if (!((bitField & 50397184) === 0)) {
3264 var handler, value, settler = target._settlePromiseCtx;
3265 if (((bitField & 33554432) !== 0)) {
3266 value = target._rejectionHandler0;
3267 handler = didFulfill;
3268 } else if (((bitField & 16777216) !== 0)) {
3269 value = target._fulfillmentHandler0;
3270 handler = didReject;
3271 target._unsetRejectionIsUnhandled();
3272 } else {
3273 settler = target._settlePromiseLateCancellationObserver;
3274 value = new CancellationError("late cancellation observer");
3275 target._attachExtraTrace(value);
3276 handler = didReject;
3277 }
3278
3279 async.invoke(settler, target, {
3280 handler: domain === null ? handler
3281 : (typeof handler === "function" &&
3282 util.domainBind(domain, handler)),
3283 promise: promise,
3284 receiver: receiver,
3285 value: value
3286 });
3287 } else {
3288 target._addCallbacks(didFulfill, didReject, promise, receiver, domain);
3289 }
3290
3291 return promise;
3292};
3293
3294Promise.prototype._length = function () {
3295 return this._bitField & 65535;
3296};
3297
3298Promise.prototype._isFateSealed = function () {
3299 return (this._bitField & 117506048) !== 0;
3300};
3301
3302Promise.prototype._isFollowing = function () {
3303 return (this._bitField & 67108864) === 67108864;
3304};
3305
3306Promise.prototype._setLength = function (len) {
3307 this._bitField = (this._bitField & -65536) |
3308 (len & 65535);
3309};
3310
3311Promise.prototype._setFulfilled = function () {
3312 this._bitField = this._bitField | 33554432;
3313 this._fireEvent("promiseFulfilled", this);
3314};
3315
3316Promise.prototype._setRejected = function () {
3317 this._bitField = this._bitField | 16777216;
3318 this._fireEvent("promiseRejected", this);
3319};
3320
3321Promise.prototype._setFollowing = function () {
3322 this._bitField = this._bitField | 67108864;
3323 this._fireEvent("promiseResolved", this);
3324};
3325
3326Promise.prototype._setIsFinal = function () {
3327 this._bitField = this._bitField | 4194304;
3328};
3329
3330Promise.prototype._isFinal = function () {
3331 return (this._bitField & 4194304) > 0;
3332};
3333
3334Promise.prototype._unsetCancelled = function() {
3335 this._bitField = this._bitField & (~65536);
3336};
3337
3338Promise.prototype._setCancelled = function() {
3339 this._bitField = this._bitField | 65536;
3340 this._fireEvent("promiseCancelled", this);
3341};
3342
3343Promise.prototype._setWillBeCancelled = function() {
3344 this._bitField = this._bitField | 8388608;
3345};
3346
3347Promise.prototype._setAsyncGuaranteed = function() {
3348 if (async.hasCustomScheduler()) return;
3349 this._bitField = this._bitField | 134217728;
3350};
3351
3352Promise.prototype._receiverAt = function (index) {
3353 var ret = index === 0 ? this._receiver0 : this[
3354 index * 4 - 4 + 3];
3355 if (ret === UNDEFINED_BINDING) {
3356 return undefined;
3357 } else if (ret === undefined && this._isBound()) {
3358 return this._boundValue();
3359 }
3360 return ret;
3361};
3362
3363Promise.prototype._promiseAt = function (index) {
3364 return this[
3365 index * 4 - 4 + 2];
3366};
3367
3368Promise.prototype._fulfillmentHandlerAt = function (index) {
3369 return this[
3370 index * 4 - 4 + 0];
3371};
3372
3373Promise.prototype._rejectionHandlerAt = function (index) {
3374 return this[
3375 index * 4 - 4 + 1];
3376};
3377
3378Promise.prototype._boundValue = function() {};
3379
3380Promise.prototype._migrateCallback0 = function (follower) {
3381 var bitField = follower._bitField;
3382 var fulfill = follower._fulfillmentHandler0;
3383 var reject = follower._rejectionHandler0;
3384 var promise = follower._promise0;
3385 var receiver = follower._receiverAt(0);
3386 if (receiver === undefined) receiver = UNDEFINED_BINDING;
3387 this._addCallbacks(fulfill, reject, promise, receiver, null);
3388};
3389
3390Promise.prototype._migrateCallbackAt = function (follower, index) {
3391 var fulfill = follower._fulfillmentHandlerAt(index);
3392 var reject = follower._rejectionHandlerAt(index);
3393 var promise = follower._promiseAt(index);
3394 var receiver = follower._receiverAt(index);
3395 if (receiver === undefined) receiver = UNDEFINED_BINDING;
3396 this._addCallbacks(fulfill, reject, promise, receiver, null);
3397};
3398
3399Promise.prototype._addCallbacks = function (
3400 fulfill,
3401 reject,
3402 promise,
3403 receiver,
3404 domain
3405) {
3406 var index = this._length();
3407
3408 if (index >= 65535 - 4) {
3409 index = 0;
3410 this._setLength(0);
3411 }
3412
3413 if (index === 0) {
3414 this._promise0 = promise;
3415 this._receiver0 = receiver;
3416 if (typeof fulfill === "function") {
3417 this._fulfillmentHandler0 =
3418 domain === null ? fulfill : util.domainBind(domain, fulfill);
3419 }
3420 if (typeof reject === "function") {
3421 this._rejectionHandler0 =
3422 domain === null ? reject : util.domainBind(domain, reject);
3423 }
3424 } else {
3425 var base = index * 4 - 4;
3426 this[base + 2] = promise;
3427 this[base + 3] = receiver;
3428 if (typeof fulfill === "function") {
3429 this[base + 0] =
3430 domain === null ? fulfill : util.domainBind(domain, fulfill);
3431 }
3432 if (typeof reject === "function") {
3433 this[base + 1] =
3434 domain === null ? reject : util.domainBind(domain, reject);
3435 }
3436 }
3437 this._setLength(index + 1);
3438 return index;
3439};
3440
3441Promise.prototype._proxy = function (proxyable, arg) {
3442 this._addCallbacks(undefined, undefined, arg, proxyable, null);
3443};
3444
3445Promise.prototype._resolveCallback = function(value, shouldBind) {
3446 if (((this._bitField & 117506048) !== 0)) return;
3447 if (value === this)
3448 return this._rejectCallback(makeSelfResolutionError(), false);
3449 var maybePromise = tryConvertToPromise(value, this);
3450 if (!(maybePromise instanceof Promise)) return this._fulfill(value);
3451
3452 if (shouldBind) this._propagateFrom(maybePromise, 2);
3453
3454 var promise = maybePromise._target();
3455
3456 if (promise === this) {
3457 this._reject(makeSelfResolutionError());
3458 return;
3459 }
3460
3461 var bitField = promise._bitField;
3462 if (((bitField & 50397184) === 0)) {
3463 var len = this._length();
3464 if (len > 0) promise._migrateCallback0(this);
3465 for (var i = 1; i < len; ++i) {
3466 promise._migrateCallbackAt(this, i);
3467 }
3468 this._setFollowing();
3469 this._setLength(0);
3470 this._setFollowee(promise);
3471 } else if (((bitField & 33554432) !== 0)) {
3472 this._fulfill(promise._value());
3473 } else if (((bitField & 16777216) !== 0)) {
3474 this._reject(promise._reason());
3475 } else {
3476 var reason = new CancellationError("late cancellation observer");
3477 promise._attachExtraTrace(reason);
3478 this._reject(reason);
3479 }
3480};
3481
3482Promise.prototype._rejectCallback =
3483function(reason, synchronous, ignoreNonErrorWarnings) {
3484 var trace = util.ensureErrorObject(reason);
3485 var hasStack = trace === reason;
3486 if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
3487 var message = "a promise was rejected with a non-error: " +
3488 util.classString(reason);
3489 this._warn(message, true);
3490 }
3491 this._attachExtraTrace(trace, synchronous ? hasStack : false);
3492 this._reject(reason);
3493};
3494
3495Promise.prototype._resolveFromExecutor = function (executor) {
3496 if (executor === INTERNAL) return;
3497 var promise = this;
3498 this._captureStackTrace();
3499 this._pushContext();
3500 var synchronous = true;
3501 var r = this._execute(executor, function(value) {
3502 promise._resolveCallback(value);
3503 }, function (reason) {
3504 promise._rejectCallback(reason, synchronous);
3505 });
3506 synchronous = false;
3507 this._popContext();
3508
3509 if (r !== undefined) {
3510 promise._rejectCallback(r, true);
3511 }
3512};
3513
3514Promise.prototype._settlePromiseFromHandler = function (
3515 handler, receiver, value, promise
3516) {
3517 var bitField = promise._bitField;
3518 if (((bitField & 65536) !== 0)) return;
3519 promise._pushContext();
3520 var x;
3521 if (receiver === APPLY) {
3522 if (!value || typeof value.length !== "number") {
3523 x = errorObj;
3524 x.e = new TypeError("cannot .spread() a non-array: " +
3525 util.classString(value));
3526 } else {
3527 x = tryCatch(handler).apply(this._boundValue(), value);
3528 }
3529 } else {
3530 x = tryCatch(handler).call(receiver, value);
3531 }
3532 var promiseCreated = promise._popContext();
3533 bitField = promise._bitField;
3534 if (((bitField & 65536) !== 0)) return;
3535
3536 if (x === NEXT_FILTER) {
3537 promise._reject(value);
3538 } else if (x === errorObj) {
3539 promise._rejectCallback(x.e, false);
3540 } else {
3541 debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
3542 promise._resolveCallback(x);
3543 }
3544};
3545
3546Promise.prototype._target = function() {
3547 var ret = this;
3548 while (ret._isFollowing()) ret = ret._followee();
3549 return ret;
3550};
3551
3552Promise.prototype._followee = function() {
3553 return this._rejectionHandler0;
3554};
3555
3556Promise.prototype._setFollowee = function(promise) {
3557 this._rejectionHandler0 = promise;
3558};
3559
3560Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
3561 var isPromise = promise instanceof Promise;
3562 var bitField = this._bitField;
3563 var asyncGuaranteed = ((bitField & 134217728) !== 0);
3564 if (((bitField & 65536) !== 0)) {
3565 if (isPromise) promise._invokeInternalOnCancel();
3566
3567 if (receiver instanceof PassThroughHandlerContext &&
3568 receiver.isFinallyHandler()) {
3569 receiver.cancelPromise = promise;
3570 if (tryCatch(handler).call(receiver, value) === errorObj) {
3571 promise._reject(errorObj.e);
3572 }
3573 } else if (handler === reflectHandler) {
3574 promise._fulfill(reflectHandler.call(receiver));
3575 } else if (receiver instanceof Proxyable) {
3576 receiver._promiseCancelled(promise);
3577 } else if (isPromise || promise instanceof PromiseArray) {
3578 promise._cancel();
3579 } else {
3580 receiver.cancel();
3581 }
3582 } else if (typeof handler === "function") {
3583 if (!isPromise) {
3584 handler.call(receiver, value, promise);
3585 } else {
3586 if (asyncGuaranteed) promise._setAsyncGuaranteed();
3587 this._settlePromiseFromHandler(handler, receiver, value, promise);
3588 }
3589 } else if (receiver instanceof Proxyable) {
3590 if (!receiver._isResolved()) {
3591 if (((bitField & 33554432) !== 0)) {
3592 receiver._promiseFulfilled(value, promise);
3593 } else {
3594 receiver._promiseRejected(value, promise);
3595 }
3596 }
3597 } else if (isPromise) {
3598 if (asyncGuaranteed) promise._setAsyncGuaranteed();
3599 if (((bitField & 33554432) !== 0)) {
3600 promise._fulfill(value);
3601 } else {
3602 promise._reject(value);
3603 }
3604 }
3605};
3606
3607Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
3608 var handler = ctx.handler;
3609 var promise = ctx.promise;
3610 var receiver = ctx.receiver;
3611 var value = ctx.value;
3612 if (typeof handler === "function") {
3613 if (!(promise instanceof Promise)) {
3614 handler.call(receiver, value, promise);
3615 } else {
3616 this._settlePromiseFromHandler(handler, receiver, value, promise);
3617 }
3618 } else if (promise instanceof Promise) {
3619 promise._reject(value);
3620 }
3621};
3622
3623Promise.prototype._settlePromiseCtx = function(ctx) {
3624 this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
3625};
3626
3627Promise.prototype._settlePromise0 = function(handler, value, bitField) {
3628 var promise = this._promise0;
3629 var receiver = this._receiverAt(0);
3630 this._promise0 = undefined;
3631 this._receiver0 = undefined;
3632 this._settlePromise(promise, handler, receiver, value);
3633};
3634
3635Promise.prototype._clearCallbackDataAtIndex = function(index) {
3636 var base = index * 4 - 4;
3637 this[base + 2] =
3638 this[base + 3] =
3639 this[base + 0] =
3640 this[base + 1] = undefined;
3641};
3642
3643Promise.prototype._fulfill = function (value) {
3644 var bitField = this._bitField;
3645 if (((bitField & 117506048) >>> 16)) return;
3646 if (value === this) {
3647 var err = makeSelfResolutionError();
3648 this._attachExtraTrace(err);
3649 return this._reject(err);
3650 }
3651 this._setFulfilled();
3652 this._rejectionHandler0 = value;
3653
3654 if ((bitField & 65535) > 0) {
3655 if (((bitField & 134217728) !== 0)) {
3656 this._settlePromises();
3657 } else {
3658 async.settlePromises(this);
3659 }
3660 }
3661};
3662
3663Promise.prototype._reject = function (reason) {
3664 var bitField = this._bitField;
3665 if (((bitField & 117506048) >>> 16)) return;
3666 this._setRejected();
3667 this._fulfillmentHandler0 = reason;
3668
3669 if (this._isFinal()) {
3670 return async.fatalError(reason, util.isNode);
3671 }
3672
3673 if ((bitField & 65535) > 0) {
3674 async.settlePromises(this);
3675 } else {
3676 this._ensurePossibleRejectionHandled();
3677 }
3678};
3679
3680Promise.prototype._fulfillPromises = function (len, value) {
3681 for (var i = 1; i < len; i++) {
3682 var handler = this._fulfillmentHandlerAt(i);
3683 var promise = this._promiseAt(i);
3684 var receiver = this._receiverAt(i);
3685 this._clearCallbackDataAtIndex(i);
3686 this._settlePromise(promise, handler, receiver, value);
3687 }
3688};
3689
3690Promise.prototype._rejectPromises = function (len, reason) {
3691 for (var i = 1; i < len; i++) {
3692 var handler = this._rejectionHandlerAt(i);
3693 var promise = this._promiseAt(i);
3694 var receiver = this._receiverAt(i);
3695 this._clearCallbackDataAtIndex(i);
3696 this._settlePromise(promise, handler, receiver, reason);
3697 }
3698};
3699
3700Promise.prototype._settlePromises = function () {
3701 var bitField = this._bitField;
3702 var len = (bitField & 65535);
3703
3704 if (len > 0) {
3705 if (((bitField & 16842752) !== 0)) {
3706 var reason = this._fulfillmentHandler0;
3707 this._settlePromise0(this._rejectionHandler0, reason, bitField);
3708 this._rejectPromises(len, reason);
3709 } else {
3710 var value = this._rejectionHandler0;
3711 this._settlePromise0(this._fulfillmentHandler0, value, bitField);
3712 this._fulfillPromises(len, value);
3713 }
3714 this._setLength(0);
3715 }
3716 this._clearCancellationData();
3717};
3718
3719Promise.prototype._settledValue = function() {
3720 var bitField = this._bitField;
3721 if (((bitField & 33554432) !== 0)) {
3722 return this._rejectionHandler0;
3723 } else if (((bitField & 16777216) !== 0)) {
3724 return this._fulfillmentHandler0;
3725 }
3726};
3727
3728function deferResolve(v) {this.promise._resolveCallback(v);}
3729function deferReject(v) {this.promise._rejectCallback(v, false);}
3730
3731Promise.defer = Promise.pending = function() {
3732 debug.deprecated("Promise.defer", "new Promise");
3733 var promise = new Promise(INTERNAL);
3734 return {
3735 promise: promise,
3736 resolve: deferResolve,
3737 reject: deferReject
3738 };
3739};
3740
3741util.notEnumerableProp(Promise,
3742 "_makeSelfResolutionError",
3743 makeSelfResolutionError);
3744
3745_dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
3746 debug);
3747_dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
3748_dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug);
3749_dereq_("./direct_resolve")(Promise);
3750_dereq_("./synchronous_inspection")(Promise);
3751_dereq_("./join")(
3752 Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain);
3753Promise.Promise = Promise;
3754Promise.version = "3.5.0";
3755_dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
3756_dereq_('./call_get.js')(Promise);
3757_dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
3758_dereq_('./timers.js')(Promise, INTERNAL, debug);
3759_dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
3760_dereq_('./nodeify.js')(Promise);
3761_dereq_('./promisify.js')(Promise, INTERNAL);
3762_dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
3763_dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
3764_dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
3765_dereq_('./settle.js')(Promise, PromiseArray, debug);
3766_dereq_('./some.js')(Promise, PromiseArray, apiRejection);
3767_dereq_('./filter.js')(Promise, INTERNAL);
3768_dereq_('./each.js')(Promise, INTERNAL);
3769_dereq_('./any.js')(Promise);
3770
3771 util.toFastProperties(Promise);
3772 util.toFastProperties(Promise.prototype);
3773 function fillTypes(value) {
3774 var p = new Promise(INTERNAL);
3775 p._fulfillmentHandler0 = value;
3776 p._rejectionHandler0 = value;
3777 p._promise0 = value;
3778 p._receiver0 = value;
3779 }
3780 // Complete slack tracking, opt out of field-type tracking and
3781 // stabilize map
3782 fillTypes({a: 1});
3783 fillTypes({b: 2});
3784 fillTypes({c: 3});
3785 fillTypes(1);
3786 fillTypes(function(){});
3787 fillTypes(undefined);
3788 fillTypes(false);
3789 fillTypes(new Promise(INTERNAL));
3790 debug.setBounds(Async.firstLineError, util.lastLineError);
3791 return Promise;
3792
3793};
3794
3795},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(_dereq_,module,exports){
3796"use strict";
3797module.exports = function(Promise, INTERNAL, tryConvertToPromise,
3798 apiRejection, Proxyable) {
3799var util = _dereq_("./util");
3800var isArray = util.isArray;
3801
3802function toResolutionValue(val) {
3803 switch(val) {
3804 case -2: return [];
3805 case -3: return {};
3806 case -6: return new Map();
3807 }
3808}
3809
3810function PromiseArray(values) {
3811 var promise = this._promise = new Promise(INTERNAL);
3812 if (values instanceof Promise) {
3813 promise._propagateFrom(values, 3);
3814 }
3815 promise._setOnCancel(this);
3816 this._values = values;
3817 this._length = 0;
3818 this._totalResolved = 0;
3819 this._init(undefined, -2);
3820}
3821util.inherits(PromiseArray, Proxyable);
3822
3823PromiseArray.prototype.length = function () {
3824 return this._length;
3825};
3826
3827PromiseArray.prototype.promise = function () {
3828 return this._promise;
3829};
3830
3831PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
3832 var values = tryConvertToPromise(this._values, this._promise);
3833 if (values instanceof Promise) {
3834 values = values._target();
3835 var bitField = values._bitField;
3836 ;
3837 this._values = values;
3838
3839 if (((bitField & 50397184) === 0)) {
3840 this._promise._setAsyncGuaranteed();
3841 return values._then(
3842 init,
3843 this._reject,
3844 undefined,
3845 this,
3846 resolveValueIfEmpty
3847 );
3848 } else if (((bitField & 33554432) !== 0)) {
3849 values = values._value();
3850 } else if (((bitField & 16777216) !== 0)) {
3851 return this._reject(values._reason());
3852 } else {
3853 return this._cancel();
3854 }
3855 }
3856 values = util.asArray(values);
3857 if (values === null) {
3858 var err = apiRejection(
3859 "expecting an array or an iterable object but got " + util.classString(values)).reason();
3860 this._promise._rejectCallback(err, false);
3861 return;
3862 }
3863
3864 if (values.length === 0) {
3865 if (resolveValueIfEmpty === -5) {
3866 this._resolveEmptyArray();
3867 }
3868 else {
3869 this._resolve(toResolutionValue(resolveValueIfEmpty));
3870 }
3871 return;
3872 }
3873 this._iterate(values);
3874};
3875
3876PromiseArray.prototype._iterate = function(values) {
3877 var len = this.getActualLength(values.length);
3878 this._length = len;
3879 this._values = this.shouldCopyValues() ? new Array(len) : this._values;
3880 var result = this._promise;
3881 var isResolved = false;
3882 var bitField = null;
3883 for (var i = 0; i < len; ++i) {
3884 var maybePromise = tryConvertToPromise(values[i], result);
3885
3886 if (maybePromise instanceof Promise) {
3887 maybePromise = maybePromise._target();
3888 bitField = maybePromise._bitField;
3889 } else {
3890 bitField = null;
3891 }
3892
3893 if (isResolved) {
3894 if (bitField !== null) {
3895 maybePromise.suppressUnhandledRejections();
3896 }
3897 } else if (bitField !== null) {
3898 if (((bitField & 50397184) === 0)) {
3899 maybePromise._proxy(this, i);
3900 this._values[i] = maybePromise;
3901 } else if (((bitField & 33554432) !== 0)) {
3902 isResolved = this._promiseFulfilled(maybePromise._value(), i);
3903 } else if (((bitField & 16777216) !== 0)) {
3904 isResolved = this._promiseRejected(maybePromise._reason(), i);
3905 } else {
3906 isResolved = this._promiseCancelled(i);
3907 }
3908 } else {
3909 isResolved = this._promiseFulfilled(maybePromise, i);
3910 }
3911 }
3912 if (!isResolved) result._setAsyncGuaranteed();
3913};
3914
3915PromiseArray.prototype._isResolved = function () {
3916 return this._values === null;
3917};
3918
3919PromiseArray.prototype._resolve = function (value) {
3920 this._values = null;
3921 this._promise._fulfill(value);
3922};
3923
3924PromiseArray.prototype._cancel = function() {
3925 if (this._isResolved() || !this._promise._isCancellable()) return;
3926 this._values = null;
3927 this._promise._cancel();
3928};
3929
3930PromiseArray.prototype._reject = function (reason) {
3931 this._values = null;
3932 this._promise._rejectCallback(reason, false);
3933};
3934
3935PromiseArray.prototype._promiseFulfilled = function (value, index) {
3936 this._values[index] = value;
3937 var totalResolved = ++this._totalResolved;
3938 if (totalResolved >= this._length) {
3939 this._resolve(this._values);
3940 return true;
3941 }
3942 return false;
3943};
3944
3945PromiseArray.prototype._promiseCancelled = function() {
3946 this._cancel();
3947 return true;
3948};
3949
3950PromiseArray.prototype._promiseRejected = function (reason) {
3951 this._totalResolved++;
3952 this._reject(reason);
3953 return true;
3954};
3955
3956PromiseArray.prototype._resultCancelled = function() {
3957 if (this._isResolved()) return;
3958 var values = this._values;
3959 this._cancel();
3960 if (values instanceof Promise) {
3961 values.cancel();
3962 } else {
3963 for (var i = 0; i < values.length; ++i) {
3964 if (values[i] instanceof Promise) {
3965 values[i].cancel();
3966 }
3967 }
3968 }
3969};
3970
3971PromiseArray.prototype.shouldCopyValues = function () {
3972 return true;
3973};
3974
3975PromiseArray.prototype.getActualLength = function (len) {
3976 return len;
3977};
3978
3979return PromiseArray;
3980};
3981
3982},{"./util":36}],24:[function(_dereq_,module,exports){
3983"use strict";
3984module.exports = function(Promise, INTERNAL) {
3985var THIS = {};
3986var util = _dereq_("./util");
3987var nodebackForPromise = _dereq_("./nodeback");
3988var withAppended = util.withAppended;
3989var maybeWrapAsError = util.maybeWrapAsError;
3990var canEvaluate = util.canEvaluate;
3991var TypeError = _dereq_("./errors").TypeError;
3992var defaultSuffix = "Async";
3993var defaultPromisified = {__isPromisified__: true};
3994var noCopyProps = [
3995 "arity", "length",
3996 "name",
3997 "arguments",
3998 "caller",
3999 "callee",
4000 "prototype",
4001 "__isPromisified__"
4002];
4003var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
4004
4005var defaultFilter = function(name) {
4006 return util.isIdentifier(name) &&
4007 name.charAt(0) !== "_" &&
4008 name !== "constructor";
4009};
4010
4011function propsFilter(key) {
4012 return !noCopyPropsPattern.test(key);
4013}
4014
4015function isPromisified(fn) {
4016 try {
4017 return fn.__isPromisified__ === true;
4018 }
4019 catch (e) {
4020 return false;
4021 }
4022}
4023
4024function hasPromisified(obj, key, suffix) {
4025 var val = util.getDataPropertyOrDefault(obj, key + suffix,
4026 defaultPromisified);
4027 return val ? isPromisified(val) : false;
4028}
4029function checkValid(ret, suffix, suffixRegexp) {
4030 for (var i = 0; i < ret.length; i += 2) {
4031 var key = ret[i];
4032 if (suffixRegexp.test(key)) {
4033 var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
4034 for (var j = 0; j < ret.length; j += 2) {
4035 if (ret[j] === keyWithoutAsyncSuffix) {
4036 throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/MqrFmX\u000a"
4037 .replace("%s", suffix));
4038 }
4039 }
4040 }
4041 }
4042}
4043
4044function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
4045 var keys = util.inheritedDataKeys(obj);
4046 var ret = [];
4047 for (var i = 0; i < keys.length; ++i) {
4048 var key = keys[i];
4049 var value = obj[key];
4050 var passesDefaultFilter = filter === defaultFilter
4051 ? true : defaultFilter(key, value, obj);
4052 if (typeof value === "function" &&
4053 !isPromisified(value) &&
4054 !hasPromisified(obj, key, suffix) &&
4055 filter(key, value, obj, passesDefaultFilter)) {
4056 ret.push(key, value);
4057 }
4058 }
4059 checkValid(ret, suffix, suffixRegexp);
4060 return ret;
4061}
4062
4063var escapeIdentRegex = function(str) {
4064 return str.replace(/([$])/, "\\$");
4065};
4066
4067var makeNodePromisifiedEval;
4068if (!true) {
4069var switchCaseArgumentOrder = function(likelyArgumentCount) {
4070 var ret = [likelyArgumentCount];
4071 var min = Math.max(0, likelyArgumentCount - 1 - 3);
4072 for(var i = likelyArgumentCount - 1; i >= min; --i) {
4073 ret.push(i);
4074 }
4075 for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
4076 ret.push(i);
4077 }
4078 return ret;
4079};
4080
4081var argumentSequence = function(argumentCount) {
4082 return util.filledRange(argumentCount, "_arg", "");
4083};
4084
4085var parameterDeclaration = function(parameterCount) {
4086 return util.filledRange(
4087 Math.max(parameterCount, 3), "_arg", "");
4088};
4089
4090var parameterCount = function(fn) {
4091 if (typeof fn.length === "number") {
4092 return Math.max(Math.min(fn.length, 1023 + 1), 0);
4093 }
4094 return 0;
4095};
4096
4097makeNodePromisifiedEval =
4098function(callback, receiver, originalName, fn, _, multiArgs) {
4099 var newParameterCount = Math.max(0, parameterCount(fn) - 1);
4100 var argumentOrder = switchCaseArgumentOrder(newParameterCount);
4101 var shouldProxyThis = typeof callback === "string" || receiver === THIS;
4102
4103 function generateCallForArgumentCount(count) {
4104 var args = argumentSequence(count).join(", ");
4105 var comma = count > 0 ? ", " : "";
4106 var ret;
4107 if (shouldProxyThis) {
4108 ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
4109 } else {
4110 ret = receiver === undefined
4111 ? "ret = callback({{args}}, nodeback); break;\n"
4112 : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
4113 }
4114 return ret.replace("{{args}}", args).replace(", ", comma);
4115 }
4116
4117 function generateArgumentSwitchCase() {
4118 var ret = "";
4119 for (var i = 0; i < argumentOrder.length; ++i) {
4120 ret += "case " + argumentOrder[i] +":" +
4121 generateCallForArgumentCount(argumentOrder[i]);
4122 }
4123
4124 ret += " \n\
4125 default: \n\
4126 var args = new Array(len + 1); \n\
4127 var i = 0; \n\
4128 for (var i = 0; i < len; ++i) { \n\
4129 args[i] = arguments[i]; \n\
4130 } \n\
4131 args[i] = nodeback; \n\
4132 [CodeForCall] \n\
4133 break; \n\
4134 ".replace("[CodeForCall]", (shouldProxyThis
4135 ? "ret = callback.apply(this, args);\n"
4136 : "ret = callback.apply(receiver, args);\n"));
4137 return ret;
4138 }
4139
4140 var getFunctionCode = typeof callback === "string"
4141 ? ("this != null ? this['"+callback+"'] : fn")
4142 : "fn";
4143 var body = "'use strict'; \n\
4144 var ret = function (Parameters) { \n\
4145 'use strict'; \n\
4146 var len = arguments.length; \n\
4147 var promise = new Promise(INTERNAL); \n\
4148 promise._captureStackTrace(); \n\
4149 var nodeback = nodebackForPromise(promise, " + multiArgs + "); \n\
4150 var ret; \n\
4151 var callback = tryCatch([GetFunctionCode]); \n\
4152 switch(len) { \n\
4153 [CodeForSwitchCase] \n\
4154 } \n\
4155 if (ret === errorObj) { \n\
4156 promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
4157 } \n\
4158 if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); \n\
4159 return promise; \n\
4160 }; \n\
4161 notEnumerableProp(ret, '__isPromisified__', true); \n\
4162 return ret; \n\
4163 ".replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
4164 .replace("[GetFunctionCode]", getFunctionCode);
4165 body = body.replace("Parameters", parameterDeclaration(newParameterCount));
4166 return new Function("Promise",
4167 "fn",
4168 "receiver",
4169 "withAppended",
4170 "maybeWrapAsError",
4171 "nodebackForPromise",
4172 "tryCatch",
4173 "errorObj",
4174 "notEnumerableProp",
4175 "INTERNAL",
4176 body)(
4177 Promise,
4178 fn,
4179 receiver,
4180 withAppended,
4181 maybeWrapAsError,
4182 nodebackForPromise,
4183 util.tryCatch,
4184 util.errorObj,
4185 util.notEnumerableProp,
4186 INTERNAL);
4187};
4188}
4189
4190function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) {
4191 var defaultThis = (function() {return this;})();
4192 var method = callback;
4193 if (typeof method === "string") {
4194 callback = fn;
4195 }
4196 function promisified() {
4197 var _receiver = receiver;
4198 if (receiver === THIS) _receiver = this;
4199 var promise = new Promise(INTERNAL);
4200 promise._captureStackTrace();
4201 var cb = typeof method === "string" && this !== defaultThis
4202 ? this[method] : callback;
4203 var fn = nodebackForPromise(promise, multiArgs);
4204 try {
4205 cb.apply(_receiver, withAppended(arguments, fn));
4206 } catch(e) {
4207 promise._rejectCallback(maybeWrapAsError(e), true, true);
4208 }
4209 if (!promise._isFateSealed()) promise._setAsyncGuaranteed();
4210 return promise;
4211 }
4212 util.notEnumerableProp(promisified, "__isPromisified__", true);
4213 return promisified;
4214}
4215
4216var makeNodePromisified = canEvaluate
4217 ? makeNodePromisifiedEval
4218 : makeNodePromisifiedClosure;
4219
4220function promisifyAll(obj, suffix, filter, promisifier, multiArgs) {
4221 var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
4222 var methods =
4223 promisifiableMethods(obj, suffix, suffixRegexp, filter);
4224
4225 for (var i = 0, len = methods.length; i < len; i+= 2) {
4226 var key = methods[i];
4227 var fn = methods[i+1];
4228 var promisifiedKey = key + suffix;
4229 if (promisifier === makeNodePromisified) {
4230 obj[promisifiedKey] =
4231 makeNodePromisified(key, THIS, key, fn, suffix, multiArgs);
4232 } else {
4233 var promisified = promisifier(fn, function() {
4234 return makeNodePromisified(key, THIS, key,
4235 fn, suffix, multiArgs);
4236 });
4237 util.notEnumerableProp(promisified, "__isPromisified__", true);
4238 obj[promisifiedKey] = promisified;
4239 }
4240 }
4241 util.toFastProperties(obj);
4242 return obj;
4243}
4244
4245function promisify(callback, receiver, multiArgs) {
4246 return makeNodePromisified(callback, receiver, undefined,
4247 callback, null, multiArgs);
4248}
4249
4250Promise.promisify = function (fn, options) {
4251 if (typeof fn !== "function") {
4252 throw new TypeError("expecting a function but got " + util.classString(fn));
4253 }
4254 if (isPromisified(fn)) {
4255 return fn;
4256 }
4257 options = Object(options);
4258 var receiver = options.context === undefined ? THIS : options.context;
4259 var multiArgs = !!options.multiArgs;
4260 var ret = promisify(fn, receiver, multiArgs);
4261 util.copyDescriptors(fn, ret, propsFilter);
4262 return ret;
4263};
4264
4265Promise.promisifyAll = function (target, options) {
4266 if (typeof target !== "function" && typeof target !== "object") {
4267 throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
4268 }
4269 options = Object(options);
4270 var multiArgs = !!options.multiArgs;
4271 var suffix = options.suffix;
4272 if (typeof suffix !== "string") suffix = defaultSuffix;
4273 var filter = options.filter;
4274 if (typeof filter !== "function") filter = defaultFilter;
4275 var promisifier = options.promisifier;
4276 if (typeof promisifier !== "function") promisifier = makeNodePromisified;
4277
4278 if (!util.isIdentifier(suffix)) {
4279 throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a");
4280 }
4281
4282 var keys = util.inheritedDataKeys(target);
4283 for (var i = 0; i < keys.length; ++i) {
4284 var value = target[keys[i]];
4285 if (keys[i] !== "constructor" &&
4286 util.isClass(value)) {
4287 promisifyAll(value.prototype, suffix, filter, promisifier,
4288 multiArgs);
4289 promisifyAll(value, suffix, filter, promisifier, multiArgs);
4290 }
4291 }
4292
4293 return promisifyAll(target, suffix, filter, promisifier, multiArgs);
4294};
4295};
4296
4297
4298},{"./errors":12,"./nodeback":20,"./util":36}],25:[function(_dereq_,module,exports){
4299"use strict";
4300module.exports = function(
4301 Promise, PromiseArray, tryConvertToPromise, apiRejection) {
4302var util = _dereq_("./util");
4303var isObject = util.isObject;
4304var es5 = _dereq_("./es5");
4305var Es6Map;
4306if (typeof Map === "function") Es6Map = Map;
4307
4308var mapToEntries = (function() {
4309 var index = 0;
4310 var size = 0;
4311
4312 function extractEntry(value, key) {
4313 this[index] = value;
4314 this[index + size] = key;
4315 index++;
4316 }
4317
4318 return function mapToEntries(map) {
4319 size = map.size;
4320 index = 0;
4321 var ret = new Array(map.size * 2);
4322 map.forEach(extractEntry, ret);
4323 return ret;
4324 };
4325})();
4326
4327var entriesToMap = function(entries) {
4328 var ret = new Es6Map();
4329 var length = entries.length / 2 | 0;
4330 for (var i = 0; i < length; ++i) {
4331 var key = entries[length + i];
4332 var value = entries[i];
4333 ret.set(key, value);
4334 }
4335 return ret;
4336};
4337
4338function PropertiesPromiseArray(obj) {
4339 var isMap = false;
4340 var entries;
4341 if (Es6Map !== undefined && obj instanceof Es6Map) {
4342 entries = mapToEntries(obj);
4343 isMap = true;
4344 } else {
4345 var keys = es5.keys(obj);
4346 var len = keys.length;
4347 entries = new Array(len * 2);
4348 for (var i = 0; i < len; ++i) {
4349 var key = keys[i];
4350 entries[i] = obj[key];
4351 entries[i + len] = key;
4352 }
4353 }
4354 this.constructor$(entries);
4355 this._isMap = isMap;
4356 this._init$(undefined, isMap ? -6 : -3);
4357}
4358util.inherits(PropertiesPromiseArray, PromiseArray);
4359
4360PropertiesPromiseArray.prototype._init = function () {};
4361
4362PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
4363 this._values[index] = value;
4364 var totalResolved = ++this._totalResolved;
4365 if (totalResolved >= this._length) {
4366 var val;
4367 if (this._isMap) {
4368 val = entriesToMap(this._values);
4369 } else {
4370 val = {};
4371 var keyOffset = this.length();
4372 for (var i = 0, len = this.length(); i < len; ++i) {
4373 val[this._values[i + keyOffset]] = this._values[i];
4374 }
4375 }
4376 this._resolve(val);
4377 return true;
4378 }
4379 return false;
4380};
4381
4382PropertiesPromiseArray.prototype.shouldCopyValues = function () {
4383 return false;
4384};
4385
4386PropertiesPromiseArray.prototype.getActualLength = function (len) {
4387 return len >> 1;
4388};
4389
4390function props(promises) {
4391 var ret;
4392 var castValue = tryConvertToPromise(promises);
4393
4394 if (!isObject(castValue)) {
4395 return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/MqrFmX\u000a");
4396 } else if (castValue instanceof Promise) {
4397 ret = castValue._then(
4398 Promise.props, undefined, undefined, undefined, undefined);
4399 } else {
4400 ret = new PropertiesPromiseArray(castValue).promise();
4401 }
4402
4403 if (castValue instanceof Promise) {
4404 ret._propagateFrom(castValue, 2);
4405 }
4406 return ret;
4407}
4408
4409Promise.prototype.props = function () {
4410 return props(this);
4411};
4412
4413Promise.props = function (promises) {
4414 return props(promises);
4415};
4416};
4417
4418},{"./es5":13,"./util":36}],26:[function(_dereq_,module,exports){
4419"use strict";
4420function arrayMove(src, srcIndex, dst, dstIndex, len) {
4421 for (var j = 0; j < len; ++j) {
4422 dst[j + dstIndex] = src[j + srcIndex];
4423 src[j + srcIndex] = void 0;
4424 }
4425}
4426
4427function Queue(capacity) {
4428 this._capacity = capacity;
4429 this._length = 0;
4430 this._front = 0;
4431}
4432
4433Queue.prototype._willBeOverCapacity = function (size) {
4434 return this._capacity < size;
4435};
4436
4437Queue.prototype._pushOne = function (arg) {
4438 var length = this.length();
4439 this._checkCapacity(length + 1);
4440 var i = (this._front + length) & (this._capacity - 1);
4441 this[i] = arg;
4442 this._length = length + 1;
4443};
4444
4445Queue.prototype.push = function (fn, receiver, arg) {
4446 var length = this.length() + 3;
4447 if (this._willBeOverCapacity(length)) {
4448 this._pushOne(fn);
4449 this._pushOne(receiver);
4450 this._pushOne(arg);
4451 return;
4452 }
4453 var j = this._front + length - 3;
4454 this._checkCapacity(length);
4455 var wrapMask = this._capacity - 1;
4456 this[(j + 0) & wrapMask] = fn;
4457 this[(j + 1) & wrapMask] = receiver;
4458 this[(j + 2) & wrapMask] = arg;
4459 this._length = length;
4460};
4461
4462Queue.prototype.shift = function () {
4463 var front = this._front,
4464 ret = this[front];
4465
4466 this[front] = undefined;
4467 this._front = (front + 1) & (this._capacity - 1);
4468 this._length--;
4469 return ret;
4470};
4471
4472Queue.prototype.length = function () {
4473 return this._length;
4474};
4475
4476Queue.prototype._checkCapacity = function (size) {
4477 if (this._capacity < size) {
4478 this._resizeTo(this._capacity << 1);
4479 }
4480};
4481
4482Queue.prototype._resizeTo = function (capacity) {
4483 var oldCapacity = this._capacity;
4484 this._capacity = capacity;
4485 var front = this._front;
4486 var length = this._length;
4487 var moveItemsCount = (front + length) & (oldCapacity - 1);
4488 arrayMove(this, 0, this, oldCapacity, moveItemsCount);
4489};
4490
4491module.exports = Queue;
4492
4493},{}],27:[function(_dereq_,module,exports){
4494"use strict";
4495module.exports = function(
4496 Promise, INTERNAL, tryConvertToPromise, apiRejection) {
4497var util = _dereq_("./util");
4498
4499var raceLater = function (promise) {
4500 return promise.then(function(array) {
4501 return race(array, promise);
4502 });
4503};
4504
4505function race(promises, parent) {
4506 var maybePromise = tryConvertToPromise(promises);
4507
4508 if (maybePromise instanceof Promise) {
4509 return raceLater(maybePromise);
4510 } else {
4511 promises = util.asArray(promises);
4512 if (promises === null)
4513 return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
4514 }
4515
4516 var ret = new Promise(INTERNAL);
4517 if (parent !== undefined) {
4518 ret._propagateFrom(parent, 3);
4519 }
4520 var fulfill = ret._fulfill;
4521 var reject = ret._reject;
4522 for (var i = 0, len = promises.length; i < len; ++i) {
4523 var val = promises[i];
4524
4525 if (val === undefined && !(i in promises)) {
4526 continue;
4527 }
4528
4529 Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
4530 }
4531 return ret;
4532}
4533
4534Promise.race = function (promises) {
4535 return race(promises, undefined);
4536};
4537
4538Promise.prototype.race = function () {
4539 return race(this, undefined);
4540};
4541
4542};
4543
4544},{"./util":36}],28:[function(_dereq_,module,exports){
4545"use strict";
4546module.exports = function(Promise,
4547 PromiseArray,
4548 apiRejection,
4549 tryConvertToPromise,
4550 INTERNAL,
4551 debug) {
4552var getDomain = Promise._getDomain;
4553var util = _dereq_("./util");
4554var tryCatch = util.tryCatch;
4555
4556function ReductionPromiseArray(promises, fn, initialValue, _each) {
4557 this.constructor$(promises);
4558 var domain = getDomain();
4559 this._fn = domain === null ? fn : util.domainBind(domain, fn);
4560 if (initialValue !== undefined) {
4561 initialValue = Promise.resolve(initialValue);
4562 initialValue._attachCancellationCallback(this);
4563 }
4564 this._initialValue = initialValue;
4565 this._currentCancellable = null;
4566 if(_each === INTERNAL) {
4567 this._eachValues = Array(this._length);
4568 } else if (_each === 0) {
4569 this._eachValues = null;
4570 } else {
4571 this._eachValues = undefined;
4572 }
4573 this._promise._captureStackTrace();
4574 this._init$(undefined, -5);
4575}
4576util.inherits(ReductionPromiseArray, PromiseArray);
4577
4578ReductionPromiseArray.prototype._gotAccum = function(accum) {
4579 if (this._eachValues !== undefined &&
4580 this._eachValues !== null &&
4581 accum !== INTERNAL) {
4582 this._eachValues.push(accum);
4583 }
4584};
4585
4586ReductionPromiseArray.prototype._eachComplete = function(value) {
4587 if (this._eachValues !== null) {
4588 this._eachValues.push(value);
4589 }
4590 return this._eachValues;
4591};
4592
4593ReductionPromiseArray.prototype._init = function() {};
4594
4595ReductionPromiseArray.prototype._resolveEmptyArray = function() {
4596 this._resolve(this._eachValues !== undefined ? this._eachValues
4597 : this._initialValue);
4598};
4599
4600ReductionPromiseArray.prototype.shouldCopyValues = function () {
4601 return false;
4602};
4603
4604ReductionPromiseArray.prototype._resolve = function(value) {
4605 this._promise._resolveCallback(value);
4606 this._values = null;
4607};
4608
4609ReductionPromiseArray.prototype._resultCancelled = function(sender) {
4610 if (sender === this._initialValue) return this._cancel();
4611 if (this._isResolved()) return;
4612 this._resultCancelled$();
4613 if (this._currentCancellable instanceof Promise) {
4614 this._currentCancellable.cancel();
4615 }
4616 if (this._initialValue instanceof Promise) {
4617 this._initialValue.cancel();
4618 }
4619};
4620
4621ReductionPromiseArray.prototype._iterate = function (values) {
4622 this._values = values;
4623 var value;
4624 var i;
4625 var length = values.length;
4626 if (this._initialValue !== undefined) {
4627 value = this._initialValue;
4628 i = 0;
4629 } else {
4630 value = Promise.resolve(values[0]);
4631 i = 1;
4632 }
4633
4634 this._currentCancellable = value;
4635
4636 if (!value.isRejected()) {
4637 for (; i < length; ++i) {
4638 var ctx = {
4639 accum: null,
4640 value: values[i],
4641 index: i,
4642 length: length,
4643 array: this
4644 };
4645 value = value._then(gotAccum, undefined, undefined, ctx, undefined);
4646 }
4647 }
4648
4649 if (this._eachValues !== undefined) {
4650 value = value
4651 ._then(this._eachComplete, undefined, undefined, this, undefined);
4652 }
4653 value._then(completed, completed, undefined, value, this);
4654};
4655
4656Promise.prototype.reduce = function (fn, initialValue) {
4657 return reduce(this, fn, initialValue, null);
4658};
4659
4660Promise.reduce = function (promises, fn, initialValue, _each) {
4661 return reduce(promises, fn, initialValue, _each);
4662};
4663
4664function completed(valueOrReason, array) {
4665 if (this.isFulfilled()) {
4666 array._resolve(valueOrReason);
4667 } else {
4668 array._reject(valueOrReason);
4669 }
4670}
4671
4672function reduce(promises, fn, initialValue, _each) {
4673 if (typeof fn !== "function") {
4674 return apiRejection("expecting a function but got " + util.classString(fn));
4675 }
4676 var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
4677 return array.promise();
4678}
4679
4680function gotAccum(accum) {
4681 this.accum = accum;
4682 this.array._gotAccum(accum);
4683 var value = tryConvertToPromise(this.value, this.array._promise);
4684 if (value instanceof Promise) {
4685 this.array._currentCancellable = value;
4686 return value._then(gotValue, undefined, undefined, this, undefined);
4687 } else {
4688 return gotValue.call(this, value);
4689 }
4690}
4691
4692function gotValue(value) {
4693 var array = this.array;
4694 var promise = array._promise;
4695 var fn = tryCatch(array._fn);
4696 promise._pushContext();
4697 var ret;
4698 if (array._eachValues !== undefined) {
4699 ret = fn.call(promise._boundValue(), value, this.index, this.length);
4700 } else {
4701 ret = fn.call(promise._boundValue(),
4702 this.accum, value, this.index, this.length);
4703 }
4704 if (ret instanceof Promise) {
4705 array._currentCancellable = ret;
4706 }
4707 var promiseCreated = promise._popContext();
4708 debug.checkForgottenReturns(
4709 ret,
4710 promiseCreated,
4711 array._eachValues !== undefined ? "Promise.each" : "Promise.reduce",
4712 promise
4713 );
4714 return ret;
4715}
4716};
4717
4718},{"./util":36}],29:[function(_dereq_,module,exports){
4719"use strict";
4720var util = _dereq_("./util");
4721var schedule;
4722var noAsyncScheduler = function() {
4723 throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
4724};
4725var NativePromise = util.getNativePromise();
4726if (util.isNode && typeof MutationObserver === "undefined") {
4727 var GlobalSetImmediate = global.setImmediate;
4728 var ProcessNextTick = process.nextTick;
4729 schedule = util.isRecentNode
4730 ? function(fn) { GlobalSetImmediate.call(global, fn); }
4731 : function(fn) { ProcessNextTick.call(process, fn); };
4732} else if (typeof NativePromise === "function" &&
4733 typeof NativePromise.resolve === "function") {
4734 var nativePromise = NativePromise.resolve();
4735 schedule = function(fn) {
4736 nativePromise.then(fn);
4737 };
4738} else if ((typeof MutationObserver !== "undefined") &&
4739 !(typeof window !== "undefined" &&
4740 window.navigator &&
4741 (window.navigator.standalone || window.cordova))) {
4742 schedule = (function() {
4743 var div = document.createElement("div");
4744 var opts = {attributes: true};
4745 var toggleScheduled = false;
4746 var div2 = document.createElement("div");
4747 var o2 = new MutationObserver(function() {
4748 div.classList.toggle("foo");
4749 toggleScheduled = false;
4750 });
4751 o2.observe(div2, opts);
4752
4753 var scheduleToggle = function() {
4754 if (toggleScheduled) return;
4755 toggleScheduled = true;
4756 div2.classList.toggle("foo");
4757 };
4758
4759 return function schedule(fn) {
4760 var o = new MutationObserver(function() {
4761 o.disconnect();
4762 fn();
4763 });
4764 o.observe(div, opts);
4765 scheduleToggle();
4766 };
4767 })();
4768} else if (typeof setImmediate !== "undefined") {
4769 schedule = function (fn) {
4770 setImmediate(fn);
4771 };
4772} else if (typeof setTimeout !== "undefined") {
4773 schedule = function (fn) {
4774 setTimeout(fn, 0);
4775 };
4776} else {
4777 schedule = noAsyncScheduler;
4778}
4779module.exports = schedule;
4780
4781},{"./util":36}],30:[function(_dereq_,module,exports){
4782"use strict";
4783module.exports =
4784 function(Promise, PromiseArray, debug) {
4785var PromiseInspection = Promise.PromiseInspection;
4786var util = _dereq_("./util");
4787
4788function SettledPromiseArray(values) {
4789 this.constructor$(values);
4790}
4791util.inherits(SettledPromiseArray, PromiseArray);
4792
4793SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
4794 this._values[index] = inspection;
4795 var totalResolved = ++this._totalResolved;
4796 if (totalResolved >= this._length) {
4797 this._resolve(this._values);
4798 return true;
4799 }
4800 return false;
4801};
4802
4803SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
4804 var ret = new PromiseInspection();
4805 ret._bitField = 33554432;
4806 ret._settledValueField = value;
4807 return this._promiseResolved(index, ret);
4808};
4809SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
4810 var ret = new PromiseInspection();
4811 ret._bitField = 16777216;
4812 ret._settledValueField = reason;
4813 return this._promiseResolved(index, ret);
4814};
4815
4816Promise.settle = function (promises) {
4817 debug.deprecated(".settle()", ".reflect()");
4818 return new SettledPromiseArray(promises).promise();
4819};
4820
4821Promise.prototype.settle = function () {
4822 return Promise.settle(this);
4823};
4824};
4825
4826},{"./util":36}],31:[function(_dereq_,module,exports){
4827"use strict";
4828module.exports =
4829function(Promise, PromiseArray, apiRejection) {
4830var util = _dereq_("./util");
4831var RangeError = _dereq_("./errors").RangeError;
4832var AggregateError = _dereq_("./errors").AggregateError;
4833var isArray = util.isArray;
4834var CANCELLATION = {};
4835
4836
4837function SomePromiseArray(values) {
4838 this.constructor$(values);
4839 this._howMany = 0;
4840 this._unwrap = false;
4841 this._initialized = false;
4842}
4843util.inherits(SomePromiseArray, PromiseArray);
4844
4845SomePromiseArray.prototype._init = function () {
4846 if (!this._initialized) {
4847 return;
4848 }
4849 if (this._howMany === 0) {
4850 this._resolve([]);
4851 return;
4852 }
4853 this._init$(undefined, -5);
4854 var isArrayResolved = isArray(this._values);
4855 if (!this._isResolved() &&
4856 isArrayResolved &&
4857 this._howMany > this._canPossiblyFulfill()) {
4858 this._reject(this._getRangeError(this.length()));
4859 }
4860};
4861
4862SomePromiseArray.prototype.init = function () {
4863 this._initialized = true;
4864 this._init();
4865};
4866
4867SomePromiseArray.prototype.setUnwrap = function () {
4868 this._unwrap = true;
4869};
4870
4871SomePromiseArray.prototype.howMany = function () {
4872 return this._howMany;
4873};
4874
4875SomePromiseArray.prototype.setHowMany = function (count) {
4876 this._howMany = count;
4877};
4878
4879SomePromiseArray.prototype._promiseFulfilled = function (value) {
4880 this._addFulfilled(value);
4881 if (this._fulfilled() === this.howMany()) {
4882 this._values.length = this.howMany();
4883 if (this.howMany() === 1 && this._unwrap) {
4884 this._resolve(this._values[0]);
4885 } else {
4886 this._resolve(this._values);
4887 }
4888 return true;
4889 }
4890 return false;
4891
4892};
4893SomePromiseArray.prototype._promiseRejected = function (reason) {
4894 this._addRejected(reason);
4895 return this._checkOutcome();
4896};
4897
4898SomePromiseArray.prototype._promiseCancelled = function () {
4899 if (this._values instanceof Promise || this._values == null) {
4900 return this._cancel();
4901 }
4902 this._addRejected(CANCELLATION);
4903 return this._checkOutcome();
4904};
4905
4906SomePromiseArray.prototype._checkOutcome = function() {
4907 if (this.howMany() > this._canPossiblyFulfill()) {
4908 var e = new AggregateError();
4909 for (var i = this.length(); i < this._values.length; ++i) {
4910 if (this._values[i] !== CANCELLATION) {
4911 e.push(this._values[i]);
4912 }
4913 }
4914 if (e.length > 0) {
4915 this._reject(e);
4916 } else {
4917 this._cancel();
4918 }
4919 return true;
4920 }
4921 return false;
4922};
4923
4924SomePromiseArray.prototype._fulfilled = function () {
4925 return this._totalResolved;
4926};
4927
4928SomePromiseArray.prototype._rejected = function () {
4929 return this._values.length - this.length();
4930};
4931
4932SomePromiseArray.prototype._addRejected = function (reason) {
4933 this._values.push(reason);
4934};
4935
4936SomePromiseArray.prototype._addFulfilled = function (value) {
4937 this._values[this._totalResolved++] = value;
4938};
4939
4940SomePromiseArray.prototype._canPossiblyFulfill = function () {
4941 return this.length() - this._rejected();
4942};
4943
4944SomePromiseArray.prototype._getRangeError = function (count) {
4945 var message = "Input array must contain at least " +
4946 this._howMany + " items but contains only " + count + " items";
4947 return new RangeError(message);
4948};
4949
4950SomePromiseArray.prototype._resolveEmptyArray = function () {
4951 this._reject(this._getRangeError(0));
4952};
4953
4954function some(promises, howMany) {
4955 if ((howMany | 0) !== howMany || howMany < 0) {
4956 return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/MqrFmX\u000a");
4957 }
4958 var ret = new SomePromiseArray(promises);
4959 var promise = ret.promise();
4960 ret.setHowMany(howMany);
4961 ret.init();
4962 return promise;
4963}
4964
4965Promise.some = function (promises, howMany) {
4966 return some(promises, howMany);
4967};
4968
4969Promise.prototype.some = function (howMany) {
4970 return some(this, howMany);
4971};
4972
4973Promise._SomePromiseArray = SomePromiseArray;
4974};
4975
4976},{"./errors":12,"./util":36}],32:[function(_dereq_,module,exports){
4977"use strict";
4978module.exports = function(Promise) {
4979function PromiseInspection(promise) {
4980 if (promise !== undefined) {
4981 promise = promise._target();
4982 this._bitField = promise._bitField;
4983 this._settledValueField = promise._isFateSealed()
4984 ? promise._settledValue() : undefined;
4985 }
4986 else {
4987 this._bitField = 0;
4988 this._settledValueField = undefined;
4989 }
4990}
4991
4992PromiseInspection.prototype._settledValue = function() {
4993 return this._settledValueField;
4994};
4995
4996var value = PromiseInspection.prototype.value = function () {
4997 if (!this.isFulfilled()) {
4998 throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
4999 }
5000 return this._settledValue();
5001};
5002
5003var reason = PromiseInspection.prototype.error =
5004PromiseInspection.prototype.reason = function () {
5005 if (!this.isRejected()) {
5006 throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
5007 }
5008 return this._settledValue();
5009};
5010
5011var isFulfilled = PromiseInspection.prototype.isFulfilled = function() {
5012 return (this._bitField & 33554432) !== 0;
5013};
5014
5015var isRejected = PromiseInspection.prototype.isRejected = function () {
5016 return (this._bitField & 16777216) !== 0;
5017};
5018
5019var isPending = PromiseInspection.prototype.isPending = function () {
5020 return (this._bitField & 50397184) === 0;
5021};
5022
5023var isResolved = PromiseInspection.prototype.isResolved = function () {
5024 return (this._bitField & 50331648) !== 0;
5025};
5026
5027PromiseInspection.prototype.isCancelled = function() {
5028 return (this._bitField & 8454144) !== 0;
5029};
5030
5031Promise.prototype.__isCancelled = function() {
5032 return (this._bitField & 65536) === 65536;
5033};
5034
5035Promise.prototype._isCancelled = function() {
5036 return this._target().__isCancelled();
5037};
5038
5039Promise.prototype.isCancelled = function() {
5040 return (this._target()._bitField & 8454144) !== 0;
5041};
5042
5043Promise.prototype.isPending = function() {
5044 return isPending.call(this._target());
5045};
5046
5047Promise.prototype.isRejected = function() {
5048 return isRejected.call(this._target());
5049};
5050
5051Promise.prototype.isFulfilled = function() {
5052 return isFulfilled.call(this._target());
5053};
5054
5055Promise.prototype.isResolved = function() {
5056 return isResolved.call(this._target());
5057};
5058
5059Promise.prototype.value = function() {
5060 return value.call(this._target());
5061};
5062
5063Promise.prototype.reason = function() {
5064 var target = this._target();
5065 target._unsetRejectionIsUnhandled();
5066 return reason.call(target);
5067};
5068
5069Promise.prototype._value = function() {
5070 return this._settledValue();
5071};
5072
5073Promise.prototype._reason = function() {
5074 this._unsetRejectionIsUnhandled();
5075 return this._settledValue();
5076};
5077
5078Promise.PromiseInspection = PromiseInspection;
5079};
5080
5081},{}],33:[function(_dereq_,module,exports){
5082"use strict";
5083module.exports = function(Promise, INTERNAL) {
5084var util = _dereq_("./util");
5085var errorObj = util.errorObj;
5086var isObject = util.isObject;
5087
5088function tryConvertToPromise(obj, context) {
5089 if (isObject(obj)) {
5090 if (obj instanceof Promise) return obj;
5091 var then = getThen(obj);
5092 if (then === errorObj) {
5093 if (context) context._pushContext();
5094 var ret = Promise.reject(then.e);
5095 if (context) context._popContext();
5096 return ret;
5097 } else if (typeof then === "function") {
5098 if (isAnyBluebirdPromise(obj)) {
5099 var ret = new Promise(INTERNAL);
5100 obj._then(
5101 ret._fulfill,
5102 ret._reject,
5103 undefined,
5104 ret,
5105 null
5106 );
5107 return ret;
5108 }
5109 return doThenable(obj, then, context);
5110 }
5111 }
5112 return obj;
5113}
5114
5115function doGetThen(obj) {
5116 return obj.then;
5117}
5118
5119function getThen(obj) {
5120 try {
5121 return doGetThen(obj);
5122 } catch (e) {
5123 errorObj.e = e;
5124 return errorObj;
5125 }
5126}
5127
5128var hasProp = {}.hasOwnProperty;
5129function isAnyBluebirdPromise(obj) {
5130 try {
5131 return hasProp.call(obj, "_promise0");
5132 } catch (e) {
5133 return false;
5134 }
5135}
5136
5137function doThenable(x, then, context) {
5138 var promise = new Promise(INTERNAL);
5139 var ret = promise;
5140 if (context) context._pushContext();
5141 promise._captureStackTrace();
5142 if (context) context._popContext();
5143 var synchronous = true;
5144 var result = util.tryCatch(then).call(x, resolve, reject);
5145 synchronous = false;
5146
5147 if (promise && result === errorObj) {
5148 promise._rejectCallback(result.e, true, true);
5149 promise = null;
5150 }
5151
5152 function resolve(value) {
5153 if (!promise) return;
5154 promise._resolveCallback(value);
5155 promise = null;
5156 }
5157
5158 function reject(reason) {
5159 if (!promise) return;
5160 promise._rejectCallback(reason, synchronous, true);
5161 promise = null;
5162 }
5163 return ret;
5164}
5165
5166return tryConvertToPromise;
5167};
5168
5169},{"./util":36}],34:[function(_dereq_,module,exports){
5170"use strict";
5171module.exports = function(Promise, INTERNAL, debug) {
5172var util = _dereq_("./util");
5173var TimeoutError = Promise.TimeoutError;
5174
5175function HandleWrapper(handle) {
5176 this.handle = handle;
5177}
5178
5179HandleWrapper.prototype._resultCancelled = function() {
5180 clearTimeout(this.handle);
5181};
5182
5183var afterValue = function(value) { return delay(+this).thenReturn(value); };
5184var delay = Promise.delay = function (ms, value) {
5185 var ret;
5186 var handle;
5187 if (value !== undefined) {
5188 ret = Promise.resolve(value)
5189 ._then(afterValue, null, null, ms, undefined);
5190 if (debug.cancellation() && value instanceof Promise) {
5191 ret._setOnCancel(value);
5192 }
5193 } else {
5194 ret = new Promise(INTERNAL);
5195 handle = setTimeout(function() { ret._fulfill(); }, +ms);
5196 if (debug.cancellation()) {
5197 ret._setOnCancel(new HandleWrapper(handle));
5198 }
5199 ret._captureStackTrace();
5200 }
5201 ret._setAsyncGuaranteed();
5202 return ret;
5203};
5204
5205Promise.prototype.delay = function (ms) {
5206 return delay(ms, this);
5207};
5208
5209var afterTimeout = function (promise, message, parent) {
5210 var err;
5211 if (typeof message !== "string") {
5212 if (message instanceof Error) {
5213 err = message;
5214 } else {
5215 err = new TimeoutError("operation timed out");
5216 }
5217 } else {
5218 err = new TimeoutError(message);
5219 }
5220 util.markAsOriginatingFromRejection(err);
5221 promise._attachExtraTrace(err);
5222 promise._reject(err);
5223
5224 if (parent != null) {
5225 parent.cancel();
5226 }
5227};
5228
5229function successClear(value) {
5230 clearTimeout(this.handle);
5231 return value;
5232}
5233
5234function failureClear(reason) {
5235 clearTimeout(this.handle);
5236 throw reason;
5237}
5238
5239Promise.prototype.timeout = function (ms, message) {
5240 ms = +ms;
5241 var ret, parent;
5242
5243 var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() {
5244 if (ret.isPending()) {
5245 afterTimeout(ret, message, parent);
5246 }
5247 }, ms));
5248
5249 if (debug.cancellation()) {
5250 parent = this.then();
5251 ret = parent._then(successClear, failureClear,
5252 undefined, handleWrapper, undefined);
5253 ret._setOnCancel(handleWrapper);
5254 } else {
5255 ret = this._then(successClear, failureClear,
5256 undefined, handleWrapper, undefined);
5257 }
5258
5259 return ret;
5260};
5261
5262};
5263
5264},{"./util":36}],35:[function(_dereq_,module,exports){
5265"use strict";
5266module.exports = function (Promise, apiRejection, tryConvertToPromise,
5267 createContext, INTERNAL, debug) {
5268 var util = _dereq_("./util");
5269 var TypeError = _dereq_("./errors").TypeError;
5270 var inherits = _dereq_("./util").inherits;
5271 var errorObj = util.errorObj;
5272 var tryCatch = util.tryCatch;
5273 var NULL = {};
5274
5275 function thrower(e) {
5276 setTimeout(function(){throw e;}, 0);
5277 }
5278
5279 function castPreservingDisposable(thenable) {
5280 var maybePromise = tryConvertToPromise(thenable);
5281 if (maybePromise !== thenable &&
5282 typeof thenable._isDisposable === "function" &&
5283 typeof thenable._getDisposer === "function" &&
5284 thenable._isDisposable()) {
5285 maybePromise._setDisposable(thenable._getDisposer());
5286 }
5287 return maybePromise;
5288 }
5289 function dispose(resources, inspection) {
5290 var i = 0;
5291 var len = resources.length;
5292 var ret = new Promise(INTERNAL);
5293 function iterator() {
5294 if (i >= len) return ret._fulfill();
5295 var maybePromise = castPreservingDisposable(resources[i++]);
5296 if (maybePromise instanceof Promise &&
5297 maybePromise._isDisposable()) {
5298 try {
5299 maybePromise = tryConvertToPromise(
5300 maybePromise._getDisposer().tryDispose(inspection),
5301 resources.promise);
5302 } catch (e) {
5303 return thrower(e);
5304 }
5305 if (maybePromise instanceof Promise) {
5306 return maybePromise._then(iterator, thrower,
5307 null, null, null);
5308 }
5309 }
5310 iterator();
5311 }
5312 iterator();
5313 return ret;
5314 }
5315
5316 function Disposer(data, promise, context) {
5317 this._data = data;
5318 this._promise = promise;
5319 this._context = context;
5320 }
5321
5322 Disposer.prototype.data = function () {
5323 return this._data;
5324 };
5325
5326 Disposer.prototype.promise = function () {
5327 return this._promise;
5328 };
5329
5330 Disposer.prototype.resource = function () {
5331 if (this.promise().isFulfilled()) {
5332 return this.promise().value();
5333 }
5334 return NULL;
5335 };
5336
5337 Disposer.prototype.tryDispose = function(inspection) {
5338 var resource = this.resource();
5339 var context = this._context;
5340 if (context !== undefined) context._pushContext();
5341 var ret = resource !== NULL
5342 ? this.doDispose(resource, inspection) : null;
5343 if (context !== undefined) context._popContext();
5344 this._promise._unsetDisposable();
5345 this._data = null;
5346 return ret;
5347 };
5348
5349 Disposer.isDisposer = function (d) {
5350 return (d != null &&
5351 typeof d.resource === "function" &&
5352 typeof d.tryDispose === "function");
5353 };
5354
5355 function FunctionDisposer(fn, promise, context) {
5356 this.constructor$(fn, promise, context);
5357 }
5358 inherits(FunctionDisposer, Disposer);
5359
5360 FunctionDisposer.prototype.doDispose = function (resource, inspection) {
5361 var fn = this.data();
5362 return fn.call(resource, resource, inspection);
5363 };
5364
5365 function maybeUnwrapDisposer(value) {
5366 if (Disposer.isDisposer(value)) {
5367 this.resources[this.index]._setDisposable(value);
5368 return value.promise();
5369 }
5370 return value;
5371 }
5372
5373 function ResourceList(length) {
5374 this.length = length;
5375 this.promise = null;
5376 this[length-1] = null;
5377 }
5378
5379 ResourceList.prototype._resultCancelled = function() {
5380 var len = this.length;
5381 for (var i = 0; i < len; ++i) {
5382 var item = this[i];
5383 if (item instanceof Promise) {
5384 item.cancel();
5385 }
5386 }
5387 };
5388
5389 Promise.using = function () {
5390 var len = arguments.length;
5391 if (len < 2) return apiRejection(
5392 "you must pass at least 2 arguments to Promise.using");
5393 var fn = arguments[len - 1];
5394 if (typeof fn !== "function") {
5395 return apiRejection("expecting a function but got " + util.classString(fn));
5396 }
5397 var input;
5398 var spreadArgs = true;
5399 if (len === 2 && Array.isArray(arguments[0])) {
5400 input = arguments[0];
5401 len = input.length;
5402 spreadArgs = false;
5403 } else {
5404 input = arguments;
5405 len--;
5406 }
5407 var resources = new ResourceList(len);
5408 for (var i = 0; i < len; ++i) {
5409 var resource = input[i];
5410 if (Disposer.isDisposer(resource)) {
5411 var disposer = resource;
5412 resource = resource.promise();
5413 resource._setDisposable(disposer);
5414 } else {
5415 var maybePromise = tryConvertToPromise(resource);
5416 if (maybePromise instanceof Promise) {
5417 resource =
5418 maybePromise._then(maybeUnwrapDisposer, null, null, {
5419 resources: resources,
5420 index: i
5421 }, undefined);
5422 }
5423 }
5424 resources[i] = resource;
5425 }
5426
5427 var reflectedResources = new Array(resources.length);
5428 for (var i = 0; i < reflectedResources.length; ++i) {
5429 reflectedResources[i] = Promise.resolve(resources[i]).reflect();
5430 }
5431
5432 var resultPromise = Promise.all(reflectedResources)
5433 .then(function(inspections) {
5434 for (var i = 0; i < inspections.length; ++i) {
5435 var inspection = inspections[i];
5436 if (inspection.isRejected()) {
5437 errorObj.e = inspection.error();
5438 return errorObj;
5439 } else if (!inspection.isFulfilled()) {
5440 resultPromise.cancel();
5441 return;
5442 }
5443 inspections[i] = inspection.value();
5444 }
5445 promise._pushContext();
5446
5447 fn = tryCatch(fn);
5448 var ret = spreadArgs
5449 ? fn.apply(undefined, inspections) : fn(inspections);
5450 var promiseCreated = promise._popContext();
5451 debug.checkForgottenReturns(
5452 ret, promiseCreated, "Promise.using", promise);
5453 return ret;
5454 });
5455
5456 var promise = resultPromise.lastly(function() {
5457 var inspection = new Promise.PromiseInspection(resultPromise);
5458 return dispose(resources, inspection);
5459 });
5460 resources.promise = promise;
5461 promise._setOnCancel(resources);
5462 return promise;
5463 };
5464
5465 Promise.prototype._setDisposable = function (disposer) {
5466 this._bitField = this._bitField | 131072;
5467 this._disposer = disposer;
5468 };
5469
5470 Promise.prototype._isDisposable = function () {
5471 return (this._bitField & 131072) > 0;
5472 };
5473
5474 Promise.prototype._getDisposer = function () {
5475 return this._disposer;
5476 };
5477
5478 Promise.prototype._unsetDisposable = function () {
5479 this._bitField = this._bitField & (~131072);
5480 this._disposer = undefined;
5481 };
5482
5483 Promise.prototype.disposer = function (fn) {
5484 if (typeof fn === "function") {
5485 return new FunctionDisposer(fn, this, createContext());
5486 }
5487 throw new TypeError();
5488 };
5489
5490};
5491
5492},{"./errors":12,"./util":36}],36:[function(_dereq_,module,exports){
5493"use strict";
5494var es5 = _dereq_("./es5");
5495var canEvaluate = typeof navigator == "undefined";
5496
5497var errorObj = {e: {}};
5498var tryCatchTarget;
5499var globalObject = typeof self !== "undefined" ? self :
5500 typeof window !== "undefined" ? window :
5501 typeof global !== "undefined" ? global :
5502 this !== undefined ? this : null;
5503
5504function tryCatcher() {
5505 try {
5506 var target = tryCatchTarget;
5507 tryCatchTarget = null;
5508 return target.apply(this, arguments);
5509 } catch (e) {
5510 errorObj.e = e;
5511 return errorObj;
5512 }
5513}
5514function tryCatch(fn) {
5515 tryCatchTarget = fn;
5516 return tryCatcher;
5517}
5518
5519var inherits = function(Child, Parent) {
5520 var hasProp = {}.hasOwnProperty;
5521
5522 function T() {
5523 this.constructor = Child;
5524 this.constructor$ = Parent;
5525 for (var propertyName in Parent.prototype) {
5526 if (hasProp.call(Parent.prototype, propertyName) &&
5527 propertyName.charAt(propertyName.length-1) !== "$"
5528 ) {
5529 this[propertyName + "$"] = Parent.prototype[propertyName];
5530 }
5531 }
5532 }
5533 T.prototype = Parent.prototype;
5534 Child.prototype = new T();
5535 return Child.prototype;
5536};
5537
5538
5539function isPrimitive(val) {
5540 return val == null || val === true || val === false ||
5541 typeof val === "string" || typeof val === "number";
5542
5543}
5544
5545function isObject(value) {
5546 return typeof value === "function" ||
5547 typeof value === "object" && value !== null;
5548}
5549
5550function maybeWrapAsError(maybeError) {
5551 if (!isPrimitive(maybeError)) return maybeError;
5552
5553 return new Error(safeToString(maybeError));
5554}
5555
5556function withAppended(target, appendee) {
5557 var len = target.length;
5558 var ret = new Array(len + 1);
5559 var i;
5560 for (i = 0; i < len; ++i) {
5561 ret[i] = target[i];
5562 }
5563 ret[i] = appendee;
5564 return ret;
5565}
5566
5567function getDataPropertyOrDefault(obj, key, defaultValue) {
5568 if (es5.isES5) {
5569 var desc = Object.getOwnPropertyDescriptor(obj, key);
5570
5571 if (desc != null) {
5572 return desc.get == null && desc.set == null
5573 ? desc.value
5574 : defaultValue;
5575 }
5576 } else {
5577 return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
5578 }
5579}
5580
5581function notEnumerableProp(obj, name, value) {
5582 if (isPrimitive(obj)) return obj;
5583 var descriptor = {
5584 value: value,
5585 configurable: true,
5586 enumerable: false,
5587 writable: true
5588 };
5589 es5.defineProperty(obj, name, descriptor);
5590 return obj;
5591}
5592
5593function thrower(r) {
5594 throw r;
5595}
5596
5597var inheritedDataKeys = (function() {
5598 var excludedPrototypes = [
5599 Array.prototype,
5600 Object.prototype,
5601 Function.prototype
5602 ];
5603
5604 var isExcludedProto = function(val) {
5605 for (var i = 0; i < excludedPrototypes.length; ++i) {
5606 if (excludedPrototypes[i] === val) {
5607 return true;
5608 }
5609 }
5610 return false;
5611 };
5612
5613 if (es5.isES5) {
5614 var getKeys = Object.getOwnPropertyNames;
5615 return function(obj) {
5616 var ret = [];
5617 var visitedKeys = Object.create(null);
5618 while (obj != null && !isExcludedProto(obj)) {
5619 var keys;
5620 try {
5621 keys = getKeys(obj);
5622 } catch (e) {
5623 return ret;
5624 }
5625 for (var i = 0; i < keys.length; ++i) {
5626 var key = keys[i];
5627 if (visitedKeys[key]) continue;
5628 visitedKeys[key] = true;
5629 var desc = Object.getOwnPropertyDescriptor(obj, key);
5630 if (desc != null && desc.get == null && desc.set == null) {
5631 ret.push(key);
5632 }
5633 }
5634 obj = es5.getPrototypeOf(obj);
5635 }
5636 return ret;
5637 };
5638 } else {
5639 var hasProp = {}.hasOwnProperty;
5640 return function(obj) {
5641 if (isExcludedProto(obj)) return [];
5642 var ret = [];
5643
5644 /*jshint forin:false */
5645 enumeration: for (var key in obj) {
5646 if (hasProp.call(obj, key)) {
5647 ret.push(key);
5648 } else {
5649 for (var i = 0; i < excludedPrototypes.length; ++i) {
5650 if (hasProp.call(excludedPrototypes[i], key)) {
5651 continue enumeration;
5652 }
5653 }
5654 ret.push(key);
5655 }
5656 }
5657 return ret;
5658 };
5659 }
5660
5661})();
5662
5663var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
5664function isClass(fn) {
5665 try {
5666 if (typeof fn === "function") {
5667 var keys = es5.names(fn.prototype);
5668
5669 var hasMethods = es5.isES5 && keys.length > 1;
5670 var hasMethodsOtherThanConstructor = keys.length > 0 &&
5671 !(keys.length === 1 && keys[0] === "constructor");
5672 var hasThisAssignmentAndStaticMethods =
5673 thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
5674
5675 if (hasMethods || hasMethodsOtherThanConstructor ||
5676 hasThisAssignmentAndStaticMethods) {
5677 return true;
5678 }
5679 }
5680 return false;
5681 } catch (e) {
5682 return false;
5683 }
5684}
5685
5686function toFastProperties(obj) {
5687 /*jshint -W027,-W055,-W031*/
5688 function FakeConstructor() {}
5689 FakeConstructor.prototype = obj;
5690 var l = 8;
5691 while (l--) new FakeConstructor();
5692 return obj;
5693 eval(obj);
5694}
5695
5696var rident = /^[a-z$_][a-z$_0-9]*$/i;
5697function isIdentifier(str) {
5698 return rident.test(str);
5699}
5700
5701function filledRange(count, prefix, suffix) {
5702 var ret = new Array(count);
5703 for(var i = 0; i < count; ++i) {
5704 ret[i] = prefix + i + suffix;
5705 }
5706 return ret;
5707}
5708
5709function safeToString(obj) {
5710 try {
5711 return obj + "";
5712 } catch (e) {
5713 return "[no string representation]";
5714 }
5715}
5716
5717function isError(obj) {
5718 return obj !== null &&
5719 typeof obj === "object" &&
5720 typeof obj.message === "string" &&
5721 typeof obj.name === "string";
5722}
5723
5724function markAsOriginatingFromRejection(e) {
5725 try {
5726 notEnumerableProp(e, "isOperational", true);
5727 }
5728 catch(ignore) {}
5729}
5730
5731function originatesFromRejection(e) {
5732 if (e == null) return false;
5733 return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
5734 e["isOperational"] === true);
5735}
5736
5737function canAttachTrace(obj) {
5738 return isError(obj) && es5.propertyIsWritable(obj, "stack");
5739}
5740
5741var ensureErrorObject = (function() {
5742 if (!("stack" in new Error())) {
5743 return function(value) {
5744 if (canAttachTrace(value)) return value;
5745 try {throw new Error(safeToString(value));}
5746 catch(err) {return err;}
5747 };
5748 } else {
5749 return function(value) {
5750 if (canAttachTrace(value)) return value;
5751 return new Error(safeToString(value));
5752 };
5753 }
5754})();
5755
5756function classString(obj) {
5757 return {}.toString.call(obj);
5758}
5759
5760function copyDescriptors(from, to, filter) {
5761 var keys = es5.names(from);
5762 for (var i = 0; i < keys.length; ++i) {
5763 var key = keys[i];
5764 if (filter(key)) {
5765 try {
5766 es5.defineProperty(to, key, es5.getDescriptor(from, key));
5767 } catch (ignore) {}
5768 }
5769 }
5770}
5771
5772var asArray = function(v) {
5773 if (es5.isArray(v)) {
5774 return v;
5775 }
5776 return null;
5777};
5778
5779if (typeof Symbol !== "undefined" && Symbol.iterator) {
5780 var ArrayFrom = typeof Array.from === "function" ? function(v) {
5781 return Array.from(v);
5782 } : function(v) {
5783 var ret = [];
5784 var it = v[Symbol.iterator]();
5785 var itResult;
5786 while (!((itResult = it.next()).done)) {
5787 ret.push(itResult.value);
5788 }
5789 return ret;
5790 };
5791
5792 asArray = function(v) {
5793 if (es5.isArray(v)) {
5794 return v;
5795 } else if (v != null && typeof v[Symbol.iterator] === "function") {
5796 return ArrayFrom(v);
5797 }
5798 return null;
5799 };
5800}
5801
5802var isNode = typeof process !== "undefined" &&
5803 classString(process).toLowerCase() === "[object process]";
5804
5805var hasEnvVariables = typeof process !== "undefined" &&
5806 typeof process.env !== "undefined";
5807
5808function env(key) {
5809 return hasEnvVariables ? process.env[key] : undefined;
5810}
5811
5812function getNativePromise() {
5813 if (typeof Promise === "function") {
5814 try {
5815 var promise = new Promise(function(){});
5816 if ({}.toString.call(promise) === "[object Promise]") {
5817 return Promise;
5818 }
5819 } catch (e) {}
5820 }
5821}
5822
5823function domainBind(self, cb) {
5824 return self.bind(cb);
5825}
5826
5827var ret = {
5828 isClass: isClass,
5829 isIdentifier: isIdentifier,
5830 inheritedDataKeys: inheritedDataKeys,
5831 getDataPropertyOrDefault: getDataPropertyOrDefault,
5832 thrower: thrower,
5833 isArray: es5.isArray,
5834 asArray: asArray,
5835 notEnumerableProp: notEnumerableProp,
5836 isPrimitive: isPrimitive,
5837 isObject: isObject,
5838 isError: isError,
5839 canEvaluate: canEvaluate,
5840 errorObj: errorObj,
5841 tryCatch: tryCatch,
5842 inherits: inherits,
5843 withAppended: withAppended,
5844 maybeWrapAsError: maybeWrapAsError,
5845 toFastProperties: toFastProperties,
5846 filledRange: filledRange,
5847 toString: safeToString,
5848 canAttachTrace: canAttachTrace,
5849 ensureErrorObject: ensureErrorObject,
5850 originatesFromRejection: originatesFromRejection,
5851 markAsOriginatingFromRejection: markAsOriginatingFromRejection,
5852 classString: classString,
5853 copyDescriptors: copyDescriptors,
5854 hasDevTools: typeof chrome !== "undefined" && chrome &&
5855 typeof chrome.loadTimes === "function",
5856 isNode: isNode,
5857 hasEnvVariables: hasEnvVariables,
5858 env: env,
5859 global: globalObject,
5860 getNativePromise: getNativePromise,
5861 domainBind: domainBind
5862};
5863ret.isRecentNode = ret.isNode && (function() {
5864 var version = process.versions.node.split(".").map(Number);
5865 return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
5866})();
5867
5868if (ret.isNode) ret.toFastProperties(process);
5869
5870try {throw new Error(); } catch (e) {ret.lastLineError = e;}
5871module.exports = ret;
5872
5873},{"./es5":13}]},{},[4])(4)
5874}); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; }
5875}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
5876},{"_process":146}],3:[function(require,module,exports){
5877var getNative = require('./_getNative'),
5878 root = require('./_root');
5879
5880/* Built-in method references that are verified to be native. */
5881var DataView = getNative(root, 'DataView');
5882
5883module.exports = DataView;
5884
5885},{"./_getNative":66,"./_root":103}],4:[function(require,module,exports){
5886var hashClear = require('./_hashClear'),
5887 hashDelete = require('./_hashDelete'),
5888 hashGet = require('./_hashGet'),
5889 hashHas = require('./_hashHas'),
5890 hashSet = require('./_hashSet');
5891
5892/**
5893 * Creates a hash object.
5894 *
5895 * @private
5896 * @constructor
5897 * @param {Array} [entries] The key-value pairs to cache.
5898 */
5899function Hash(entries) {
5900 var index = -1,
5901 length = entries == null ? 0 : entries.length;
5902
5903 this.clear();
5904 while (++index < length) {
5905 var entry = entries[index];
5906 this.set(entry[0], entry[1]);
5907 }
5908}
5909
5910// Add methods to `Hash`.
5911Hash.prototype.clear = hashClear;
5912Hash.prototype['delete'] = hashDelete;
5913Hash.prototype.get = hashGet;
5914Hash.prototype.has = hashHas;
5915Hash.prototype.set = hashSet;
5916
5917module.exports = Hash;
5918
5919},{"./_hashClear":72,"./_hashDelete":73,"./_hashGet":74,"./_hashHas":75,"./_hashSet":76}],5:[function(require,module,exports){
5920var listCacheClear = require('./_listCacheClear'),
5921 listCacheDelete = require('./_listCacheDelete'),
5922 listCacheGet = require('./_listCacheGet'),
5923 listCacheHas = require('./_listCacheHas'),
5924 listCacheSet = require('./_listCacheSet');
5925
5926/**
5927 * Creates an list cache object.
5928 *
5929 * @private
5930 * @constructor
5931 * @param {Array} [entries] The key-value pairs to cache.
5932 */
5933function ListCache(entries) {
5934 var index = -1,
5935 length = entries == null ? 0 : entries.length;
5936
5937 this.clear();
5938 while (++index < length) {
5939 var entry = entries[index];
5940 this.set(entry[0], entry[1]);
5941 }
5942}
5943
5944// Add methods to `ListCache`.
5945ListCache.prototype.clear = listCacheClear;
5946ListCache.prototype['delete'] = listCacheDelete;
5947ListCache.prototype.get = listCacheGet;
5948ListCache.prototype.has = listCacheHas;
5949ListCache.prototype.set = listCacheSet;
5950
5951module.exports = ListCache;
5952
5953},{"./_listCacheClear":84,"./_listCacheDelete":85,"./_listCacheGet":86,"./_listCacheHas":87,"./_listCacheSet":88}],6:[function(require,module,exports){
5954var getNative = require('./_getNative'),
5955 root = require('./_root');
5956
5957/* Built-in method references that are verified to be native. */
5958var Map = getNative(root, 'Map');
5959
5960module.exports = Map;
5961
5962},{"./_getNative":66,"./_root":103}],7:[function(require,module,exports){
5963var mapCacheClear = require('./_mapCacheClear'),
5964 mapCacheDelete = require('./_mapCacheDelete'),
5965 mapCacheGet = require('./_mapCacheGet'),
5966 mapCacheHas = require('./_mapCacheHas'),
5967 mapCacheSet = require('./_mapCacheSet');
5968
5969/**
5970 * Creates a map cache object to store key-value pairs.
5971 *
5972 * @private
5973 * @constructor
5974 * @param {Array} [entries] The key-value pairs to cache.
5975 */
5976function MapCache(entries) {
5977 var index = -1,
5978 length = entries == null ? 0 : entries.length;
5979
5980 this.clear();
5981 while (++index < length) {
5982 var entry = entries[index];
5983 this.set(entry[0], entry[1]);
5984 }
5985}
5986
5987// Add methods to `MapCache`.
5988MapCache.prototype.clear = mapCacheClear;
5989MapCache.prototype['delete'] = mapCacheDelete;
5990MapCache.prototype.get = mapCacheGet;
5991MapCache.prototype.has = mapCacheHas;
5992MapCache.prototype.set = mapCacheSet;
5993
5994module.exports = MapCache;
5995
5996},{"./_mapCacheClear":89,"./_mapCacheDelete":90,"./_mapCacheGet":91,"./_mapCacheHas":92,"./_mapCacheSet":93}],8:[function(require,module,exports){
5997var getNative = require('./_getNative'),
5998 root = require('./_root');
5999
6000/* Built-in method references that are verified to be native. */
6001var Promise = getNative(root, 'Promise');
6002
6003module.exports = Promise;
6004
6005},{"./_getNative":66,"./_root":103}],9:[function(require,module,exports){
6006var getNative = require('./_getNative'),
6007 root = require('./_root');
6008
6009/* Built-in method references that are verified to be native. */
6010var Set = getNative(root, 'Set');
6011
6012module.exports = Set;
6013
6014},{"./_getNative":66,"./_root":103}],10:[function(require,module,exports){
6015var MapCache = require('./_MapCache'),
6016 setCacheAdd = require('./_setCacheAdd'),
6017 setCacheHas = require('./_setCacheHas');
6018
6019/**
6020 *
6021 * Creates an array cache object to store unique values.
6022 *
6023 * @private
6024 * @constructor
6025 * @param {Array} [values] The values to cache.
6026 */
6027function SetCache(values) {
6028 var index = -1,
6029 length = values == null ? 0 : values.length;
6030
6031 this.__data__ = new MapCache;
6032 while (++index < length) {
6033 this.add(values[index]);
6034 }
6035}
6036
6037// Add methods to `SetCache`.
6038SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
6039SetCache.prototype.has = setCacheHas;
6040
6041module.exports = SetCache;
6042
6043},{"./_MapCache":7,"./_setCacheAdd":104,"./_setCacheHas":105}],11:[function(require,module,exports){
6044var ListCache = require('./_ListCache'),
6045 stackClear = require('./_stackClear'),
6046 stackDelete = require('./_stackDelete'),
6047 stackGet = require('./_stackGet'),
6048 stackHas = require('./_stackHas'),
6049 stackSet = require('./_stackSet');
6050
6051/**
6052 * Creates a stack cache object to store key-value pairs.
6053 *
6054 * @private
6055 * @constructor
6056 * @param {Array} [entries] The key-value pairs to cache.
6057 */
6058function Stack(entries) {
6059 var data = this.__data__ = new ListCache(entries);
6060 this.size = data.size;
6061}
6062
6063// Add methods to `Stack`.
6064Stack.prototype.clear = stackClear;
6065Stack.prototype['delete'] = stackDelete;
6066Stack.prototype.get = stackGet;
6067Stack.prototype.has = stackHas;
6068Stack.prototype.set = stackSet;
6069
6070module.exports = Stack;
6071
6072},{"./_ListCache":5,"./_stackClear":109,"./_stackDelete":110,"./_stackGet":111,"./_stackHas":112,"./_stackSet":113}],12:[function(require,module,exports){
6073var root = require('./_root');
6074
6075/** Built-in value references. */
6076var Symbol = root.Symbol;
6077
6078module.exports = Symbol;
6079
6080},{"./_root":103}],13:[function(require,module,exports){
6081var root = require('./_root');
6082
6083/** Built-in value references. */
6084var Uint8Array = root.Uint8Array;
6085
6086module.exports = Uint8Array;
6087
6088},{"./_root":103}],14:[function(require,module,exports){
6089var getNative = require('./_getNative'),
6090 root = require('./_root');
6091
6092/* Built-in method references that are verified to be native. */
6093var WeakMap = getNative(root, 'WeakMap');
6094
6095module.exports = WeakMap;
6096
6097},{"./_getNative":66,"./_root":103}],15:[function(require,module,exports){
6098/**
6099 * A faster alternative to `Function#apply`, this function invokes `func`
6100 * with the `this` binding of `thisArg` and the arguments of `args`.
6101 *
6102 * @private
6103 * @param {Function} func The function to invoke.
6104 * @param {*} thisArg The `this` binding of `func`.
6105 * @param {Array} args The arguments to invoke `func` with.
6106 * @returns {*} Returns the result of `func`.
6107 */
6108function apply(func, thisArg, args) {
6109 switch (args.length) {
6110 case 0: return func.call(thisArg);
6111 case 1: return func.call(thisArg, args[0]);
6112 case 2: return func.call(thisArg, args[0], args[1]);
6113 case 3: return func.call(thisArg, args[0], args[1], args[2]);
6114 }
6115 return func.apply(thisArg, args);
6116}
6117
6118module.exports = apply;
6119
6120},{}],16:[function(require,module,exports){
6121/**
6122 * A specialized version of `_.filter` for arrays without support for
6123 * iteratee shorthands.
6124 *
6125 * @private
6126 * @param {Array} [array] The array to iterate over.
6127 * @param {Function} predicate The function invoked per iteration.
6128 * @returns {Array} Returns the new filtered array.
6129 */
6130function arrayFilter(array, predicate) {
6131 var index = -1,
6132 length = array == null ? 0 : array.length,
6133 resIndex = 0,
6134 result = [];
6135
6136 while (++index < length) {
6137 var value = array[index];
6138 if (predicate(value, index, array)) {
6139 result[resIndex++] = value;
6140 }
6141 }
6142 return result;
6143}
6144
6145module.exports = arrayFilter;
6146
6147},{}],17:[function(require,module,exports){
6148var baseTimes = require('./_baseTimes'),
6149 isArguments = require('./isArguments'),
6150 isArray = require('./isArray'),
6151 isBuffer = require('./isBuffer'),
6152 isIndex = require('./_isIndex'),
6153 isTypedArray = require('./isTypedArray');
6154
6155/** Used for built-in method references. */
6156var objectProto = Object.prototype;
6157
6158/** Used to check objects for own properties. */
6159var hasOwnProperty = objectProto.hasOwnProperty;
6160
6161/**
6162 * Creates an array of the enumerable property names of the array-like `value`.
6163 *
6164 * @private
6165 * @param {*} value The value to query.
6166 * @param {boolean} inherited Specify returning inherited property names.
6167 * @returns {Array} Returns the array of property names.
6168 */
6169function arrayLikeKeys(value, inherited) {
6170 var isArr = isArray(value),
6171 isArg = !isArr && isArguments(value),
6172 isBuff = !isArr && !isArg && isBuffer(value),
6173 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
6174 skipIndexes = isArr || isArg || isBuff || isType,
6175 result = skipIndexes ? baseTimes(value.length, String) : [],
6176 length = result.length;
6177
6178 for (var key in value) {
6179 if ((inherited || hasOwnProperty.call(value, key)) &&
6180 !(skipIndexes && (
6181 // Safari 9 has enumerable `arguments.length` in strict mode.
6182 key == 'length' ||
6183 // Node.js 0.10 has enumerable non-index properties on buffers.
6184 (isBuff && (key == 'offset' || key == 'parent')) ||
6185 // PhantomJS 2 has enumerable non-index properties on typed arrays.
6186 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
6187 // Skip index properties.
6188 isIndex(key, length)
6189 ))) {
6190 result.push(key);
6191 }
6192 }
6193 return result;
6194}
6195
6196module.exports = arrayLikeKeys;
6197
6198},{"./_baseTimes":49,"./_isIndex":78,"./isArguments":124,"./isArray":125,"./isBuffer":127,"./isTypedArray":133}],18:[function(require,module,exports){
6199/**
6200 * A specialized version of `_.map` for arrays without support for iteratee
6201 * shorthands.
6202 *
6203 * @private
6204 * @param {Array} [array] The array to iterate over.
6205 * @param {Function} iteratee The function invoked per iteration.
6206 * @returns {Array} Returns the new mapped array.
6207 */
6208function arrayMap(array, iteratee) {
6209 var index = -1,
6210 length = array == null ? 0 : array.length,
6211 result = Array(length);
6212
6213 while (++index < length) {
6214 result[index] = iteratee(array[index], index, array);
6215 }
6216 return result;
6217}
6218
6219module.exports = arrayMap;
6220
6221},{}],19:[function(require,module,exports){
6222/**
6223 * Appends the elements of `values` to `array`.
6224 *
6225 * @private
6226 * @param {Array} array The array to modify.
6227 * @param {Array} values The values to append.
6228 * @returns {Array} Returns `array`.
6229 */
6230function arrayPush(array, values) {
6231 var index = -1,
6232 length = values.length,
6233 offset = array.length;
6234
6235 while (++index < length) {
6236 array[offset + index] = values[index];
6237 }
6238 return array;
6239}
6240
6241module.exports = arrayPush;
6242
6243},{}],20:[function(require,module,exports){
6244/**
6245 * A specialized version of `_.some` for arrays without support for iteratee
6246 * shorthands.
6247 *
6248 * @private
6249 * @param {Array} [array] The array to iterate over.
6250 * @param {Function} predicate The function invoked per iteration.
6251 * @returns {boolean} Returns `true` if any element passes the predicate check,
6252 * else `false`.
6253 */
6254function arraySome(array, predicate) {
6255 var index = -1,
6256 length = array == null ? 0 : array.length;
6257
6258 while (++index < length) {
6259 if (predicate(array[index], index, array)) {
6260 return true;
6261 }
6262 }
6263 return false;
6264}
6265
6266module.exports = arraySome;
6267
6268},{}],21:[function(require,module,exports){
6269var baseAssignValue = require('./_baseAssignValue'),
6270 eq = require('./eq');
6271
6272/** Used for built-in method references. */
6273var objectProto = Object.prototype;
6274
6275/** Used to check objects for own properties. */
6276var hasOwnProperty = objectProto.hasOwnProperty;
6277
6278/**
6279 * Assigns `value` to `key` of `object` if the existing value is not equivalent
6280 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
6281 * for equality comparisons.
6282 *
6283 * @private
6284 * @param {Object} object The object to modify.
6285 * @param {string} key The key of the property to assign.
6286 * @param {*} value The value to assign.
6287 */
6288function assignValue(object, key, value) {
6289 var objValue = object[key];
6290 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
6291 (value === undefined && !(key in object))) {
6292 baseAssignValue(object, key, value);
6293 }
6294}
6295
6296module.exports = assignValue;
6297
6298},{"./_baseAssignValue":23,"./eq":119}],22:[function(require,module,exports){
6299var eq = require('./eq');
6300
6301/**
6302 * Gets the index at which the `key` is found in `array` of key-value pairs.
6303 *
6304 * @private
6305 * @param {Array} array The array to inspect.
6306 * @param {*} key The key to search for.
6307 * @returns {number} Returns the index of the matched value, else `-1`.
6308 */
6309function assocIndexOf(array, key) {
6310 var length = array.length;
6311 while (length--) {
6312 if (eq(array[length][0], key)) {
6313 return length;
6314 }
6315 }
6316 return -1;
6317}
6318
6319module.exports = assocIndexOf;
6320
6321},{"./eq":119}],23:[function(require,module,exports){
6322var defineProperty = require('./_defineProperty');
6323
6324/**
6325 * The base implementation of `assignValue` and `assignMergeValue` without
6326 * value checks.
6327 *
6328 * @private
6329 * @param {Object} object The object to modify.
6330 * @param {string} key The key of the property to assign.
6331 * @param {*} value The value to assign.
6332 */
6333function baseAssignValue(object, key, value) {
6334 if (key == '__proto__' && defineProperty) {
6335 defineProperty(object, key, {
6336 'configurable': true,
6337 'enumerable': true,
6338 'value': value,
6339 'writable': true
6340 });
6341 } else {
6342 object[key] = value;
6343 }
6344}
6345
6346module.exports = baseAssignValue;
6347
6348},{"./_defineProperty":57}],24:[function(require,module,exports){
6349var baseForOwn = require('./_baseForOwn'),
6350 createBaseEach = require('./_createBaseEach');
6351
6352/**
6353 * The base implementation of `_.forEach` without support for iteratee shorthands.
6354 *
6355 * @private
6356 * @param {Array|Object} collection The collection to iterate over.
6357 * @param {Function} iteratee The function invoked per iteration.
6358 * @returns {Array|Object} Returns `collection`.
6359 */
6360var baseEach = createBaseEach(baseForOwn);
6361
6362module.exports = baseEach;
6363
6364},{"./_baseForOwn":27,"./_createBaseEach":55}],25:[function(require,module,exports){
6365var arrayPush = require('./_arrayPush'),
6366 isFlattenable = require('./_isFlattenable');
6367
6368/**
6369 * The base implementation of `_.flatten` with support for restricting flattening.
6370 *
6371 * @private
6372 * @param {Array} array The array to flatten.
6373 * @param {number} depth The maximum recursion depth.
6374 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
6375 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
6376 * @param {Array} [result=[]] The initial result value.
6377 * @returns {Array} Returns the new flattened array.
6378 */
6379function baseFlatten(array, depth, predicate, isStrict, result) {
6380 var index = -1,
6381 length = array.length;
6382
6383 predicate || (predicate = isFlattenable);
6384 result || (result = []);
6385
6386 while (++index < length) {
6387 var value = array[index];
6388 if (depth > 0 && predicate(value)) {
6389 if (depth > 1) {
6390 // Recursively flatten arrays (susceptible to call stack limits).
6391 baseFlatten(value, depth - 1, predicate, isStrict, result);
6392 } else {
6393 arrayPush(result, value);
6394 }
6395 } else if (!isStrict) {
6396 result[result.length] = value;
6397 }
6398 }
6399 return result;
6400}
6401
6402module.exports = baseFlatten;
6403
6404},{"./_arrayPush":19,"./_isFlattenable":77}],26:[function(require,module,exports){
6405var createBaseFor = require('./_createBaseFor');
6406
6407/**
6408 * The base implementation of `baseForOwn` which iterates over `object`
6409 * properties returned by `keysFunc` and invokes `iteratee` for each property.
6410 * Iteratee functions may exit iteration early by explicitly returning `false`.
6411 *
6412 * @private
6413 * @param {Object} object The object to iterate over.
6414 * @param {Function} iteratee The function invoked per iteration.
6415 * @param {Function} keysFunc The function to get the keys of `object`.
6416 * @returns {Object} Returns `object`.
6417 */
6418var baseFor = createBaseFor();
6419
6420module.exports = baseFor;
6421
6422},{"./_createBaseFor":56}],27:[function(require,module,exports){
6423var baseFor = require('./_baseFor'),
6424 keys = require('./keys');
6425
6426/**
6427 * The base implementation of `_.forOwn` without support for iteratee shorthands.
6428 *
6429 * @private
6430 * @param {Object} object The object to iterate over.
6431 * @param {Function} iteratee The function invoked per iteration.
6432 * @returns {Object} Returns `object`.
6433 */
6434function baseForOwn(object, iteratee) {
6435 return object && baseFor(object, iteratee, keys);
6436}
6437
6438module.exports = baseForOwn;
6439
6440},{"./_baseFor":26,"./keys":134}],28:[function(require,module,exports){
6441var castPath = require('./_castPath'),
6442 toKey = require('./_toKey');
6443
6444/**
6445 * The base implementation of `_.get` without support for default values.
6446 *
6447 * @private
6448 * @param {Object} object The object to query.
6449 * @param {Array|string} path The path of the property to get.
6450 * @returns {*} Returns the resolved value.
6451 */
6452function baseGet(object, path) {
6453 path = castPath(path, object);
6454
6455 var index = 0,
6456 length = path.length;
6457
6458 while (object != null && index < length) {
6459 object = object[toKey(path[index++])];
6460 }
6461 return (index && index == length) ? object : undefined;
6462}
6463
6464module.exports = baseGet;
6465
6466},{"./_castPath":53,"./_toKey":115}],29:[function(require,module,exports){
6467var arrayPush = require('./_arrayPush'),
6468 isArray = require('./isArray');
6469
6470/**
6471 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
6472 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
6473 * symbols of `object`.
6474 *
6475 * @private
6476 * @param {Object} object The object to query.
6477 * @param {Function} keysFunc The function to get the keys of `object`.
6478 * @param {Function} symbolsFunc The function to get the symbols of `object`.
6479 * @returns {Array} Returns the array of property names and symbols.
6480 */
6481function baseGetAllKeys(object, keysFunc, symbolsFunc) {
6482 var result = keysFunc(object);
6483 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
6484}
6485
6486module.exports = baseGetAllKeys;
6487
6488},{"./_arrayPush":19,"./isArray":125}],30:[function(require,module,exports){
6489var Symbol = require('./_Symbol'),
6490 getRawTag = require('./_getRawTag'),
6491 objectToString = require('./_objectToString');
6492
6493/** `Object#toString` result references. */
6494var nullTag = '[object Null]',
6495 undefinedTag = '[object Undefined]';
6496
6497/** Built-in value references. */
6498var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
6499
6500/**
6501 * The base implementation of `getTag` without fallbacks for buggy environments.
6502 *
6503 * @private
6504 * @param {*} value The value to query.
6505 * @returns {string} Returns the `toStringTag`.
6506 */
6507function baseGetTag(value) {
6508 if (value == null) {
6509 return value === undefined ? undefinedTag : nullTag;
6510 }
6511 return (symToStringTag && symToStringTag in Object(value))
6512 ? getRawTag(value)
6513 : objectToString(value);
6514}
6515
6516module.exports = baseGetTag;
6517
6518},{"./_Symbol":12,"./_getRawTag":67,"./_objectToString":100}],31:[function(require,module,exports){
6519/**
6520 * The base implementation of `_.hasIn` without support for deep paths.
6521 *
6522 * @private
6523 * @param {Object} [object] The object to query.
6524 * @param {Array|string} key The key to check.
6525 * @returns {boolean} Returns `true` if `key` exists, else `false`.
6526 */
6527function baseHasIn(object, key) {
6528 return object != null && key in Object(object);
6529}
6530
6531module.exports = baseHasIn;
6532
6533},{}],32:[function(require,module,exports){
6534var baseGetTag = require('./_baseGetTag'),
6535 isObjectLike = require('./isObjectLike');
6536
6537/** `Object#toString` result references. */
6538var argsTag = '[object Arguments]';
6539
6540/**
6541 * The base implementation of `_.isArguments`.
6542 *
6543 * @private
6544 * @param {*} value The value to check.
6545 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
6546 */
6547function baseIsArguments(value) {
6548 return isObjectLike(value) && baseGetTag(value) == argsTag;
6549}
6550
6551module.exports = baseIsArguments;
6552
6553},{"./_baseGetTag":30,"./isObjectLike":131}],33:[function(require,module,exports){
6554var baseIsEqualDeep = require('./_baseIsEqualDeep'),
6555 isObjectLike = require('./isObjectLike');
6556
6557/**
6558 * The base implementation of `_.isEqual` which supports partial comparisons
6559 * and tracks traversed objects.
6560 *
6561 * @private
6562 * @param {*} value The value to compare.
6563 * @param {*} other The other value to compare.
6564 * @param {boolean} bitmask The bitmask flags.
6565 * 1 - Unordered comparison
6566 * 2 - Partial comparison
6567 * @param {Function} [customizer] The function to customize comparisons.
6568 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
6569 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
6570 */
6571function baseIsEqual(value, other, bitmask, customizer, stack) {
6572 if (value === other) {
6573 return true;
6574 }
6575 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
6576 return value !== value && other !== other;
6577 }
6578 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
6579}
6580
6581module.exports = baseIsEqual;
6582
6583},{"./_baseIsEqualDeep":34,"./isObjectLike":131}],34:[function(require,module,exports){
6584var Stack = require('./_Stack'),
6585 equalArrays = require('./_equalArrays'),
6586 equalByTag = require('./_equalByTag'),
6587 equalObjects = require('./_equalObjects'),
6588 getTag = require('./_getTag'),
6589 isArray = require('./isArray'),
6590 isBuffer = require('./isBuffer'),
6591 isTypedArray = require('./isTypedArray');
6592
6593/** Used to compose bitmasks for value comparisons. */
6594var COMPARE_PARTIAL_FLAG = 1;
6595
6596/** `Object#toString` result references. */
6597var argsTag = '[object Arguments]',
6598 arrayTag = '[object Array]',
6599 objectTag = '[object Object]';
6600
6601/** Used for built-in method references. */
6602var objectProto = Object.prototype;
6603
6604/** Used to check objects for own properties. */
6605var hasOwnProperty = objectProto.hasOwnProperty;
6606
6607/**
6608 * A specialized version of `baseIsEqual` for arrays and objects which performs
6609 * deep comparisons and tracks traversed objects enabling objects with circular
6610 * references to be compared.
6611 *
6612 * @private
6613 * @param {Object} object The object to compare.
6614 * @param {Object} other The other object to compare.
6615 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
6616 * @param {Function} customizer The function to customize comparisons.
6617 * @param {Function} equalFunc The function to determine equivalents of values.
6618 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
6619 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
6620 */
6621function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
6622 var objIsArr = isArray(object),
6623 othIsArr = isArray(other),
6624 objTag = objIsArr ? arrayTag : getTag(object),
6625 othTag = othIsArr ? arrayTag : getTag(other);
6626
6627 objTag = objTag == argsTag ? objectTag : objTag;
6628 othTag = othTag == argsTag ? objectTag : othTag;
6629
6630 var objIsObj = objTag == objectTag,
6631 othIsObj = othTag == objectTag,
6632 isSameTag = objTag == othTag;
6633
6634 if (isSameTag && isBuffer(object)) {
6635 if (!isBuffer(other)) {
6636 return false;
6637 }
6638 objIsArr = true;
6639 objIsObj = false;
6640 }
6641 if (isSameTag && !objIsObj) {
6642 stack || (stack = new Stack);
6643 return (objIsArr || isTypedArray(object))
6644 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
6645 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
6646 }
6647 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
6648 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
6649 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
6650
6651 if (objIsWrapped || othIsWrapped) {
6652 var objUnwrapped = objIsWrapped ? object.value() : object,
6653 othUnwrapped = othIsWrapped ? other.value() : other;
6654
6655 stack || (stack = new Stack);
6656 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
6657 }
6658 }
6659 if (!isSameTag) {
6660 return false;
6661 }
6662 stack || (stack = new Stack);
6663 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
6664}
6665
6666module.exports = baseIsEqualDeep;
6667
6668},{"./_Stack":11,"./_equalArrays":58,"./_equalByTag":59,"./_equalObjects":60,"./_getTag":69,"./isArray":125,"./isBuffer":127,"./isTypedArray":133}],35:[function(require,module,exports){
6669var Stack = require('./_Stack'),
6670 baseIsEqual = require('./_baseIsEqual');
6671
6672/** Used to compose bitmasks for value comparisons. */
6673var COMPARE_PARTIAL_FLAG = 1,
6674 COMPARE_UNORDERED_FLAG = 2;
6675
6676/**
6677 * The base implementation of `_.isMatch` without support for iteratee shorthands.
6678 *
6679 * @private
6680 * @param {Object} object The object to inspect.
6681 * @param {Object} source The object of property values to match.
6682 * @param {Array} matchData The property names, values, and compare flags to match.
6683 * @param {Function} [customizer] The function to customize comparisons.
6684 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
6685 */
6686function baseIsMatch(object, source, matchData, customizer) {
6687 var index = matchData.length,
6688 length = index,
6689 noCustomizer = !customizer;
6690
6691 if (object == null) {
6692 return !length;
6693 }
6694 object = Object(object);
6695 while (index--) {
6696 var data = matchData[index];
6697 if ((noCustomizer && data[2])
6698 ? data[1] !== object[data[0]]
6699 : !(data[0] in object)
6700 ) {
6701 return false;
6702 }
6703 }
6704 while (++index < length) {
6705 data = matchData[index];
6706 var key = data[0],
6707 objValue = object[key],
6708 srcValue = data[1];
6709
6710 if (noCustomizer && data[2]) {
6711 if (objValue === undefined && !(key in object)) {
6712 return false;
6713 }
6714 } else {
6715 var stack = new Stack;
6716 if (customizer) {
6717 var result = customizer(objValue, srcValue, key, object, source, stack);
6718 }
6719 if (!(result === undefined
6720 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
6721 : result
6722 )) {
6723 return false;
6724 }
6725 }
6726 }
6727 return true;
6728}
6729
6730module.exports = baseIsMatch;
6731
6732},{"./_Stack":11,"./_baseIsEqual":33}],36:[function(require,module,exports){
6733var isFunction = require('./isFunction'),
6734 isMasked = require('./_isMasked'),
6735 isObject = require('./isObject'),
6736 toSource = require('./_toSource');
6737
6738/**
6739 * Used to match `RegExp`
6740 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
6741 */
6742var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
6743
6744/** Used to detect host constructors (Safari). */
6745var reIsHostCtor = /^\[object .+?Constructor\]$/;
6746
6747/** Used for built-in method references. */
6748var funcProto = Function.prototype,
6749 objectProto = Object.prototype;
6750
6751/** Used to resolve the decompiled source of functions. */
6752var funcToString = funcProto.toString;
6753
6754/** Used to check objects for own properties. */
6755var hasOwnProperty = objectProto.hasOwnProperty;
6756
6757/** Used to detect if a method is native. */
6758var reIsNative = RegExp('^' +
6759 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
6760 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
6761);
6762
6763/**
6764 * The base implementation of `_.isNative` without bad shim checks.
6765 *
6766 * @private
6767 * @param {*} value The value to check.
6768 * @returns {boolean} Returns `true` if `value` is a native function,
6769 * else `false`.
6770 */
6771function baseIsNative(value) {
6772 if (!isObject(value) || isMasked(value)) {
6773 return false;
6774 }
6775 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
6776 return pattern.test(toSource(value));
6777}
6778
6779module.exports = baseIsNative;
6780
6781},{"./_isMasked":81,"./_toSource":116,"./isFunction":128,"./isObject":130}],37:[function(require,module,exports){
6782var baseGetTag = require('./_baseGetTag'),
6783 isLength = require('./isLength'),
6784 isObjectLike = require('./isObjectLike');
6785
6786/** `Object#toString` result references. */
6787var argsTag = '[object Arguments]',
6788 arrayTag = '[object Array]',
6789 boolTag = '[object Boolean]',
6790 dateTag = '[object Date]',
6791 errorTag = '[object Error]',
6792 funcTag = '[object Function]',
6793 mapTag = '[object Map]',
6794 numberTag = '[object Number]',
6795 objectTag = '[object Object]',
6796 regexpTag = '[object RegExp]',
6797 setTag = '[object Set]',
6798 stringTag = '[object String]',
6799 weakMapTag = '[object WeakMap]';
6800
6801var arrayBufferTag = '[object ArrayBuffer]',
6802 dataViewTag = '[object DataView]',
6803 float32Tag = '[object Float32Array]',
6804 float64Tag = '[object Float64Array]',
6805 int8Tag = '[object Int8Array]',
6806 int16Tag = '[object Int16Array]',
6807 int32Tag = '[object Int32Array]',
6808 uint8Tag = '[object Uint8Array]',
6809 uint8ClampedTag = '[object Uint8ClampedArray]',
6810 uint16Tag = '[object Uint16Array]',
6811 uint32Tag = '[object Uint32Array]';
6812
6813/** Used to identify `toStringTag` values of typed arrays. */
6814var typedArrayTags = {};
6815typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
6816typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
6817typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
6818typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
6819typedArrayTags[uint32Tag] = true;
6820typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
6821typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
6822typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
6823typedArrayTags[errorTag] = typedArrayTags[funcTag] =
6824typedArrayTags[mapTag] = typedArrayTags[numberTag] =
6825typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
6826typedArrayTags[setTag] = typedArrayTags[stringTag] =
6827typedArrayTags[weakMapTag] = false;
6828
6829/**
6830 * The base implementation of `_.isTypedArray` without Node.js optimizations.
6831 *
6832 * @private
6833 * @param {*} value The value to check.
6834 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
6835 */
6836function baseIsTypedArray(value) {
6837 return isObjectLike(value) &&
6838 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
6839}
6840
6841module.exports = baseIsTypedArray;
6842
6843},{"./_baseGetTag":30,"./isLength":129,"./isObjectLike":131}],38:[function(require,module,exports){
6844var baseMatches = require('./_baseMatches'),
6845 baseMatchesProperty = require('./_baseMatchesProperty'),
6846 identity = require('./identity'),
6847 isArray = require('./isArray'),
6848 property = require('./property');
6849
6850/**
6851 * The base implementation of `_.iteratee`.
6852 *
6853 * @private
6854 * @param {*} [value=_.identity] The value to convert to an iteratee.
6855 * @returns {Function} Returns the iteratee.
6856 */
6857function baseIteratee(value) {
6858 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
6859 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
6860 if (typeof value == 'function') {
6861 return value;
6862 }
6863 if (value == null) {
6864 return identity;
6865 }
6866 if (typeof value == 'object') {
6867 return isArray(value)
6868 ? baseMatchesProperty(value[0], value[1])
6869 : baseMatches(value);
6870 }
6871 return property(value);
6872}
6873
6874module.exports = baseIteratee;
6875
6876},{"./_baseMatches":41,"./_baseMatchesProperty":42,"./identity":123,"./isArray":125,"./property":139}],39:[function(require,module,exports){
6877var isPrototype = require('./_isPrototype'),
6878 nativeKeys = require('./_nativeKeys');
6879
6880/** Used for built-in method references. */
6881var objectProto = Object.prototype;
6882
6883/** Used to check objects for own properties. */
6884var hasOwnProperty = objectProto.hasOwnProperty;
6885
6886/**
6887 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
6888 *
6889 * @private
6890 * @param {Object} object The object to query.
6891 * @returns {Array} Returns the array of property names.
6892 */
6893function baseKeys(object) {
6894 if (!isPrototype(object)) {
6895 return nativeKeys(object);
6896 }
6897 var result = [];
6898 for (var key in Object(object)) {
6899 if (hasOwnProperty.call(object, key) && key != 'constructor') {
6900 result.push(key);
6901 }
6902 }
6903 return result;
6904}
6905
6906module.exports = baseKeys;
6907
6908},{"./_isPrototype":82,"./_nativeKeys":98}],40:[function(require,module,exports){
6909var baseEach = require('./_baseEach'),
6910 isArrayLike = require('./isArrayLike');
6911
6912/**
6913 * The base implementation of `_.map` without support for iteratee shorthands.
6914 *
6915 * @private
6916 * @param {Array|Object} collection The collection to iterate over.
6917 * @param {Function} iteratee The function invoked per iteration.
6918 * @returns {Array} Returns the new mapped array.
6919 */
6920function baseMap(collection, iteratee) {
6921 var index = -1,
6922 result = isArrayLike(collection) ? Array(collection.length) : [];
6923
6924 baseEach(collection, function(value, key, collection) {
6925 result[++index] = iteratee(value, key, collection);
6926 });
6927 return result;
6928}
6929
6930module.exports = baseMap;
6931
6932},{"./_baseEach":24,"./isArrayLike":126}],41:[function(require,module,exports){
6933var baseIsMatch = require('./_baseIsMatch'),
6934 getMatchData = require('./_getMatchData'),
6935 matchesStrictComparable = require('./_matchesStrictComparable');
6936
6937/**
6938 * The base implementation of `_.matches` which doesn't clone `source`.
6939 *
6940 * @private
6941 * @param {Object} source The object of property values to match.
6942 * @returns {Function} Returns the new spec function.
6943 */
6944function baseMatches(source) {
6945 var matchData = getMatchData(source);
6946 if (matchData.length == 1 && matchData[0][2]) {
6947 return matchesStrictComparable(matchData[0][0], matchData[0][1]);
6948 }
6949 return function(object) {
6950 return object === source || baseIsMatch(object, source, matchData);
6951 };
6952}
6953
6954module.exports = baseMatches;
6955
6956},{"./_baseIsMatch":35,"./_getMatchData":65,"./_matchesStrictComparable":95}],42:[function(require,module,exports){
6957var baseIsEqual = require('./_baseIsEqual'),
6958 get = require('./get'),
6959 hasIn = require('./hasIn'),
6960 isKey = require('./_isKey'),
6961 isStrictComparable = require('./_isStrictComparable'),
6962 matchesStrictComparable = require('./_matchesStrictComparable'),
6963 toKey = require('./_toKey');
6964
6965/** Used to compose bitmasks for value comparisons. */
6966var COMPARE_PARTIAL_FLAG = 1,
6967 COMPARE_UNORDERED_FLAG = 2;
6968
6969/**
6970 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
6971 *
6972 * @private
6973 * @param {string} path The path of the property to get.
6974 * @param {*} srcValue The value to match.
6975 * @returns {Function} Returns the new spec function.
6976 */
6977function baseMatchesProperty(path, srcValue) {
6978 if (isKey(path) && isStrictComparable(srcValue)) {
6979 return matchesStrictComparable(toKey(path), srcValue);
6980 }
6981 return function(object) {
6982 var objValue = get(object, path);
6983 return (objValue === undefined && objValue === srcValue)
6984 ? hasIn(object, path)
6985 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
6986 };
6987}
6988
6989module.exports = baseMatchesProperty;
6990
6991},{"./_baseIsEqual":33,"./_isKey":79,"./_isStrictComparable":83,"./_matchesStrictComparable":95,"./_toKey":115,"./get":121,"./hasIn":122}],43:[function(require,module,exports){
6992var basePickBy = require('./_basePickBy'),
6993 hasIn = require('./hasIn');
6994
6995/**
6996 * The base implementation of `_.pick` without support for individual
6997 * property identifiers.
6998 *
6999 * @private
7000 * @param {Object} object The source object.
7001 * @param {string[]} paths The property paths to pick.
7002 * @returns {Object} Returns the new object.
7003 */
7004function basePick(object, paths) {
7005 return basePickBy(object, paths, function(value, path) {
7006 return hasIn(object, path);
7007 });
7008}
7009
7010module.exports = basePick;
7011
7012},{"./_basePickBy":44,"./hasIn":122}],44:[function(require,module,exports){
7013var baseGet = require('./_baseGet'),
7014 baseSet = require('./_baseSet'),
7015 castPath = require('./_castPath');
7016
7017/**
7018 * The base implementation of `_.pickBy` without support for iteratee shorthands.
7019 *
7020 * @private
7021 * @param {Object} object The source object.
7022 * @param {string[]} paths The property paths to pick.
7023 * @param {Function} predicate The function invoked per property.
7024 * @returns {Object} Returns the new object.
7025 */
7026function basePickBy(object, paths, predicate) {
7027 var index = -1,
7028 length = paths.length,
7029 result = {};
7030
7031 while (++index < length) {
7032 var path = paths[index],
7033 value = baseGet(object, path);
7034
7035 if (predicate(value, path)) {
7036 baseSet(result, castPath(path, object), value);
7037 }
7038 }
7039 return result;
7040}
7041
7042module.exports = basePickBy;
7043
7044},{"./_baseGet":28,"./_baseSet":47,"./_castPath":53}],45:[function(require,module,exports){
7045/**
7046 * The base implementation of `_.property` without support for deep paths.
7047 *
7048 * @private
7049 * @param {string} key The key of the property to get.
7050 * @returns {Function} Returns the new accessor function.
7051 */
7052function baseProperty(key) {
7053 return function(object) {
7054 return object == null ? undefined : object[key];
7055 };
7056}
7057
7058module.exports = baseProperty;
7059
7060},{}],46:[function(require,module,exports){
7061var baseGet = require('./_baseGet');
7062
7063/**
7064 * A specialized version of `baseProperty` which supports deep paths.
7065 *
7066 * @private
7067 * @param {Array|string} path The path of the property to get.
7068 * @returns {Function} Returns the new accessor function.
7069 */
7070function basePropertyDeep(path) {
7071 return function(object) {
7072 return baseGet(object, path);
7073 };
7074}
7075
7076module.exports = basePropertyDeep;
7077
7078},{"./_baseGet":28}],47:[function(require,module,exports){
7079var assignValue = require('./_assignValue'),
7080 castPath = require('./_castPath'),
7081 isIndex = require('./_isIndex'),
7082 isObject = require('./isObject'),
7083 toKey = require('./_toKey');
7084
7085/**
7086 * The base implementation of `_.set`.
7087 *
7088 * @private
7089 * @param {Object} object The object to modify.
7090 * @param {Array|string} path The path of the property to set.
7091 * @param {*} value The value to set.
7092 * @param {Function} [customizer] The function to customize path creation.
7093 * @returns {Object} Returns `object`.
7094 */
7095function baseSet(object, path, value, customizer) {
7096 if (!isObject(object)) {
7097 return object;
7098 }
7099 path = castPath(path, object);
7100
7101 var index = -1,
7102 length = path.length,
7103 lastIndex = length - 1,
7104 nested = object;
7105
7106 while (nested != null && ++index < length) {
7107 var key = toKey(path[index]),
7108 newValue = value;
7109
7110 if (index != lastIndex) {
7111 var objValue = nested[key];
7112 newValue = customizer ? customizer(objValue, key, nested) : undefined;
7113 if (newValue === undefined) {
7114 newValue = isObject(objValue)
7115 ? objValue
7116 : (isIndex(path[index + 1]) ? [] : {});
7117 }
7118 }
7119 assignValue(nested, key, newValue);
7120 nested = nested[key];
7121 }
7122 return object;
7123}
7124
7125module.exports = baseSet;
7126
7127},{"./_assignValue":21,"./_castPath":53,"./_isIndex":78,"./_toKey":115,"./isObject":130}],48:[function(require,module,exports){
7128var constant = require('./constant'),
7129 defineProperty = require('./_defineProperty'),
7130 identity = require('./identity');
7131
7132/**
7133 * The base implementation of `setToString` without support for hot loop shorting.
7134 *
7135 * @private
7136 * @param {Function} func The function to modify.
7137 * @param {Function} string The `toString` result.
7138 * @returns {Function} Returns `func`.
7139 */
7140var baseSetToString = !defineProperty ? identity : function(func, string) {
7141 return defineProperty(func, 'toString', {
7142 'configurable': true,
7143 'enumerable': false,
7144 'value': constant(string),
7145 'writable': true
7146 });
7147};
7148
7149module.exports = baseSetToString;
7150
7151},{"./_defineProperty":57,"./constant":118,"./identity":123}],49:[function(require,module,exports){
7152/**
7153 * The base implementation of `_.times` without support for iteratee shorthands
7154 * or max array length checks.
7155 *
7156 * @private
7157 * @param {number} n The number of times to invoke `iteratee`.
7158 * @param {Function} iteratee The function invoked per iteration.
7159 * @returns {Array} Returns the array of results.
7160 */
7161function baseTimes(n, iteratee) {
7162 var index = -1,
7163 result = Array(n);
7164
7165 while (++index < n) {
7166 result[index] = iteratee(index);
7167 }
7168 return result;
7169}
7170
7171module.exports = baseTimes;
7172
7173},{}],50:[function(require,module,exports){
7174var Symbol = require('./_Symbol'),
7175 arrayMap = require('./_arrayMap'),
7176 isArray = require('./isArray'),
7177 isSymbol = require('./isSymbol');
7178
7179/** Used as references for various `Number` constants. */
7180var INFINITY = 1 / 0;
7181
7182/** Used to convert symbols to primitives and strings. */
7183var symbolProto = Symbol ? Symbol.prototype : undefined,
7184 symbolToString = symbolProto ? symbolProto.toString : undefined;
7185
7186/**
7187 * The base implementation of `_.toString` which doesn't convert nullish
7188 * values to empty strings.
7189 *
7190 * @private
7191 * @param {*} value The value to process.
7192 * @returns {string} Returns the string.
7193 */
7194function baseToString(value) {
7195 // Exit early for strings to avoid a performance hit in some environments.
7196 if (typeof value == 'string') {
7197 return value;
7198 }
7199 if (isArray(value)) {
7200 // Recursively convert values (susceptible to call stack limits).
7201 return arrayMap(value, baseToString) + '';
7202 }
7203 if (isSymbol(value)) {
7204 return symbolToString ? symbolToString.call(value) : '';
7205 }
7206 var result = (value + '');
7207 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
7208}
7209
7210module.exports = baseToString;
7211
7212},{"./_Symbol":12,"./_arrayMap":18,"./isArray":125,"./isSymbol":132}],51:[function(require,module,exports){
7213/**
7214 * The base implementation of `_.unary` without support for storing metadata.
7215 *
7216 * @private
7217 * @param {Function} func The function to cap arguments for.
7218 * @returns {Function} Returns the new capped function.
7219 */
7220function baseUnary(func) {
7221 return function(value) {
7222 return func(value);
7223 };
7224}
7225
7226module.exports = baseUnary;
7227
7228},{}],52:[function(require,module,exports){
7229/**
7230 * Checks if a `cache` value for `key` exists.
7231 *
7232 * @private
7233 * @param {Object} cache The cache to query.
7234 * @param {string} key The key of the entry to check.
7235 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
7236 */
7237function cacheHas(cache, key) {
7238 return cache.has(key);
7239}
7240
7241module.exports = cacheHas;
7242
7243},{}],53:[function(require,module,exports){
7244var isArray = require('./isArray'),
7245 isKey = require('./_isKey'),
7246 stringToPath = require('./_stringToPath'),
7247 toString = require('./toString');
7248
7249/**
7250 * Casts `value` to a path array if it's not one.
7251 *
7252 * @private
7253 * @param {*} value The value to inspect.
7254 * @param {Object} [object] The object to query keys on.
7255 * @returns {Array} Returns the cast property path array.
7256 */
7257function castPath(value, object) {
7258 if (isArray(value)) {
7259 return value;
7260 }
7261 return isKey(value, object) ? [value] : stringToPath(toString(value));
7262}
7263
7264module.exports = castPath;
7265
7266},{"./_isKey":79,"./_stringToPath":114,"./isArray":125,"./toString":145}],54:[function(require,module,exports){
7267var root = require('./_root');
7268
7269/** Used to detect overreaching core-js shims. */
7270var coreJsData = root['__core-js_shared__'];
7271
7272module.exports = coreJsData;
7273
7274},{"./_root":103}],55:[function(require,module,exports){
7275var isArrayLike = require('./isArrayLike');
7276
7277/**
7278 * Creates a `baseEach` or `baseEachRight` function.
7279 *
7280 * @private
7281 * @param {Function} eachFunc The function to iterate over a collection.
7282 * @param {boolean} [fromRight] Specify iterating from right to left.
7283 * @returns {Function} Returns the new base function.
7284 */
7285function createBaseEach(eachFunc, fromRight) {
7286 return function(collection, iteratee) {
7287 if (collection == null) {
7288 return collection;
7289 }
7290 if (!isArrayLike(collection)) {
7291 return eachFunc(collection, iteratee);
7292 }
7293 var length = collection.length,
7294 index = fromRight ? length : -1,
7295 iterable = Object(collection);
7296
7297 while ((fromRight ? index-- : ++index < length)) {
7298 if (iteratee(iterable[index], index, iterable) === false) {
7299 break;
7300 }
7301 }
7302 return collection;
7303 };
7304}
7305
7306module.exports = createBaseEach;
7307
7308},{"./isArrayLike":126}],56:[function(require,module,exports){
7309/**
7310 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
7311 *
7312 * @private
7313 * @param {boolean} [fromRight] Specify iterating from right to left.
7314 * @returns {Function} Returns the new base function.
7315 */
7316function createBaseFor(fromRight) {
7317 return function(object, iteratee, keysFunc) {
7318 var index = -1,
7319 iterable = Object(object),
7320 props = keysFunc(object),
7321 length = props.length;
7322
7323 while (length--) {
7324 var key = props[fromRight ? length : ++index];
7325 if (iteratee(iterable[key], key, iterable) === false) {
7326 break;
7327 }
7328 }
7329 return object;
7330 };
7331}
7332
7333module.exports = createBaseFor;
7334
7335},{}],57:[function(require,module,exports){
7336var getNative = require('./_getNative');
7337
7338var defineProperty = (function() {
7339 try {
7340 var func = getNative(Object, 'defineProperty');
7341 func({}, '', {});
7342 return func;
7343 } catch (e) {}
7344}());
7345
7346module.exports = defineProperty;
7347
7348},{"./_getNative":66}],58:[function(require,module,exports){
7349var SetCache = require('./_SetCache'),
7350 arraySome = require('./_arraySome'),
7351 cacheHas = require('./_cacheHas');
7352
7353/** Used to compose bitmasks for value comparisons. */
7354var COMPARE_PARTIAL_FLAG = 1,
7355 COMPARE_UNORDERED_FLAG = 2;
7356
7357/**
7358 * A specialized version of `baseIsEqualDeep` for arrays with support for
7359 * partial deep comparisons.
7360 *
7361 * @private
7362 * @param {Array} array The array to compare.
7363 * @param {Array} other The other array to compare.
7364 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
7365 * @param {Function} customizer The function to customize comparisons.
7366 * @param {Function} equalFunc The function to determine equivalents of values.
7367 * @param {Object} stack Tracks traversed `array` and `other` objects.
7368 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
7369 */
7370function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
7371 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
7372 arrLength = array.length,
7373 othLength = other.length;
7374
7375 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
7376 return false;
7377 }
7378 // Assume cyclic values are equal.
7379 var stacked = stack.get(array);
7380 if (stacked && stack.get(other)) {
7381 return stacked == other;
7382 }
7383 var index = -1,
7384 result = true,
7385 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
7386
7387 stack.set(array, other);
7388 stack.set(other, array);
7389
7390 // Ignore non-index properties.
7391 while (++index < arrLength) {
7392 var arrValue = array[index],
7393 othValue = other[index];
7394
7395 if (customizer) {
7396 var compared = isPartial
7397 ? customizer(othValue, arrValue, index, other, array, stack)
7398 : customizer(arrValue, othValue, index, array, other, stack);
7399 }
7400 if (compared !== undefined) {
7401 if (compared) {
7402 continue;
7403 }
7404 result = false;
7405 break;
7406 }
7407 // Recursively compare arrays (susceptible to call stack limits).
7408 if (seen) {
7409 if (!arraySome(other, function(othValue, othIndex) {
7410 if (!cacheHas(seen, othIndex) &&
7411 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
7412 return seen.push(othIndex);
7413 }
7414 })) {
7415 result = false;
7416 break;
7417 }
7418 } else if (!(
7419 arrValue === othValue ||
7420 equalFunc(arrValue, othValue, bitmask, customizer, stack)
7421 )) {
7422 result = false;
7423 break;
7424 }
7425 }
7426 stack['delete'](array);
7427 stack['delete'](other);
7428 return result;
7429}
7430
7431module.exports = equalArrays;
7432
7433},{"./_SetCache":10,"./_arraySome":20,"./_cacheHas":52}],59:[function(require,module,exports){
7434var Symbol = require('./_Symbol'),
7435 Uint8Array = require('./_Uint8Array'),
7436 eq = require('./eq'),
7437 equalArrays = require('./_equalArrays'),
7438 mapToArray = require('./_mapToArray'),
7439 setToArray = require('./_setToArray');
7440
7441/** Used to compose bitmasks for value comparisons. */
7442var COMPARE_PARTIAL_FLAG = 1,
7443 COMPARE_UNORDERED_FLAG = 2;
7444
7445/** `Object#toString` result references. */
7446var boolTag = '[object Boolean]',
7447 dateTag = '[object Date]',
7448 errorTag = '[object Error]',
7449 mapTag = '[object Map]',
7450 numberTag = '[object Number]',
7451 regexpTag = '[object RegExp]',
7452 setTag = '[object Set]',
7453 stringTag = '[object String]',
7454 symbolTag = '[object Symbol]';
7455
7456var arrayBufferTag = '[object ArrayBuffer]',
7457 dataViewTag = '[object DataView]';
7458
7459/** Used to convert symbols to primitives and strings. */
7460var symbolProto = Symbol ? Symbol.prototype : undefined,
7461 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
7462
7463/**
7464 * A specialized version of `baseIsEqualDeep` for comparing objects of
7465 * the same `toStringTag`.
7466 *
7467 * **Note:** This function only supports comparing values with tags of
7468 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
7469 *
7470 * @private
7471 * @param {Object} object The object to compare.
7472 * @param {Object} other The other object to compare.
7473 * @param {string} tag The `toStringTag` of the objects to compare.
7474 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
7475 * @param {Function} customizer The function to customize comparisons.
7476 * @param {Function} equalFunc The function to determine equivalents of values.
7477 * @param {Object} stack Tracks traversed `object` and `other` objects.
7478 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
7479 */
7480function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
7481 switch (tag) {
7482 case dataViewTag:
7483 if ((object.byteLength != other.byteLength) ||
7484 (object.byteOffset != other.byteOffset)) {
7485 return false;
7486 }
7487 object = object.buffer;
7488 other = other.buffer;
7489
7490 case arrayBufferTag:
7491 if ((object.byteLength != other.byteLength) ||
7492 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
7493 return false;
7494 }
7495 return true;
7496
7497 case boolTag:
7498 case dateTag:
7499 case numberTag:
7500 // Coerce booleans to `1` or `0` and dates to milliseconds.
7501 // Invalid dates are coerced to `NaN`.
7502 return eq(+object, +other);
7503
7504 case errorTag:
7505 return object.name == other.name && object.message == other.message;
7506
7507 case regexpTag:
7508 case stringTag:
7509 // Coerce regexes to strings and treat strings, primitives and objects,
7510 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
7511 // for more details.
7512 return object == (other + '');
7513
7514 case mapTag:
7515 var convert = mapToArray;
7516
7517 case setTag:
7518 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
7519 convert || (convert = setToArray);
7520
7521 if (object.size != other.size && !isPartial) {
7522 return false;
7523 }
7524 // Assume cyclic values are equal.
7525 var stacked = stack.get(object);
7526 if (stacked) {
7527 return stacked == other;
7528 }
7529 bitmask |= COMPARE_UNORDERED_FLAG;
7530
7531 // Recursively compare objects (susceptible to call stack limits).
7532 stack.set(object, other);
7533 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
7534 stack['delete'](object);
7535 return result;
7536
7537 case symbolTag:
7538 if (symbolValueOf) {
7539 return symbolValueOf.call(object) == symbolValueOf.call(other);
7540 }
7541 }
7542 return false;
7543}
7544
7545module.exports = equalByTag;
7546
7547},{"./_Symbol":12,"./_Uint8Array":13,"./_equalArrays":58,"./_mapToArray":94,"./_setToArray":106,"./eq":119}],60:[function(require,module,exports){
7548var getAllKeys = require('./_getAllKeys');
7549
7550/** Used to compose bitmasks for value comparisons. */
7551var COMPARE_PARTIAL_FLAG = 1;
7552
7553/** Used for built-in method references. */
7554var objectProto = Object.prototype;
7555
7556/** Used to check objects for own properties. */
7557var hasOwnProperty = objectProto.hasOwnProperty;
7558
7559/**
7560 * A specialized version of `baseIsEqualDeep` for objects with support for
7561 * partial deep comparisons.
7562 *
7563 * @private
7564 * @param {Object} object The object to compare.
7565 * @param {Object} other The other object to compare.
7566 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
7567 * @param {Function} customizer The function to customize comparisons.
7568 * @param {Function} equalFunc The function to determine equivalents of values.
7569 * @param {Object} stack Tracks traversed `object` and `other` objects.
7570 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
7571 */
7572function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
7573 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
7574 objProps = getAllKeys(object),
7575 objLength = objProps.length,
7576 othProps = getAllKeys(other),
7577 othLength = othProps.length;
7578
7579 if (objLength != othLength && !isPartial) {
7580 return false;
7581 }
7582 var index = objLength;
7583 while (index--) {
7584 var key = objProps[index];
7585 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
7586 return false;
7587 }
7588 }
7589 // Assume cyclic values are equal.
7590 var stacked = stack.get(object);
7591 if (stacked && stack.get(other)) {
7592 return stacked == other;
7593 }
7594 var result = true;
7595 stack.set(object, other);
7596 stack.set(other, object);
7597
7598 var skipCtor = isPartial;
7599 while (++index < objLength) {
7600 key = objProps[index];
7601 var objValue = object[key],
7602 othValue = other[key];
7603
7604 if (customizer) {
7605 var compared = isPartial
7606 ? customizer(othValue, objValue, key, other, object, stack)
7607 : customizer(objValue, othValue, key, object, other, stack);
7608 }
7609 // Recursively compare objects (susceptible to call stack limits).
7610 if (!(compared === undefined
7611 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
7612 : compared
7613 )) {
7614 result = false;
7615 break;
7616 }
7617 skipCtor || (skipCtor = key == 'constructor');
7618 }
7619 if (result && !skipCtor) {
7620 var objCtor = object.constructor,
7621 othCtor = other.constructor;
7622
7623 // Non `Object` object instances with different constructors are not equal.
7624 if (objCtor != othCtor &&
7625 ('constructor' in object && 'constructor' in other) &&
7626 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
7627 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
7628 result = false;
7629 }
7630 }
7631 stack['delete'](object);
7632 stack['delete'](other);
7633 return result;
7634}
7635
7636module.exports = equalObjects;
7637
7638},{"./_getAllKeys":63}],61:[function(require,module,exports){
7639var flatten = require('./flatten'),
7640 overRest = require('./_overRest'),
7641 setToString = require('./_setToString');
7642
7643/**
7644 * A specialized version of `baseRest` which flattens the rest array.
7645 *
7646 * @private
7647 * @param {Function} func The function to apply a rest parameter to.
7648 * @returns {Function} Returns the new function.
7649 */
7650function flatRest(func) {
7651 return setToString(overRest(func, undefined, flatten), func + '');
7652}
7653
7654module.exports = flatRest;
7655
7656},{"./_overRest":102,"./_setToString":107,"./flatten":120}],62:[function(require,module,exports){
7657(function (global){
7658/** Detect free variable `global` from Node.js. */
7659var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
7660
7661module.exports = freeGlobal;
7662
7663}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
7664},{}],63:[function(require,module,exports){
7665var baseGetAllKeys = require('./_baseGetAllKeys'),
7666 getSymbols = require('./_getSymbols'),
7667 keys = require('./keys');
7668
7669/**
7670 * Creates an array of own enumerable property names and symbols of `object`.
7671 *
7672 * @private
7673 * @param {Object} object The object to query.
7674 * @returns {Array} Returns the array of property names and symbols.
7675 */
7676function getAllKeys(object) {
7677 return baseGetAllKeys(object, keys, getSymbols);
7678}
7679
7680module.exports = getAllKeys;
7681
7682},{"./_baseGetAllKeys":29,"./_getSymbols":68,"./keys":134}],64:[function(require,module,exports){
7683var isKeyable = require('./_isKeyable');
7684
7685/**
7686 * Gets the data for `map`.
7687 *
7688 * @private
7689 * @param {Object} map The map to query.
7690 * @param {string} key The reference key.
7691 * @returns {*} Returns the map data.
7692 */
7693function getMapData(map, key) {
7694 var data = map.__data__;
7695 return isKeyable(key)
7696 ? data[typeof key == 'string' ? 'string' : 'hash']
7697 : data.map;
7698}
7699
7700module.exports = getMapData;
7701
7702},{"./_isKeyable":80}],65:[function(require,module,exports){
7703var isStrictComparable = require('./_isStrictComparable'),
7704 keys = require('./keys');
7705
7706/**
7707 * Gets the property names, values, and compare flags of `object`.
7708 *
7709 * @private
7710 * @param {Object} object The object to query.
7711 * @returns {Array} Returns the match data of `object`.
7712 */
7713function getMatchData(object) {
7714 var result = keys(object),
7715 length = result.length;
7716
7717 while (length--) {
7718 var key = result[length],
7719 value = object[key];
7720
7721 result[length] = [key, value, isStrictComparable(value)];
7722 }
7723 return result;
7724}
7725
7726module.exports = getMatchData;
7727
7728},{"./_isStrictComparable":83,"./keys":134}],66:[function(require,module,exports){
7729var baseIsNative = require('./_baseIsNative'),
7730 getValue = require('./_getValue');
7731
7732/**
7733 * Gets the native function at `key` of `object`.
7734 *
7735 * @private
7736 * @param {Object} object The object to query.
7737 * @param {string} key The key of the method to get.
7738 * @returns {*} Returns the function if it's native, else `undefined`.
7739 */
7740function getNative(object, key) {
7741 var value = getValue(object, key);
7742 return baseIsNative(value) ? value : undefined;
7743}
7744
7745module.exports = getNative;
7746
7747},{"./_baseIsNative":36,"./_getValue":70}],67:[function(require,module,exports){
7748var Symbol = require('./_Symbol');
7749
7750/** Used for built-in method references. */
7751var objectProto = Object.prototype;
7752
7753/** Used to check objects for own properties. */
7754var hasOwnProperty = objectProto.hasOwnProperty;
7755
7756/**
7757 * Used to resolve the
7758 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
7759 * of values.
7760 */
7761var nativeObjectToString = objectProto.toString;
7762
7763/** Built-in value references. */
7764var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
7765
7766/**
7767 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
7768 *
7769 * @private
7770 * @param {*} value The value to query.
7771 * @returns {string} Returns the raw `toStringTag`.
7772 */
7773function getRawTag(value) {
7774 var isOwn = hasOwnProperty.call(value, symToStringTag),
7775 tag = value[symToStringTag];
7776
7777 try {
7778 value[symToStringTag] = undefined;
7779 var unmasked = true;
7780 } catch (e) {}
7781
7782 var result = nativeObjectToString.call(value);
7783 if (unmasked) {
7784 if (isOwn) {
7785 value[symToStringTag] = tag;
7786 } else {
7787 delete value[symToStringTag];
7788 }
7789 }
7790 return result;
7791}
7792
7793module.exports = getRawTag;
7794
7795},{"./_Symbol":12}],68:[function(require,module,exports){
7796var arrayFilter = require('./_arrayFilter'),
7797 stubArray = require('./stubArray');
7798
7799/** Used for built-in method references. */
7800var objectProto = Object.prototype;
7801
7802/** Built-in value references. */
7803var propertyIsEnumerable = objectProto.propertyIsEnumerable;
7804
7805/* Built-in method references for those with the same name as other `lodash` methods. */
7806var nativeGetSymbols = Object.getOwnPropertySymbols;
7807
7808/**
7809 * Creates an array of the own enumerable symbols of `object`.
7810 *
7811 * @private
7812 * @param {Object} object The object to query.
7813 * @returns {Array} Returns the array of symbols.
7814 */
7815var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
7816 if (object == null) {
7817 return [];
7818 }
7819 object = Object(object);
7820 return arrayFilter(nativeGetSymbols(object), function(symbol) {
7821 return propertyIsEnumerable.call(object, symbol);
7822 });
7823};
7824
7825module.exports = getSymbols;
7826
7827},{"./_arrayFilter":16,"./stubArray":140}],69:[function(require,module,exports){
7828var DataView = require('./_DataView'),
7829 Map = require('./_Map'),
7830 Promise = require('./_Promise'),
7831 Set = require('./_Set'),
7832 WeakMap = require('./_WeakMap'),
7833 baseGetTag = require('./_baseGetTag'),
7834 toSource = require('./_toSource');
7835
7836/** `Object#toString` result references. */
7837var mapTag = '[object Map]',
7838 objectTag = '[object Object]',
7839 promiseTag = '[object Promise]',
7840 setTag = '[object Set]',
7841 weakMapTag = '[object WeakMap]';
7842
7843var dataViewTag = '[object DataView]';
7844
7845/** Used to detect maps, sets, and weakmaps. */
7846var dataViewCtorString = toSource(DataView),
7847 mapCtorString = toSource(Map),
7848 promiseCtorString = toSource(Promise),
7849 setCtorString = toSource(Set),
7850 weakMapCtorString = toSource(WeakMap);
7851
7852/**
7853 * Gets the `toStringTag` of `value`.
7854 *
7855 * @private
7856 * @param {*} value The value to query.
7857 * @returns {string} Returns the `toStringTag`.
7858 */
7859var getTag = baseGetTag;
7860
7861// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
7862if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
7863 (Map && getTag(new Map) != mapTag) ||
7864 (Promise && getTag(Promise.resolve()) != promiseTag) ||
7865 (Set && getTag(new Set) != setTag) ||
7866 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
7867 getTag = function(value) {
7868 var result = baseGetTag(value),
7869 Ctor = result == objectTag ? value.constructor : undefined,
7870 ctorString = Ctor ? toSource(Ctor) : '';
7871
7872 if (ctorString) {
7873 switch (ctorString) {
7874 case dataViewCtorString: return dataViewTag;
7875 case mapCtorString: return mapTag;
7876 case promiseCtorString: return promiseTag;
7877 case setCtorString: return setTag;
7878 case weakMapCtorString: return weakMapTag;
7879 }
7880 }
7881 return result;
7882 };
7883}
7884
7885module.exports = getTag;
7886
7887},{"./_DataView":3,"./_Map":6,"./_Promise":8,"./_Set":9,"./_WeakMap":14,"./_baseGetTag":30,"./_toSource":116}],70:[function(require,module,exports){
7888/**
7889 * Gets the value at `key` of `object`.
7890 *
7891 * @private
7892 * @param {Object} [object] The object to query.
7893 * @param {string} key The key of the property to get.
7894 * @returns {*} Returns the property value.
7895 */
7896function getValue(object, key) {
7897 return object == null ? undefined : object[key];
7898}
7899
7900module.exports = getValue;
7901
7902},{}],71:[function(require,module,exports){
7903var castPath = require('./_castPath'),
7904 isArguments = require('./isArguments'),
7905 isArray = require('./isArray'),
7906 isIndex = require('./_isIndex'),
7907 isLength = require('./isLength'),
7908 toKey = require('./_toKey');
7909
7910/**
7911 * Checks if `path` exists on `object`.
7912 *
7913 * @private
7914 * @param {Object} object The object to query.
7915 * @param {Array|string} path The path to check.
7916 * @param {Function} hasFunc The function to check properties.
7917 * @returns {boolean} Returns `true` if `path` exists, else `false`.
7918 */
7919function hasPath(object, path, hasFunc) {
7920 path = castPath(path, object);
7921
7922 var index = -1,
7923 length = path.length,
7924 result = false;
7925
7926 while (++index < length) {
7927 var key = toKey(path[index]);
7928 if (!(result = object != null && hasFunc(object, key))) {
7929 break;
7930 }
7931 object = object[key];
7932 }
7933 if (result || ++index != length) {
7934 return result;
7935 }
7936 length = object == null ? 0 : object.length;
7937 return !!length && isLength(length) && isIndex(key, length) &&
7938 (isArray(object) || isArguments(object));
7939}
7940
7941module.exports = hasPath;
7942
7943},{"./_castPath":53,"./_isIndex":78,"./_toKey":115,"./isArguments":124,"./isArray":125,"./isLength":129}],72:[function(require,module,exports){
7944var nativeCreate = require('./_nativeCreate');
7945
7946/**
7947 * Removes all key-value entries from the hash.
7948 *
7949 * @private
7950 * @name clear
7951 * @memberOf Hash
7952 */
7953function hashClear() {
7954 this.__data__ = nativeCreate ? nativeCreate(null) : {};
7955 this.size = 0;
7956}
7957
7958module.exports = hashClear;
7959
7960},{"./_nativeCreate":97}],73:[function(require,module,exports){
7961/**
7962 * Removes `key` and its value from the hash.
7963 *
7964 * @private
7965 * @name delete
7966 * @memberOf Hash
7967 * @param {Object} hash The hash to modify.
7968 * @param {string} key The key of the value to remove.
7969 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
7970 */
7971function hashDelete(key) {
7972 var result = this.has(key) && delete this.__data__[key];
7973 this.size -= result ? 1 : 0;
7974 return result;
7975}
7976
7977module.exports = hashDelete;
7978
7979},{}],74:[function(require,module,exports){
7980var nativeCreate = require('./_nativeCreate');
7981
7982/** Used to stand-in for `undefined` hash values. */
7983var HASH_UNDEFINED = '__lodash_hash_undefined__';
7984
7985/** Used for built-in method references. */
7986var objectProto = Object.prototype;
7987
7988/** Used to check objects for own properties. */
7989var hasOwnProperty = objectProto.hasOwnProperty;
7990
7991/**
7992 * Gets the hash value for `key`.
7993 *
7994 * @private
7995 * @name get
7996 * @memberOf Hash
7997 * @param {string} key The key of the value to get.
7998 * @returns {*} Returns the entry value.
7999 */
8000function hashGet(key) {
8001 var data = this.__data__;
8002 if (nativeCreate) {
8003 var result = data[key];
8004 return result === HASH_UNDEFINED ? undefined : result;
8005 }
8006 return hasOwnProperty.call(data, key) ? data[key] : undefined;
8007}
8008
8009module.exports = hashGet;
8010
8011},{"./_nativeCreate":97}],75:[function(require,module,exports){
8012var nativeCreate = require('./_nativeCreate');
8013
8014/** Used for built-in method references. */
8015var objectProto = Object.prototype;
8016
8017/** Used to check objects for own properties. */
8018var hasOwnProperty = objectProto.hasOwnProperty;
8019
8020/**
8021 * Checks if a hash value for `key` exists.
8022 *
8023 * @private
8024 * @name has
8025 * @memberOf Hash
8026 * @param {string} key The key of the entry to check.
8027 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
8028 */
8029function hashHas(key) {
8030 var data = this.__data__;
8031 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
8032}
8033
8034module.exports = hashHas;
8035
8036},{"./_nativeCreate":97}],76:[function(require,module,exports){
8037var nativeCreate = require('./_nativeCreate');
8038
8039/** Used to stand-in for `undefined` hash values. */
8040var HASH_UNDEFINED = '__lodash_hash_undefined__';
8041
8042/**
8043 * Sets the hash `key` to `value`.
8044 *
8045 * @private
8046 * @name set
8047 * @memberOf Hash
8048 * @param {string} key The key of the value to set.
8049 * @param {*} value The value to set.
8050 * @returns {Object} Returns the hash instance.
8051 */
8052function hashSet(key, value) {
8053 var data = this.__data__;
8054 this.size += this.has(key) ? 0 : 1;
8055 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
8056 return this;
8057}
8058
8059module.exports = hashSet;
8060
8061},{"./_nativeCreate":97}],77:[function(require,module,exports){
8062var Symbol = require('./_Symbol'),
8063 isArguments = require('./isArguments'),
8064 isArray = require('./isArray');
8065
8066/** Built-in value references. */
8067var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
8068
8069/**
8070 * Checks if `value` is a flattenable `arguments` object or array.
8071 *
8072 * @private
8073 * @param {*} value The value to check.
8074 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
8075 */
8076function isFlattenable(value) {
8077 return isArray(value) || isArguments(value) ||
8078 !!(spreadableSymbol && value && value[spreadableSymbol]);
8079}
8080
8081module.exports = isFlattenable;
8082
8083},{"./_Symbol":12,"./isArguments":124,"./isArray":125}],78:[function(require,module,exports){
8084/** Used as references for various `Number` constants. */
8085var MAX_SAFE_INTEGER = 9007199254740991;
8086
8087/** Used to detect unsigned integer values. */
8088var reIsUint = /^(?:0|[1-9]\d*)$/;
8089
8090/**
8091 * Checks if `value` is a valid array-like index.
8092 *
8093 * @private
8094 * @param {*} value The value to check.
8095 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
8096 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
8097 */
8098function isIndex(value, length) {
8099 length = length == null ? MAX_SAFE_INTEGER : length;
8100 return !!length &&
8101 (typeof value == 'number' || reIsUint.test(value)) &&
8102 (value > -1 && value % 1 == 0 && value < length);
8103}
8104
8105module.exports = isIndex;
8106
8107},{}],79:[function(require,module,exports){
8108var isArray = require('./isArray'),
8109 isSymbol = require('./isSymbol');
8110
8111/** Used to match property names within property paths. */
8112var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
8113 reIsPlainProp = /^\w*$/;
8114
8115/**
8116 * Checks if `value` is a property name and not a property path.
8117 *
8118 * @private
8119 * @param {*} value The value to check.
8120 * @param {Object} [object] The object to query keys on.
8121 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
8122 */
8123function isKey(value, object) {
8124 if (isArray(value)) {
8125 return false;
8126 }
8127 var type = typeof value;
8128 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
8129 value == null || isSymbol(value)) {
8130 return true;
8131 }
8132 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
8133 (object != null && value in Object(object));
8134}
8135
8136module.exports = isKey;
8137
8138},{"./isArray":125,"./isSymbol":132}],80:[function(require,module,exports){
8139/**
8140 * Checks if `value` is suitable for use as unique object key.
8141 *
8142 * @private
8143 * @param {*} value The value to check.
8144 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
8145 */
8146function isKeyable(value) {
8147 var type = typeof value;
8148 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
8149 ? (value !== '__proto__')
8150 : (value === null);
8151}
8152
8153module.exports = isKeyable;
8154
8155},{}],81:[function(require,module,exports){
8156var coreJsData = require('./_coreJsData');
8157
8158/** Used to detect methods masquerading as native. */
8159var maskSrcKey = (function() {
8160 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
8161 return uid ? ('Symbol(src)_1.' + uid) : '';
8162}());
8163
8164/**
8165 * Checks if `func` has its source masked.
8166 *
8167 * @private
8168 * @param {Function} func The function to check.
8169 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
8170 */
8171function isMasked(func) {
8172 return !!maskSrcKey && (maskSrcKey in func);
8173}
8174
8175module.exports = isMasked;
8176
8177},{"./_coreJsData":54}],82:[function(require,module,exports){
8178/** Used for built-in method references. */
8179var objectProto = Object.prototype;
8180
8181/**
8182 * Checks if `value` is likely a prototype object.
8183 *
8184 * @private
8185 * @param {*} value The value to check.
8186 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
8187 */
8188function isPrototype(value) {
8189 var Ctor = value && value.constructor,
8190 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
8191
8192 return value === proto;
8193}
8194
8195module.exports = isPrototype;
8196
8197},{}],83:[function(require,module,exports){
8198var isObject = require('./isObject');
8199
8200/**
8201 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
8202 *
8203 * @private
8204 * @param {*} value The value to check.
8205 * @returns {boolean} Returns `true` if `value` if suitable for strict
8206 * equality comparisons, else `false`.
8207 */
8208function isStrictComparable(value) {
8209 return value === value && !isObject(value);
8210}
8211
8212module.exports = isStrictComparable;
8213
8214},{"./isObject":130}],84:[function(require,module,exports){
8215/**
8216 * Removes all key-value entries from the list cache.
8217 *
8218 * @private
8219 * @name clear
8220 * @memberOf ListCache
8221 */
8222function listCacheClear() {
8223 this.__data__ = [];
8224 this.size = 0;
8225}
8226
8227module.exports = listCacheClear;
8228
8229},{}],85:[function(require,module,exports){
8230var assocIndexOf = require('./_assocIndexOf');
8231
8232/** Used for built-in method references. */
8233var arrayProto = Array.prototype;
8234
8235/** Built-in value references. */
8236var splice = arrayProto.splice;
8237
8238/**
8239 * Removes `key` and its value from the list cache.
8240 *
8241 * @private
8242 * @name delete
8243 * @memberOf ListCache
8244 * @param {string} key The key of the value to remove.
8245 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
8246 */
8247function listCacheDelete(key) {
8248 var data = this.__data__,
8249 index = assocIndexOf(data, key);
8250
8251 if (index < 0) {
8252 return false;
8253 }
8254 var lastIndex = data.length - 1;
8255 if (index == lastIndex) {
8256 data.pop();
8257 } else {
8258 splice.call(data, index, 1);
8259 }
8260 --this.size;
8261 return true;
8262}
8263
8264module.exports = listCacheDelete;
8265
8266},{"./_assocIndexOf":22}],86:[function(require,module,exports){
8267var assocIndexOf = require('./_assocIndexOf');
8268
8269/**
8270 * Gets the list cache value for `key`.
8271 *
8272 * @private
8273 * @name get
8274 * @memberOf ListCache
8275 * @param {string} key The key of the value to get.
8276 * @returns {*} Returns the entry value.
8277 */
8278function listCacheGet(key) {
8279 var data = this.__data__,
8280 index = assocIndexOf(data, key);
8281
8282 return index < 0 ? undefined : data[index][1];
8283}
8284
8285module.exports = listCacheGet;
8286
8287},{"./_assocIndexOf":22}],87:[function(require,module,exports){
8288var assocIndexOf = require('./_assocIndexOf');
8289
8290/**
8291 * Checks if a list cache value for `key` exists.
8292 *
8293 * @private
8294 * @name has
8295 * @memberOf ListCache
8296 * @param {string} key The key of the entry to check.
8297 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
8298 */
8299function listCacheHas(key) {
8300 return assocIndexOf(this.__data__, key) > -1;
8301}
8302
8303module.exports = listCacheHas;
8304
8305},{"./_assocIndexOf":22}],88:[function(require,module,exports){
8306var assocIndexOf = require('./_assocIndexOf');
8307
8308/**
8309 * Sets the list cache `key` to `value`.
8310 *
8311 * @private
8312 * @name set
8313 * @memberOf ListCache
8314 * @param {string} key The key of the value to set.
8315 * @param {*} value The value to set.
8316 * @returns {Object} Returns the list cache instance.
8317 */
8318function listCacheSet(key, value) {
8319 var data = this.__data__,
8320 index = assocIndexOf(data, key);
8321
8322 if (index < 0) {
8323 ++this.size;
8324 data.push([key, value]);
8325 } else {
8326 data[index][1] = value;
8327 }
8328 return this;
8329}
8330
8331module.exports = listCacheSet;
8332
8333},{"./_assocIndexOf":22}],89:[function(require,module,exports){
8334var Hash = require('./_Hash'),
8335 ListCache = require('./_ListCache'),
8336 Map = require('./_Map');
8337
8338/**
8339 * Removes all key-value entries from the map.
8340 *
8341 * @private
8342 * @name clear
8343 * @memberOf MapCache
8344 */
8345function mapCacheClear() {
8346 this.size = 0;
8347 this.__data__ = {
8348 'hash': new Hash,
8349 'map': new (Map || ListCache),
8350 'string': new Hash
8351 };
8352}
8353
8354module.exports = mapCacheClear;
8355
8356},{"./_Hash":4,"./_ListCache":5,"./_Map":6}],90:[function(require,module,exports){
8357var getMapData = require('./_getMapData');
8358
8359/**
8360 * Removes `key` and its value from the map.
8361 *
8362 * @private
8363 * @name delete
8364 * @memberOf MapCache
8365 * @param {string} key The key of the value to remove.
8366 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
8367 */
8368function mapCacheDelete(key) {
8369 var result = getMapData(this, key)['delete'](key);
8370 this.size -= result ? 1 : 0;
8371 return result;
8372}
8373
8374module.exports = mapCacheDelete;
8375
8376},{"./_getMapData":64}],91:[function(require,module,exports){
8377var getMapData = require('./_getMapData');
8378
8379/**
8380 * Gets the map value for `key`.
8381 *
8382 * @private
8383 * @name get
8384 * @memberOf MapCache
8385 * @param {string} key The key of the value to get.
8386 * @returns {*} Returns the entry value.
8387 */
8388function mapCacheGet(key) {
8389 return getMapData(this, key).get(key);
8390}
8391
8392module.exports = mapCacheGet;
8393
8394},{"./_getMapData":64}],92:[function(require,module,exports){
8395var getMapData = require('./_getMapData');
8396
8397/**
8398 * Checks if a map value for `key` exists.
8399 *
8400 * @private
8401 * @name has
8402 * @memberOf MapCache
8403 * @param {string} key The key of the entry to check.
8404 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
8405 */
8406function mapCacheHas(key) {
8407 return getMapData(this, key).has(key);
8408}
8409
8410module.exports = mapCacheHas;
8411
8412},{"./_getMapData":64}],93:[function(require,module,exports){
8413var getMapData = require('./_getMapData');
8414
8415/**
8416 * Sets the map `key` to `value`.
8417 *
8418 * @private
8419 * @name set
8420 * @memberOf MapCache
8421 * @param {string} key The key of the value to set.
8422 * @param {*} value The value to set.
8423 * @returns {Object} Returns the map cache instance.
8424 */
8425function mapCacheSet(key, value) {
8426 var data = getMapData(this, key),
8427 size = data.size;
8428
8429 data.set(key, value);
8430 this.size += data.size == size ? 0 : 1;
8431 return this;
8432}
8433
8434module.exports = mapCacheSet;
8435
8436},{"./_getMapData":64}],94:[function(require,module,exports){
8437/**
8438 * Converts `map` to its key-value pairs.
8439 *
8440 * @private
8441 * @param {Object} map The map to convert.
8442 * @returns {Array} Returns the key-value pairs.
8443 */
8444function mapToArray(map) {
8445 var index = -1,
8446 result = Array(map.size);
8447
8448 map.forEach(function(value, key) {
8449 result[++index] = [key, value];
8450 });
8451 return result;
8452}
8453
8454module.exports = mapToArray;
8455
8456},{}],95:[function(require,module,exports){
8457/**
8458 * A specialized version of `matchesProperty` for source values suitable
8459 * for strict equality comparisons, i.e. `===`.
8460 *
8461 * @private
8462 * @param {string} key The key of the property to get.
8463 * @param {*} srcValue The value to match.
8464 * @returns {Function} Returns the new spec function.
8465 */
8466function matchesStrictComparable(key, srcValue) {
8467 return function(object) {
8468 if (object == null) {
8469 return false;
8470 }
8471 return object[key] === srcValue &&
8472 (srcValue !== undefined || (key in Object(object)));
8473 };
8474}
8475
8476module.exports = matchesStrictComparable;
8477
8478},{}],96:[function(require,module,exports){
8479var memoize = require('./memoize');
8480
8481/** Used as the maximum memoize cache size. */
8482var MAX_MEMOIZE_SIZE = 500;
8483
8484/**
8485 * A specialized version of `_.memoize` which clears the memoized function's
8486 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
8487 *
8488 * @private
8489 * @param {Function} func The function to have its output memoized.
8490 * @returns {Function} Returns the new memoized function.
8491 */
8492function memoizeCapped(func) {
8493 var result = memoize(func, function(key) {
8494 if (cache.size === MAX_MEMOIZE_SIZE) {
8495 cache.clear();
8496 }
8497 return key;
8498 });
8499
8500 var cache = result.cache;
8501 return result;
8502}
8503
8504module.exports = memoizeCapped;
8505
8506},{"./memoize":136}],97:[function(require,module,exports){
8507var getNative = require('./_getNative');
8508
8509/* Built-in method references that are verified to be native. */
8510var nativeCreate = getNative(Object, 'create');
8511
8512module.exports = nativeCreate;
8513
8514},{"./_getNative":66}],98:[function(require,module,exports){
8515var overArg = require('./_overArg');
8516
8517/* Built-in method references for those with the same name as other `lodash` methods. */
8518var nativeKeys = overArg(Object.keys, Object);
8519
8520module.exports = nativeKeys;
8521
8522},{"./_overArg":101}],99:[function(require,module,exports){
8523var freeGlobal = require('./_freeGlobal');
8524
8525/** Detect free variable `exports`. */
8526var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
8527
8528/** Detect free variable `module`. */
8529var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
8530
8531/** Detect the popular CommonJS extension `module.exports`. */
8532var moduleExports = freeModule && freeModule.exports === freeExports;
8533
8534/** Detect free variable `process` from Node.js. */
8535var freeProcess = moduleExports && freeGlobal.process;
8536
8537/** Used to access faster Node.js helpers. */
8538var nodeUtil = (function() {
8539 try {
8540 return freeProcess && freeProcess.binding && freeProcess.binding('util');
8541 } catch (e) {}
8542}());
8543
8544module.exports = nodeUtil;
8545
8546},{"./_freeGlobal":62}],100:[function(require,module,exports){
8547/** Used for built-in method references. */
8548var objectProto = Object.prototype;
8549
8550/**
8551 * Used to resolve the
8552 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
8553 * of values.
8554 */
8555var nativeObjectToString = objectProto.toString;
8556
8557/**
8558 * Converts `value` to a string using `Object.prototype.toString`.
8559 *
8560 * @private
8561 * @param {*} value The value to convert.
8562 * @returns {string} Returns the converted string.
8563 */
8564function objectToString(value) {
8565 return nativeObjectToString.call(value);
8566}
8567
8568module.exports = objectToString;
8569
8570},{}],101:[function(require,module,exports){
8571/**
8572 * Creates a unary function that invokes `func` with its argument transformed.
8573 *
8574 * @private
8575 * @param {Function} func The function to wrap.
8576 * @param {Function} transform The argument transform.
8577 * @returns {Function} Returns the new function.
8578 */
8579function overArg(func, transform) {
8580 return function(arg) {
8581 return func(transform(arg));
8582 };
8583}
8584
8585module.exports = overArg;
8586
8587},{}],102:[function(require,module,exports){
8588var apply = require('./_apply');
8589
8590/* Built-in method references for those with the same name as other `lodash` methods. */
8591var nativeMax = Math.max;
8592
8593/**
8594 * A specialized version of `baseRest` which transforms the rest array.
8595 *
8596 * @private
8597 * @param {Function} func The function to apply a rest parameter to.
8598 * @param {number} [start=func.length-1] The start position of the rest parameter.
8599 * @param {Function} transform The rest array transform.
8600 * @returns {Function} Returns the new function.
8601 */
8602function overRest(func, start, transform) {
8603 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
8604 return function() {
8605 var args = arguments,
8606 index = -1,
8607 length = nativeMax(args.length - start, 0),
8608 array = Array(length);
8609
8610 while (++index < length) {
8611 array[index] = args[start + index];
8612 }
8613 index = -1;
8614 var otherArgs = Array(start + 1);
8615 while (++index < start) {
8616 otherArgs[index] = args[index];
8617 }
8618 otherArgs[start] = transform(array);
8619 return apply(func, this, otherArgs);
8620 };
8621}
8622
8623module.exports = overRest;
8624
8625},{"./_apply":15}],103:[function(require,module,exports){
8626var freeGlobal = require('./_freeGlobal');
8627
8628/** Detect free variable `self`. */
8629var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
8630
8631/** Used as a reference to the global object. */
8632var root = freeGlobal || freeSelf || Function('return this')();
8633
8634module.exports = root;
8635
8636},{"./_freeGlobal":62}],104:[function(require,module,exports){
8637/** Used to stand-in for `undefined` hash values. */
8638var HASH_UNDEFINED = '__lodash_hash_undefined__';
8639
8640/**
8641 * Adds `value` to the array cache.
8642 *
8643 * @private
8644 * @name add
8645 * @memberOf SetCache
8646 * @alias push
8647 * @param {*} value The value to cache.
8648 * @returns {Object} Returns the cache instance.
8649 */
8650function setCacheAdd(value) {
8651 this.__data__.set(value, HASH_UNDEFINED);
8652 return this;
8653}
8654
8655module.exports = setCacheAdd;
8656
8657},{}],105:[function(require,module,exports){
8658/**
8659 * Checks if `value` is in the array cache.
8660 *
8661 * @private
8662 * @name has
8663 * @memberOf SetCache
8664 * @param {*} value The value to search for.
8665 * @returns {number} Returns `true` if `value` is found, else `false`.
8666 */
8667function setCacheHas(value) {
8668 return this.__data__.has(value);
8669}
8670
8671module.exports = setCacheHas;
8672
8673},{}],106:[function(require,module,exports){
8674/**
8675 * Converts `set` to an array of its values.
8676 *
8677 * @private
8678 * @param {Object} set The set to convert.
8679 * @returns {Array} Returns the values.
8680 */
8681function setToArray(set) {
8682 var index = -1,
8683 result = Array(set.size);
8684
8685 set.forEach(function(value) {
8686 result[++index] = value;
8687 });
8688 return result;
8689}
8690
8691module.exports = setToArray;
8692
8693},{}],107:[function(require,module,exports){
8694var baseSetToString = require('./_baseSetToString'),
8695 shortOut = require('./_shortOut');
8696
8697/**
8698 * Sets the `toString` method of `func` to return `string`.
8699 *
8700 * @private
8701 * @param {Function} func The function to modify.
8702 * @param {Function} string The `toString` result.
8703 * @returns {Function} Returns `func`.
8704 */
8705var setToString = shortOut(baseSetToString);
8706
8707module.exports = setToString;
8708
8709},{"./_baseSetToString":48,"./_shortOut":108}],108:[function(require,module,exports){
8710/** Used to detect hot functions by number of calls within a span of milliseconds. */
8711var HOT_COUNT = 800,
8712 HOT_SPAN = 16;
8713
8714/* Built-in method references for those with the same name as other `lodash` methods. */
8715var nativeNow = Date.now;
8716
8717/**
8718 * Creates a function that'll short out and invoke `identity` instead
8719 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
8720 * milliseconds.
8721 *
8722 * @private
8723 * @param {Function} func The function to restrict.
8724 * @returns {Function} Returns the new shortable function.
8725 */
8726function shortOut(func) {
8727 var count = 0,
8728 lastCalled = 0;
8729
8730 return function() {
8731 var stamp = nativeNow(),
8732 remaining = HOT_SPAN - (stamp - lastCalled);
8733
8734 lastCalled = stamp;
8735 if (remaining > 0) {
8736 if (++count >= HOT_COUNT) {
8737 return arguments[0];
8738 }
8739 } else {
8740 count = 0;
8741 }
8742 return func.apply(undefined, arguments);
8743 };
8744}
8745
8746module.exports = shortOut;
8747
8748},{}],109:[function(require,module,exports){
8749var ListCache = require('./_ListCache');
8750
8751/**
8752 * Removes all key-value entries from the stack.
8753 *
8754 * @private
8755 * @name clear
8756 * @memberOf Stack
8757 */
8758function stackClear() {
8759 this.__data__ = new ListCache;
8760 this.size = 0;
8761}
8762
8763module.exports = stackClear;
8764
8765},{"./_ListCache":5}],110:[function(require,module,exports){
8766/**
8767 * Removes `key` and its value from the stack.
8768 *
8769 * @private
8770 * @name delete
8771 * @memberOf Stack
8772 * @param {string} key The key of the value to remove.
8773 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
8774 */
8775function stackDelete(key) {
8776 var data = this.__data__,
8777 result = data['delete'](key);
8778
8779 this.size = data.size;
8780 return result;
8781}
8782
8783module.exports = stackDelete;
8784
8785},{}],111:[function(require,module,exports){
8786/**
8787 * Gets the stack value for `key`.
8788 *
8789 * @private
8790 * @name get
8791 * @memberOf Stack
8792 * @param {string} key The key of the value to get.
8793 * @returns {*} Returns the entry value.
8794 */
8795function stackGet(key) {
8796 return this.__data__.get(key);
8797}
8798
8799module.exports = stackGet;
8800
8801},{}],112:[function(require,module,exports){
8802/**
8803 * Checks if a stack value for `key` exists.
8804 *
8805 * @private
8806 * @name has
8807 * @memberOf Stack
8808 * @param {string} key The key of the entry to check.
8809 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
8810 */
8811function stackHas(key) {
8812 return this.__data__.has(key);
8813}
8814
8815module.exports = stackHas;
8816
8817},{}],113:[function(require,module,exports){
8818var ListCache = require('./_ListCache'),
8819 Map = require('./_Map'),
8820 MapCache = require('./_MapCache');
8821
8822/** Used as the size to enable large array optimizations. */
8823var LARGE_ARRAY_SIZE = 200;
8824
8825/**
8826 * Sets the stack `key` to `value`.
8827 *
8828 * @private
8829 * @name set
8830 * @memberOf Stack
8831 * @param {string} key The key of the value to set.
8832 * @param {*} value The value to set.
8833 * @returns {Object} Returns the stack cache instance.
8834 */
8835function stackSet(key, value) {
8836 var data = this.__data__;
8837 if (data instanceof ListCache) {
8838 var pairs = data.__data__;
8839 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
8840 pairs.push([key, value]);
8841 this.size = ++data.size;
8842 return this;
8843 }
8844 data = this.__data__ = new MapCache(pairs);
8845 }
8846 data.set(key, value);
8847 this.size = data.size;
8848 return this;
8849}
8850
8851module.exports = stackSet;
8852
8853},{"./_ListCache":5,"./_Map":6,"./_MapCache":7}],114:[function(require,module,exports){
8854var memoizeCapped = require('./_memoizeCapped');
8855
8856/** Used to match property names within property paths. */
8857var reLeadingDot = /^\./,
8858 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
8859
8860/** Used to match backslashes in property paths. */
8861var reEscapeChar = /\\(\\)?/g;
8862
8863/**
8864 * Converts `string` to a property path array.
8865 *
8866 * @private
8867 * @param {string} string The string to convert.
8868 * @returns {Array} Returns the property path array.
8869 */
8870var stringToPath = memoizeCapped(function(string) {
8871 var result = [];
8872 if (reLeadingDot.test(string)) {
8873 result.push('');
8874 }
8875 string.replace(rePropName, function(match, number, quote, string) {
8876 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
8877 });
8878 return result;
8879});
8880
8881module.exports = stringToPath;
8882
8883},{"./_memoizeCapped":96}],115:[function(require,module,exports){
8884var isSymbol = require('./isSymbol');
8885
8886/** Used as references for various `Number` constants. */
8887var INFINITY = 1 / 0;
8888
8889/**
8890 * Converts `value` to a string key if it's not a string or symbol.
8891 *
8892 * @private
8893 * @param {*} value The value to inspect.
8894 * @returns {string|symbol} Returns the key.
8895 */
8896function toKey(value) {
8897 if (typeof value == 'string' || isSymbol(value)) {
8898 return value;
8899 }
8900 var result = (value + '');
8901 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
8902}
8903
8904module.exports = toKey;
8905
8906},{"./isSymbol":132}],116:[function(require,module,exports){
8907/** Used for built-in method references. */
8908var funcProto = Function.prototype;
8909
8910/** Used to resolve the decompiled source of functions. */
8911var funcToString = funcProto.toString;
8912
8913/**
8914 * Converts `func` to its source code.
8915 *
8916 * @private
8917 * @param {Function} func The function to convert.
8918 * @returns {string} Returns the source code.
8919 */
8920function toSource(func) {
8921 if (func != null) {
8922 try {
8923 return funcToString.call(func);
8924 } catch (e) {}
8925 try {
8926 return (func + '');
8927 } catch (e) {}
8928 }
8929 return '';
8930}
8931
8932module.exports = toSource;
8933
8934},{}],117:[function(require,module,exports){
8935var toInteger = require('./toInteger');
8936
8937/** Error message constants. */
8938var FUNC_ERROR_TEXT = 'Expected a function';
8939
8940/**
8941 * Creates a function that invokes `func`, with the `this` binding and arguments
8942 * of the created function, while it's called less than `n` times. Subsequent
8943 * calls to the created function return the result of the last `func` invocation.
8944 *
8945 * @static
8946 * @memberOf _
8947 * @since 3.0.0
8948 * @category Function
8949 * @param {number} n The number of calls at which `func` is no longer invoked.
8950 * @param {Function} func The function to restrict.
8951 * @returns {Function} Returns the new restricted function.
8952 * @example
8953 *
8954 * jQuery(element).on('click', _.before(5, addContactToList));
8955 * // => Allows adding up to 4 contacts to the list.
8956 */
8957function before(n, func) {
8958 var result;
8959 if (typeof func != 'function') {
8960 throw new TypeError(FUNC_ERROR_TEXT);
8961 }
8962 n = toInteger(n);
8963 return function() {
8964 if (--n > 0) {
8965 result = func.apply(this, arguments);
8966 }
8967 if (n <= 1) {
8968 func = undefined;
8969 }
8970 return result;
8971 };
8972}
8973
8974module.exports = before;
8975
8976},{"./toInteger":143}],118:[function(require,module,exports){
8977/**
8978 * Creates a function that returns `value`.
8979 *
8980 * @static
8981 * @memberOf _
8982 * @since 2.4.0
8983 * @category Util
8984 * @param {*} value The value to return from the new function.
8985 * @returns {Function} Returns the new constant function.
8986 * @example
8987 *
8988 * var objects = _.times(2, _.constant({ 'a': 1 }));
8989 *
8990 * console.log(objects);
8991 * // => [{ 'a': 1 }, { 'a': 1 }]
8992 *
8993 * console.log(objects[0] === objects[1]);
8994 * // => true
8995 */
8996function constant(value) {
8997 return function() {
8998 return value;
8999 };
9000}
9001
9002module.exports = constant;
9003
9004},{}],119:[function(require,module,exports){
9005/**
9006 * Performs a
9007 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9008 * comparison between two values to determine if they are equivalent.
9009 *
9010 * @static
9011 * @memberOf _
9012 * @since 4.0.0
9013 * @category Lang
9014 * @param {*} value The value to compare.
9015 * @param {*} other The other value to compare.
9016 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
9017 * @example
9018 *
9019 * var object = { 'a': 1 };
9020 * var other = { 'a': 1 };
9021 *
9022 * _.eq(object, object);
9023 * // => true
9024 *
9025 * _.eq(object, other);
9026 * // => false
9027 *
9028 * _.eq('a', 'a');
9029 * // => true
9030 *
9031 * _.eq('a', Object('a'));
9032 * // => false
9033 *
9034 * _.eq(NaN, NaN);
9035 * // => true
9036 */
9037function eq(value, other) {
9038 return value === other || (value !== value && other !== other);
9039}
9040
9041module.exports = eq;
9042
9043},{}],120:[function(require,module,exports){
9044var baseFlatten = require('./_baseFlatten');
9045
9046/**
9047 * Flattens `array` a single level deep.
9048 *
9049 * @static
9050 * @memberOf _
9051 * @since 0.1.0
9052 * @category Array
9053 * @param {Array} array The array to flatten.
9054 * @returns {Array} Returns the new flattened array.
9055 * @example
9056 *
9057 * _.flatten([1, [2, [3, [4]], 5]]);
9058 * // => [1, 2, [3, [4]], 5]
9059 */
9060function flatten(array) {
9061 var length = array == null ? 0 : array.length;
9062 return length ? baseFlatten(array, 1) : [];
9063}
9064
9065module.exports = flatten;
9066
9067},{"./_baseFlatten":25}],121:[function(require,module,exports){
9068var baseGet = require('./_baseGet');
9069
9070/**
9071 * Gets the value at `path` of `object`. If the resolved value is
9072 * `undefined`, the `defaultValue` is returned in its place.
9073 *
9074 * @static
9075 * @memberOf _
9076 * @since 3.7.0
9077 * @category Object
9078 * @param {Object} object The object to query.
9079 * @param {Array|string} path The path of the property to get.
9080 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
9081 * @returns {*} Returns the resolved value.
9082 * @example
9083 *
9084 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
9085 *
9086 * _.get(object, 'a[0].b.c');
9087 * // => 3
9088 *
9089 * _.get(object, ['a', '0', 'b', 'c']);
9090 * // => 3
9091 *
9092 * _.get(object, 'a.b.c', 'default');
9093 * // => 'default'
9094 */
9095function get(object, path, defaultValue) {
9096 var result = object == null ? undefined : baseGet(object, path);
9097 return result === undefined ? defaultValue : result;
9098}
9099
9100module.exports = get;
9101
9102},{"./_baseGet":28}],122:[function(require,module,exports){
9103var baseHasIn = require('./_baseHasIn'),
9104 hasPath = require('./_hasPath');
9105
9106/**
9107 * Checks if `path` is a direct or inherited property of `object`.
9108 *
9109 * @static
9110 * @memberOf _
9111 * @since 4.0.0
9112 * @category Object
9113 * @param {Object} object The object to query.
9114 * @param {Array|string} path The path to check.
9115 * @returns {boolean} Returns `true` if `path` exists, else `false`.
9116 * @example
9117 *
9118 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
9119 *
9120 * _.hasIn(object, 'a');
9121 * // => true
9122 *
9123 * _.hasIn(object, 'a.b');
9124 * // => true
9125 *
9126 * _.hasIn(object, ['a', 'b']);
9127 * // => true
9128 *
9129 * _.hasIn(object, 'b');
9130 * // => false
9131 */
9132function hasIn(object, path) {
9133 return object != null && hasPath(object, path, baseHasIn);
9134}
9135
9136module.exports = hasIn;
9137
9138},{"./_baseHasIn":31,"./_hasPath":71}],123:[function(require,module,exports){
9139/**
9140 * This method returns the first argument it receives.
9141 *
9142 * @static
9143 * @since 0.1.0
9144 * @memberOf _
9145 * @category Util
9146 * @param {*} value Any value.
9147 * @returns {*} Returns `value`.
9148 * @example
9149 *
9150 * var object = { 'a': 1 };
9151 *
9152 * console.log(_.identity(object) === object);
9153 * // => true
9154 */
9155function identity(value) {
9156 return value;
9157}
9158
9159module.exports = identity;
9160
9161},{}],124:[function(require,module,exports){
9162var baseIsArguments = require('./_baseIsArguments'),
9163 isObjectLike = require('./isObjectLike');
9164
9165/** Used for built-in method references. */
9166var objectProto = Object.prototype;
9167
9168/** Used to check objects for own properties. */
9169var hasOwnProperty = objectProto.hasOwnProperty;
9170
9171/** Built-in value references. */
9172var propertyIsEnumerable = objectProto.propertyIsEnumerable;
9173
9174/**
9175 * Checks if `value` is likely an `arguments` object.
9176 *
9177 * @static
9178 * @memberOf _
9179 * @since 0.1.0
9180 * @category Lang
9181 * @param {*} value The value to check.
9182 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
9183 * else `false`.
9184 * @example
9185 *
9186 * _.isArguments(function() { return arguments; }());
9187 * // => true
9188 *
9189 * _.isArguments([1, 2, 3]);
9190 * // => false
9191 */
9192var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
9193 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
9194 !propertyIsEnumerable.call(value, 'callee');
9195};
9196
9197module.exports = isArguments;
9198
9199},{"./_baseIsArguments":32,"./isObjectLike":131}],125:[function(require,module,exports){
9200/**
9201 * Checks if `value` is classified as an `Array` object.
9202 *
9203 * @static
9204 * @memberOf _
9205 * @since 0.1.0
9206 * @category Lang
9207 * @param {*} value The value to check.
9208 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
9209 * @example
9210 *
9211 * _.isArray([1, 2, 3]);
9212 * // => true
9213 *
9214 * _.isArray(document.body.children);
9215 * // => false
9216 *
9217 * _.isArray('abc');
9218 * // => false
9219 *
9220 * _.isArray(_.noop);
9221 * // => false
9222 */
9223var isArray = Array.isArray;
9224
9225module.exports = isArray;
9226
9227},{}],126:[function(require,module,exports){
9228var isFunction = require('./isFunction'),
9229 isLength = require('./isLength');
9230
9231/**
9232 * Checks if `value` is array-like. A value is considered array-like if it's
9233 * not a function and has a `value.length` that's an integer greater than or
9234 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
9235 *
9236 * @static
9237 * @memberOf _
9238 * @since 4.0.0
9239 * @category Lang
9240 * @param {*} value The value to check.
9241 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
9242 * @example
9243 *
9244 * _.isArrayLike([1, 2, 3]);
9245 * // => true
9246 *
9247 * _.isArrayLike(document.body.children);
9248 * // => true
9249 *
9250 * _.isArrayLike('abc');
9251 * // => true
9252 *
9253 * _.isArrayLike(_.noop);
9254 * // => false
9255 */
9256function isArrayLike(value) {
9257 return value != null && isLength(value.length) && !isFunction(value);
9258}
9259
9260module.exports = isArrayLike;
9261
9262},{"./isFunction":128,"./isLength":129}],127:[function(require,module,exports){
9263var root = require('./_root'),
9264 stubFalse = require('./stubFalse');
9265
9266/** Detect free variable `exports`. */
9267var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
9268
9269/** Detect free variable `module`. */
9270var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
9271
9272/** Detect the popular CommonJS extension `module.exports`. */
9273var moduleExports = freeModule && freeModule.exports === freeExports;
9274
9275/** Built-in value references. */
9276var Buffer = moduleExports ? root.Buffer : undefined;
9277
9278/* Built-in method references for those with the same name as other `lodash` methods. */
9279var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
9280
9281/**
9282 * Checks if `value` is a buffer.
9283 *
9284 * @static
9285 * @memberOf _
9286 * @since 4.3.0
9287 * @category Lang
9288 * @param {*} value The value to check.
9289 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
9290 * @example
9291 *
9292 * _.isBuffer(new Buffer(2));
9293 * // => true
9294 *
9295 * _.isBuffer(new Uint8Array(2));
9296 * // => false
9297 */
9298var isBuffer = nativeIsBuffer || stubFalse;
9299
9300module.exports = isBuffer;
9301
9302},{"./_root":103,"./stubFalse":141}],128:[function(require,module,exports){
9303var baseGetTag = require('./_baseGetTag'),
9304 isObject = require('./isObject');
9305
9306/** `Object#toString` result references. */
9307var asyncTag = '[object AsyncFunction]',
9308 funcTag = '[object Function]',
9309 genTag = '[object GeneratorFunction]',
9310 proxyTag = '[object Proxy]';
9311
9312/**
9313 * Checks if `value` is classified as a `Function` object.
9314 *
9315 * @static
9316 * @memberOf _
9317 * @since 0.1.0
9318 * @category Lang
9319 * @param {*} value The value to check.
9320 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
9321 * @example
9322 *
9323 * _.isFunction(_);
9324 * // => true
9325 *
9326 * _.isFunction(/abc/);
9327 * // => false
9328 */
9329function isFunction(value) {
9330 if (!isObject(value)) {
9331 return false;
9332 }
9333 // The use of `Object#toString` avoids issues with the `typeof` operator
9334 // in Safari 9 which returns 'object' for typed arrays and other constructors.
9335 var tag = baseGetTag(value);
9336 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
9337}
9338
9339module.exports = isFunction;
9340
9341},{"./_baseGetTag":30,"./isObject":130}],129:[function(require,module,exports){
9342/** Used as references for various `Number` constants. */
9343var MAX_SAFE_INTEGER = 9007199254740991;
9344
9345/**
9346 * Checks if `value` is a valid array-like length.
9347 *
9348 * **Note:** This method is loosely based on
9349 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
9350 *
9351 * @static
9352 * @memberOf _
9353 * @since 4.0.0
9354 * @category Lang
9355 * @param {*} value The value to check.
9356 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
9357 * @example
9358 *
9359 * _.isLength(3);
9360 * // => true
9361 *
9362 * _.isLength(Number.MIN_VALUE);
9363 * // => false
9364 *
9365 * _.isLength(Infinity);
9366 * // => false
9367 *
9368 * _.isLength('3');
9369 * // => false
9370 */
9371function isLength(value) {
9372 return typeof value == 'number' &&
9373 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
9374}
9375
9376module.exports = isLength;
9377
9378},{}],130:[function(require,module,exports){
9379/**
9380 * Checks if `value` is the
9381 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
9382 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
9383 *
9384 * @static
9385 * @memberOf _
9386 * @since 0.1.0
9387 * @category Lang
9388 * @param {*} value The value to check.
9389 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
9390 * @example
9391 *
9392 * _.isObject({});
9393 * // => true
9394 *
9395 * _.isObject([1, 2, 3]);
9396 * // => true
9397 *
9398 * _.isObject(_.noop);
9399 * // => true
9400 *
9401 * _.isObject(null);
9402 * // => false
9403 */
9404function isObject(value) {
9405 var type = typeof value;
9406 return value != null && (type == 'object' || type == 'function');
9407}
9408
9409module.exports = isObject;
9410
9411},{}],131:[function(require,module,exports){
9412/**
9413 * Checks if `value` is object-like. A value is object-like if it's not `null`
9414 * and has a `typeof` result of "object".
9415 *
9416 * @static
9417 * @memberOf _
9418 * @since 4.0.0
9419 * @category Lang
9420 * @param {*} value The value to check.
9421 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
9422 * @example
9423 *
9424 * _.isObjectLike({});
9425 * // => true
9426 *
9427 * _.isObjectLike([1, 2, 3]);
9428 * // => true
9429 *
9430 * _.isObjectLike(_.noop);
9431 * // => false
9432 *
9433 * _.isObjectLike(null);
9434 * // => false
9435 */
9436function isObjectLike(value) {
9437 return value != null && typeof value == 'object';
9438}
9439
9440module.exports = isObjectLike;
9441
9442},{}],132:[function(require,module,exports){
9443var baseGetTag = require('./_baseGetTag'),
9444 isObjectLike = require('./isObjectLike');
9445
9446/** `Object#toString` result references. */
9447var symbolTag = '[object Symbol]';
9448
9449/**
9450 * Checks if `value` is classified as a `Symbol` primitive or object.
9451 *
9452 * @static
9453 * @memberOf _
9454 * @since 4.0.0
9455 * @category Lang
9456 * @param {*} value The value to check.
9457 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
9458 * @example
9459 *
9460 * _.isSymbol(Symbol.iterator);
9461 * // => true
9462 *
9463 * _.isSymbol('abc');
9464 * // => false
9465 */
9466function isSymbol(value) {
9467 return typeof value == 'symbol' ||
9468 (isObjectLike(value) && baseGetTag(value) == symbolTag);
9469}
9470
9471module.exports = isSymbol;
9472
9473},{"./_baseGetTag":30,"./isObjectLike":131}],133:[function(require,module,exports){
9474var baseIsTypedArray = require('./_baseIsTypedArray'),
9475 baseUnary = require('./_baseUnary'),
9476 nodeUtil = require('./_nodeUtil');
9477
9478/* Node.js helper references. */
9479var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
9480
9481/**
9482 * Checks if `value` is classified as a typed array.
9483 *
9484 * @static
9485 * @memberOf _
9486 * @since 3.0.0
9487 * @category Lang
9488 * @param {*} value The value to check.
9489 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
9490 * @example
9491 *
9492 * _.isTypedArray(new Uint8Array);
9493 * // => true
9494 *
9495 * _.isTypedArray([]);
9496 * // => false
9497 */
9498var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
9499
9500module.exports = isTypedArray;
9501
9502},{"./_baseIsTypedArray":37,"./_baseUnary":51,"./_nodeUtil":99}],134:[function(require,module,exports){
9503var arrayLikeKeys = require('./_arrayLikeKeys'),
9504 baseKeys = require('./_baseKeys'),
9505 isArrayLike = require('./isArrayLike');
9506
9507/**
9508 * Creates an array of the own enumerable property names of `object`.
9509 *
9510 * **Note:** Non-object values are coerced to objects. See the
9511 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
9512 * for more details.
9513 *
9514 * @static
9515 * @since 0.1.0
9516 * @memberOf _
9517 * @category Object
9518 * @param {Object} object The object to query.
9519 * @returns {Array} Returns the array of property names.
9520 * @example
9521 *
9522 * function Foo() {
9523 * this.a = 1;
9524 * this.b = 2;
9525 * }
9526 *
9527 * Foo.prototype.c = 3;
9528 *
9529 * _.keys(new Foo);
9530 * // => ['a', 'b'] (iteration order is not guaranteed)
9531 *
9532 * _.keys('hi');
9533 * // => ['0', '1']
9534 */
9535function keys(object) {
9536 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
9537}
9538
9539module.exports = keys;
9540
9541},{"./_arrayLikeKeys":17,"./_baseKeys":39,"./isArrayLike":126}],135:[function(require,module,exports){
9542var arrayMap = require('./_arrayMap'),
9543 baseIteratee = require('./_baseIteratee'),
9544 baseMap = require('./_baseMap'),
9545 isArray = require('./isArray');
9546
9547/**
9548 * Creates an array of values by running each element in `collection` thru
9549 * `iteratee`. The iteratee is invoked with three arguments:
9550 * (value, index|key, collection).
9551 *
9552 * Many lodash methods are guarded to work as iteratees for methods like
9553 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
9554 *
9555 * The guarded methods are:
9556 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
9557 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
9558 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
9559 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
9560 *
9561 * @static
9562 * @memberOf _
9563 * @since 0.1.0
9564 * @category Collection
9565 * @param {Array|Object} collection The collection to iterate over.
9566 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
9567 * @returns {Array} Returns the new mapped array.
9568 * @example
9569 *
9570 * function square(n) {
9571 * return n * n;
9572 * }
9573 *
9574 * _.map([4, 8], square);
9575 * // => [16, 64]
9576 *
9577 * _.map({ 'a': 4, 'b': 8 }, square);
9578 * // => [16, 64] (iteration order is not guaranteed)
9579 *
9580 * var users = [
9581 * { 'user': 'barney' },
9582 * { 'user': 'fred' }
9583 * ];
9584 *
9585 * // The `_.property` iteratee shorthand.
9586 * _.map(users, 'user');
9587 * // => ['barney', 'fred']
9588 */
9589function map(collection, iteratee) {
9590 var func = isArray(collection) ? arrayMap : baseMap;
9591 return func(collection, baseIteratee(iteratee, 3));
9592}
9593
9594module.exports = map;
9595
9596},{"./_arrayMap":18,"./_baseIteratee":38,"./_baseMap":40,"./isArray":125}],136:[function(require,module,exports){
9597var MapCache = require('./_MapCache');
9598
9599/** Error message constants. */
9600var FUNC_ERROR_TEXT = 'Expected a function';
9601
9602/**
9603 * Creates a function that memoizes the result of `func`. If `resolver` is
9604 * provided, it determines the cache key for storing the result based on the
9605 * arguments provided to the memoized function. By default, the first argument
9606 * provided to the memoized function is used as the map cache key. The `func`
9607 * is invoked with the `this` binding of the memoized function.
9608 *
9609 * **Note:** The cache is exposed as the `cache` property on the memoized
9610 * function. Its creation may be customized by replacing the `_.memoize.Cache`
9611 * constructor with one whose instances implement the
9612 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
9613 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
9614 *
9615 * @static
9616 * @memberOf _
9617 * @since 0.1.0
9618 * @category Function
9619 * @param {Function} func The function to have its output memoized.
9620 * @param {Function} [resolver] The function to resolve the cache key.
9621 * @returns {Function} Returns the new memoized function.
9622 * @example
9623 *
9624 * var object = { 'a': 1, 'b': 2 };
9625 * var other = { 'c': 3, 'd': 4 };
9626 *
9627 * var values = _.memoize(_.values);
9628 * values(object);
9629 * // => [1, 2]
9630 *
9631 * values(other);
9632 * // => [3, 4]
9633 *
9634 * object.a = 2;
9635 * values(object);
9636 * // => [1, 2]
9637 *
9638 * // Modify the result cache.
9639 * values.cache.set(object, ['a', 'b']);
9640 * values(object);
9641 * // => ['a', 'b']
9642 *
9643 * // Replace `_.memoize.Cache`.
9644 * _.memoize.Cache = WeakMap;
9645 */
9646function memoize(func, resolver) {
9647 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
9648 throw new TypeError(FUNC_ERROR_TEXT);
9649 }
9650 var memoized = function() {
9651 var args = arguments,
9652 key = resolver ? resolver.apply(this, args) : args[0],
9653 cache = memoized.cache;
9654
9655 if (cache.has(key)) {
9656 return cache.get(key);
9657 }
9658 var result = func.apply(this, args);
9659 memoized.cache = cache.set(key, result) || cache;
9660 return result;
9661 };
9662 memoized.cache = new (memoize.Cache || MapCache);
9663 return memoized;
9664}
9665
9666// Expose `MapCache`.
9667memoize.Cache = MapCache;
9668
9669module.exports = memoize;
9670
9671},{"./_MapCache":7}],137:[function(require,module,exports){
9672var before = require('./before');
9673
9674/**
9675 * Creates a function that is restricted to invoking `func` once. Repeat calls
9676 * to the function return the value of the first invocation. The `func` is
9677 * invoked with the `this` binding and arguments of the created function.
9678 *
9679 * @static
9680 * @memberOf _
9681 * @since 0.1.0
9682 * @category Function
9683 * @param {Function} func The function to restrict.
9684 * @returns {Function} Returns the new restricted function.
9685 * @example
9686 *
9687 * var initialize = _.once(createApplication);
9688 * initialize();
9689 * initialize();
9690 * // => `createApplication` is invoked once
9691 */
9692function once(func) {
9693 return before(2, func);
9694}
9695
9696module.exports = once;
9697
9698},{"./before":117}],138:[function(require,module,exports){
9699var basePick = require('./_basePick'),
9700 flatRest = require('./_flatRest');
9701
9702/**
9703 * Creates an object composed of the picked `object` properties.
9704 *
9705 * @static
9706 * @since 0.1.0
9707 * @memberOf _
9708 * @category Object
9709 * @param {Object} object The source object.
9710 * @param {...(string|string[])} [paths] The property paths to pick.
9711 * @returns {Object} Returns the new object.
9712 * @example
9713 *
9714 * var object = { 'a': 1, 'b': '2', 'c': 3 };
9715 *
9716 * _.pick(object, ['a', 'c']);
9717 * // => { 'a': 1, 'c': 3 }
9718 */
9719var pick = flatRest(function(object, paths) {
9720 return object == null ? {} : basePick(object, paths);
9721});
9722
9723module.exports = pick;
9724
9725},{"./_basePick":43,"./_flatRest":61}],139:[function(require,module,exports){
9726var baseProperty = require('./_baseProperty'),
9727 basePropertyDeep = require('./_basePropertyDeep'),
9728 isKey = require('./_isKey'),
9729 toKey = require('./_toKey');
9730
9731/**
9732 * Creates a function that returns the value at `path` of a given object.
9733 *
9734 * @static
9735 * @memberOf _
9736 * @since 2.4.0
9737 * @category Util
9738 * @param {Array|string} path The path of the property to get.
9739 * @returns {Function} Returns the new accessor function.
9740 * @example
9741 *
9742 * var objects = [
9743 * { 'a': { 'b': 2 } },
9744 * { 'a': { 'b': 1 } }
9745 * ];
9746 *
9747 * _.map(objects, _.property('a.b'));
9748 * // => [2, 1]
9749 *
9750 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
9751 * // => [1, 2]
9752 */
9753function property(path) {
9754 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
9755}
9756
9757module.exports = property;
9758
9759},{"./_baseProperty":45,"./_basePropertyDeep":46,"./_isKey":79,"./_toKey":115}],140:[function(require,module,exports){
9760/**
9761 * This method returns a new empty array.
9762 *
9763 * @static
9764 * @memberOf _
9765 * @since 4.13.0
9766 * @category Util
9767 * @returns {Array} Returns the new empty array.
9768 * @example
9769 *
9770 * var arrays = _.times(2, _.stubArray);
9771 *
9772 * console.log(arrays);
9773 * // => [[], []]
9774 *
9775 * console.log(arrays[0] === arrays[1]);
9776 * // => false
9777 */
9778function stubArray() {
9779 return [];
9780}
9781
9782module.exports = stubArray;
9783
9784},{}],141:[function(require,module,exports){
9785/**
9786 * This method returns `false`.
9787 *
9788 * @static
9789 * @memberOf _
9790 * @since 4.13.0
9791 * @category Util
9792 * @returns {boolean} Returns `false`.
9793 * @example
9794 *
9795 * _.times(2, _.stubFalse);
9796 * // => [false, false]
9797 */
9798function stubFalse() {
9799 return false;
9800}
9801
9802module.exports = stubFalse;
9803
9804},{}],142:[function(require,module,exports){
9805var toNumber = require('./toNumber');
9806
9807/** Used as references for various `Number` constants. */
9808var INFINITY = 1 / 0,
9809 MAX_INTEGER = 1.7976931348623157e+308;
9810
9811/**
9812 * Converts `value` to a finite number.
9813 *
9814 * @static
9815 * @memberOf _
9816 * @since 4.12.0
9817 * @category Lang
9818 * @param {*} value The value to convert.
9819 * @returns {number} Returns the converted number.
9820 * @example
9821 *
9822 * _.toFinite(3.2);
9823 * // => 3.2
9824 *
9825 * _.toFinite(Number.MIN_VALUE);
9826 * // => 5e-324
9827 *
9828 * _.toFinite(Infinity);
9829 * // => 1.7976931348623157e+308
9830 *
9831 * _.toFinite('3.2');
9832 * // => 3.2
9833 */
9834function toFinite(value) {
9835 if (!value) {
9836 return value === 0 ? value : 0;
9837 }
9838 value = toNumber(value);
9839 if (value === INFINITY || value === -INFINITY) {
9840 var sign = (value < 0 ? -1 : 1);
9841 return sign * MAX_INTEGER;
9842 }
9843 return value === value ? value : 0;
9844}
9845
9846module.exports = toFinite;
9847
9848},{"./toNumber":144}],143:[function(require,module,exports){
9849var toFinite = require('./toFinite');
9850
9851/**
9852 * Converts `value` to an integer.
9853 *
9854 * **Note:** This method is loosely based on
9855 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
9856 *
9857 * @static
9858 * @memberOf _
9859 * @since 4.0.0
9860 * @category Lang
9861 * @param {*} value The value to convert.
9862 * @returns {number} Returns the converted integer.
9863 * @example
9864 *
9865 * _.toInteger(3.2);
9866 * // => 3
9867 *
9868 * _.toInteger(Number.MIN_VALUE);
9869 * // => 0
9870 *
9871 * _.toInteger(Infinity);
9872 * // => 1.7976931348623157e+308
9873 *
9874 * _.toInteger('3.2');
9875 * // => 3
9876 */
9877function toInteger(value) {
9878 var result = toFinite(value),
9879 remainder = result % 1;
9880
9881 return result === result ? (remainder ? result - remainder : result) : 0;
9882}
9883
9884module.exports = toInteger;
9885
9886},{"./toFinite":142}],144:[function(require,module,exports){
9887var isObject = require('./isObject'),
9888 isSymbol = require('./isSymbol');
9889
9890/** Used as references for various `Number` constants. */
9891var NAN = 0 / 0;
9892
9893/** Used to match leading and trailing whitespace. */
9894var reTrim = /^\s+|\s+$/g;
9895
9896/** Used to detect bad signed hexadecimal string values. */
9897var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
9898
9899/** Used to detect binary string values. */
9900var reIsBinary = /^0b[01]+$/i;
9901
9902/** Used to detect octal string values. */
9903var reIsOctal = /^0o[0-7]+$/i;
9904
9905/** Built-in method references without a dependency on `root`. */
9906var freeParseInt = parseInt;
9907
9908/**
9909 * Converts `value` to a number.
9910 *
9911 * @static
9912 * @memberOf _
9913 * @since 4.0.0
9914 * @category Lang
9915 * @param {*} value The value to process.
9916 * @returns {number} Returns the number.
9917 * @example
9918 *
9919 * _.toNumber(3.2);
9920 * // => 3.2
9921 *
9922 * _.toNumber(Number.MIN_VALUE);
9923 * // => 5e-324
9924 *
9925 * _.toNumber(Infinity);
9926 * // => Infinity
9927 *
9928 * _.toNumber('3.2');
9929 * // => 3.2
9930 */
9931function toNumber(value) {
9932 if (typeof value == 'number') {
9933 return value;
9934 }
9935 if (isSymbol(value)) {
9936 return NAN;
9937 }
9938 if (isObject(value)) {
9939 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
9940 value = isObject(other) ? (other + '') : other;
9941 }
9942 if (typeof value != 'string') {
9943 return value === 0 ? value : +value;
9944 }
9945 value = value.replace(reTrim, '');
9946 var isBinary = reIsBinary.test(value);
9947 return (isBinary || reIsOctal.test(value))
9948 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
9949 : (reIsBadHex.test(value) ? NAN : +value);
9950}
9951
9952module.exports = toNumber;
9953
9954},{"./isObject":130,"./isSymbol":132}],145:[function(require,module,exports){
9955var baseToString = require('./_baseToString');
9956
9957/**
9958 * Converts `value` to a string. An empty string is returned for `null`
9959 * and `undefined` values. The sign of `-0` is preserved.
9960 *
9961 * @static
9962 * @memberOf _
9963 * @since 4.0.0
9964 * @category Lang
9965 * @param {*} value The value to convert.
9966 * @returns {string} Returns the converted string.
9967 * @example
9968 *
9969 * _.toString(null);
9970 * // => ''
9971 *
9972 * _.toString(-0);
9973 * // => '-0'
9974 *
9975 * _.toString([1, 2, 3]);
9976 * // => '1,2,3'
9977 */
9978function toString(value) {
9979 return value == null ? '' : baseToString(value);
9980}
9981
9982module.exports = toString;
9983
9984},{"./_baseToString":50}],146:[function(require,module,exports){
9985// shim for using process in browser
9986var process = module.exports = {};
9987
9988// cached from whatever global is present so that test runners that stub it
9989// don't break things. But we need to wrap it in a try catch in case it is
9990// wrapped in strict mode code which doesn't define any globals. It's inside a
9991// function because try/catches deoptimize in certain engines.
9992
9993var cachedSetTimeout;
9994var cachedClearTimeout;
9995
9996function defaultSetTimout() {
9997 throw new Error('setTimeout has not been defined');
9998}
9999function defaultClearTimeout () {
10000 throw new Error('clearTimeout has not been defined');
10001}
10002(function () {
10003 try {
10004 if (typeof setTimeout === 'function') {
10005 cachedSetTimeout = setTimeout;
10006 } else {
10007 cachedSetTimeout = defaultSetTimout;
10008 }
10009 } catch (e) {
10010 cachedSetTimeout = defaultSetTimout;
10011 }
10012 try {
10013 if (typeof clearTimeout === 'function') {
10014 cachedClearTimeout = clearTimeout;
10015 } else {
10016 cachedClearTimeout = defaultClearTimeout;
10017 }
10018 } catch (e) {
10019 cachedClearTimeout = defaultClearTimeout;
10020 }
10021} ())
10022function runTimeout(fun) {
10023 if (cachedSetTimeout === setTimeout) {
10024 //normal enviroments in sane situations
10025 return setTimeout(fun, 0);
10026 }
10027 // if setTimeout wasn't available but was latter defined
10028 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
10029 cachedSetTimeout = setTimeout;
10030 return setTimeout(fun, 0);
10031 }
10032 try {
10033 // when when somebody has screwed with setTimeout but no I.E. maddness
10034 return cachedSetTimeout(fun, 0);
10035 } catch(e){
10036 try {
10037 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
10038 return cachedSetTimeout.call(null, fun, 0);
10039 } catch(e){
10040 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
10041 return cachedSetTimeout.call(this, fun, 0);
10042 }
10043 }
10044
10045
10046}
10047function runClearTimeout(marker) {
10048 if (cachedClearTimeout === clearTimeout) {
10049 //normal enviroments in sane situations
10050 return clearTimeout(marker);
10051 }
10052 // if clearTimeout wasn't available but was latter defined
10053 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
10054 cachedClearTimeout = clearTimeout;
10055 return clearTimeout(marker);
10056 }
10057 try {
10058 // when when somebody has screwed with setTimeout but no I.E. maddness
10059 return cachedClearTimeout(marker);
10060 } catch (e){
10061 try {
10062 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
10063 return cachedClearTimeout.call(null, marker);
10064 } catch (e){
10065 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
10066 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
10067 return cachedClearTimeout.call(this, marker);
10068 }
10069 }
10070
10071
10072
10073}
10074var queue = [];
10075var draining = false;
10076var currentQueue;
10077var queueIndex = -1;
10078
10079function cleanUpNextTick() {
10080 if (!draining || !currentQueue) {
10081 return;
10082 }
10083 draining = false;
10084 if (currentQueue.length) {
10085 queue = currentQueue.concat(queue);
10086 } else {
10087 queueIndex = -1;
10088 }
10089 if (queue.length) {
10090 drainQueue();
10091 }
10092}
10093
10094function drainQueue() {
10095 if (draining) {
10096 return;
10097 }
10098 var timeout = runTimeout(cleanUpNextTick);
10099 draining = true;
10100
10101 var len = queue.length;
10102 while(len) {
10103 currentQueue = queue;
10104 queue = [];
10105 while (++queueIndex < len) {
10106 if (currentQueue) {
10107 currentQueue[queueIndex].run();
10108 }
10109 }
10110 queueIndex = -1;
10111 len = queue.length;
10112 }
10113 currentQueue = null;
10114 draining = false;
10115 runClearTimeout(timeout);
10116}
10117
10118process.nextTick = function (fun) {
10119 var args = new Array(arguments.length - 1);
10120 if (arguments.length > 1) {
10121 for (var i = 1; i < arguments.length; i++) {
10122 args[i - 1] = arguments[i];
10123 }
10124 }
10125 queue.push(new Item(fun, args));
10126 if (queue.length === 1 && !draining) {
10127 runTimeout(drainQueue);
10128 }
10129};
10130
10131// v8 likes predictible objects
10132function Item(fun, array) {
10133 this.fun = fun;
10134 this.array = array;
10135}
10136Item.prototype.run = function () {
10137 this.fun.apply(null, this.array);
10138};
10139process.title = 'browser';
10140process.browser = true;
10141process.env = {};
10142process.argv = [];
10143process.version = ''; // empty string to avoid regexp issues
10144process.versions = {};
10145
10146function noop() {}
10147
10148process.on = noop;
10149process.addListener = noop;
10150process.once = noop;
10151process.off = noop;
10152process.removeListener = noop;
10153process.removeAllListeners = noop;
10154process.emit = noop;
10155
10156process.binding = function (name) {
10157 throw new Error('process.binding is not supported');
10158};
10159
10160process.cwd = function () { return '/' };
10161process.chdir = function (dir) {
10162 throw new Error('process.chdir is not supported');
10163};
10164process.umask = function() { return 0; };
10165
10166},{}]},{},[1]);