1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Klic = f()}})(function(){var define,module,exports;return (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})({"/home/employee-2klic/projects/2klic_io-sdk/node_modules/bluebird/js/browser/bluebird.js":[function(require,module,exports){
|
2 | (function (process,global){
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | !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){
|
32 | "use strict";
|
33 | module.exports = function(Promise) {
|
34 | var SomePromiseArray = Promise._SomePromiseArray;
|
35 | function any(promises) {
|
36 | var ret = new SomePromiseArray(promises);
|
37 | var promise = ret.promise();
|
38 | ret.setHowMany(1);
|
39 | ret.setUnwrap();
|
40 | ret.init();
|
41 | return promise;
|
42 | }
|
43 |
|
44 | Promise.any = function (promises) {
|
45 | return any(promises);
|
46 | };
|
47 |
|
48 | Promise.prototype.any = function () {
|
49 | return any(this);
|
50 | };
|
51 |
|
52 | };
|
53 |
|
54 | },{}],2:[function(_dereq_,module,exports){
|
55 | "use strict";
|
56 | var firstLineError;
|
57 | try {throw new Error(); } catch (e) {firstLineError = e;}
|
58 | var schedule = _dereq_("./schedule");
|
59 | var Queue = _dereq_("./queue");
|
60 | var util = _dereq_("./util");
|
61 |
|
62 | function Async() {
|
63 | this._isTickUsed = false;
|
64 | this._lateQueue = new Queue(16);
|
65 | this._normalQueue = new Queue(16);
|
66 | this._haveDrainedQueues = false;
|
67 | this._trampolineEnabled = true;
|
68 | var self = this;
|
69 | this.drainQueues = function () {
|
70 | self._drainQueues();
|
71 | };
|
72 | this._schedule = schedule;
|
73 | }
|
74 |
|
75 | Async.prototype.enableTrampoline = function() {
|
76 | this._trampolineEnabled = true;
|
77 | };
|
78 |
|
79 | Async.prototype.disableTrampolineIfNecessary = function() {
|
80 | if (util.hasDevTools) {
|
81 | this._trampolineEnabled = false;
|
82 | }
|
83 | };
|
84 |
|
85 | Async.prototype.haveItemsQueued = function () {
|
86 | return this._isTickUsed || this._haveDrainedQueues;
|
87 | };
|
88 |
|
89 |
|
90 | Async.prototype.fatalError = function(e, isNode) {
|
91 | if (isNode) {
|
92 | process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e));
|
93 | process.exit(2);
|
94 | } else {
|
95 | this.throwLater(e);
|
96 | }
|
97 | };
|
98 |
|
99 | Async.prototype.throwLater = function(fn, arg) {
|
100 | if (arguments.length === 1) {
|
101 | arg = fn;
|
102 | fn = function () { throw arg; };
|
103 | }
|
104 | if (typeof setTimeout !== "undefined") {
|
105 | setTimeout(function() {
|
106 | fn(arg);
|
107 | }, 0);
|
108 | } else try {
|
109 | this._schedule(function() {
|
110 | fn(arg);
|
111 | });
|
112 | } catch (e) {
|
113 | throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
114 | }
|
115 | };
|
116 |
|
117 | function AsyncInvokeLater(fn, receiver, arg) {
|
118 | this._lateQueue.push(fn, receiver, arg);
|
119 | this._queueTick();
|
120 | }
|
121 |
|
122 | function AsyncInvoke(fn, receiver, arg) {
|
123 | this._normalQueue.push(fn, receiver, arg);
|
124 | this._queueTick();
|
125 | }
|
126 |
|
127 | function AsyncSettlePromises(promise) {
|
128 | this._normalQueue._pushOne(promise);
|
129 | this._queueTick();
|
130 | }
|
131 |
|
132 | if (!util.hasDevTools) {
|
133 | Async.prototype.invokeLater = AsyncInvokeLater;
|
134 | Async.prototype.invoke = AsyncInvoke;
|
135 | Async.prototype.settlePromises = AsyncSettlePromises;
|
136 | } else {
|
137 | Async.prototype.invokeLater = function (fn, receiver, arg) {
|
138 | if (this._trampolineEnabled) {
|
139 | AsyncInvokeLater.call(this, fn, receiver, arg);
|
140 | } else {
|
141 | this._schedule(function() {
|
142 | setTimeout(function() {
|
143 | fn.call(receiver, arg);
|
144 | }, 100);
|
145 | });
|
146 | }
|
147 | };
|
148 |
|
149 | Async.prototype.invoke = function (fn, receiver, arg) {
|
150 | if (this._trampolineEnabled) {
|
151 | AsyncInvoke.call(this, fn, receiver, arg);
|
152 | } else {
|
153 | this._schedule(function() {
|
154 | fn.call(receiver, arg);
|
155 | });
|
156 | }
|
157 | };
|
158 |
|
159 | Async.prototype.settlePromises = function(promise) {
|
160 | if (this._trampolineEnabled) {
|
161 | AsyncSettlePromises.call(this, promise);
|
162 | } else {
|
163 | this._schedule(function() {
|
164 | promise._settlePromises();
|
165 | });
|
166 | }
|
167 | };
|
168 | }
|
169 |
|
170 | Async.prototype.invokeFirst = function (fn, receiver, arg) {
|
171 | this._normalQueue.unshift(fn, receiver, arg);
|
172 | this._queueTick();
|
173 | };
|
174 |
|
175 | Async.prototype._drainQueue = function(queue) {
|
176 | while (queue.length() > 0) {
|
177 | var fn = queue.shift();
|
178 | if (typeof fn !== "function") {
|
179 | fn._settlePromises();
|
180 | continue;
|
181 | }
|
182 | var receiver = queue.shift();
|
183 | var arg = queue.shift();
|
184 | fn.call(receiver, arg);
|
185 | }
|
186 | };
|
187 |
|
188 | Async.prototype._drainQueues = function () {
|
189 | this._drainQueue(this._normalQueue);
|
190 | this._reset();
|
191 | this._haveDrainedQueues = true;
|
192 | this._drainQueue(this._lateQueue);
|
193 | };
|
194 |
|
195 | Async.prototype._queueTick = function () {
|
196 | if (!this._isTickUsed) {
|
197 | this._isTickUsed = true;
|
198 | this._schedule(this.drainQueues);
|
199 | }
|
200 | };
|
201 |
|
202 | Async.prototype._reset = function () {
|
203 | this._isTickUsed = false;
|
204 | };
|
205 |
|
206 | module.exports = Async;
|
207 | module.exports.firstLineError = firstLineError;
|
208 |
|
209 | },{"./queue":26,"./schedule":29,"./util":36}],3:[function(_dereq_,module,exports){
|
210 | "use strict";
|
211 | module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
|
212 | var calledBind = false;
|
213 | var rejectThis = function(_, e) {
|
214 | this._reject(e);
|
215 | };
|
216 |
|
217 | var targetRejected = function(e, context) {
|
218 | context.promiseRejectionQueued = true;
|
219 | context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
|
220 | };
|
221 |
|
222 | var bindingResolved = function(thisArg, context) {
|
223 | if (((this._bitField & 50397184) === 0)) {
|
224 | this._resolveCallback(context.target);
|
225 | }
|
226 | };
|
227 |
|
228 | var bindingRejected = function(e, context) {
|
229 | if (!context.promiseRejectionQueued) this._reject(e);
|
230 | };
|
231 |
|
232 | Promise.prototype.bind = function (thisArg) {
|
233 | if (!calledBind) {
|
234 | calledBind = true;
|
235 | Promise.prototype._propagateFrom = debug.propagateFromFunction();
|
236 | Promise.prototype._boundValue = debug.boundValueFunction();
|
237 | }
|
238 | var maybePromise = tryConvertToPromise(thisArg);
|
239 | var ret = new Promise(INTERNAL);
|
240 | ret._propagateFrom(this, 1);
|
241 | var target = this._target();
|
242 | ret._setBoundTo(maybePromise);
|
243 | if (maybePromise instanceof Promise) {
|
244 | var context = {
|
245 | promiseRejectionQueued: false,
|
246 | promise: ret,
|
247 | target: target,
|
248 | bindingPromise: maybePromise
|
249 | };
|
250 | target._then(INTERNAL, targetRejected, undefined, ret, context);
|
251 | maybePromise._then(
|
252 | bindingResolved, bindingRejected, undefined, ret, context);
|
253 | ret._setOnCancel(maybePromise);
|
254 | } else {
|
255 | ret._resolveCallback(target);
|
256 | }
|
257 | return ret;
|
258 | };
|
259 |
|
260 | Promise.prototype._setBoundTo = function (obj) {
|
261 | if (obj !== undefined) {
|
262 | this._bitField = this._bitField | 2097152;
|
263 | this._boundTo = obj;
|
264 | } else {
|
265 | this._bitField = this._bitField & (~2097152);
|
266 | }
|
267 | };
|
268 |
|
269 | Promise.prototype._isBound = function () {
|
270 | return (this._bitField & 2097152) === 2097152;
|
271 | };
|
272 |
|
273 | Promise.bind = function (thisArg, value) {
|
274 | return Promise.resolve(value).bind(thisArg);
|
275 | };
|
276 | };
|
277 |
|
278 | },{}],4:[function(_dereq_,module,exports){
|
279 | "use strict";
|
280 | var old;
|
281 | if (typeof Promise !== "undefined") old = Promise;
|
282 | function noConflict() {
|
283 | try { if (Promise === bluebird) Promise = old; }
|
284 | catch (e) {}
|
285 | return bluebird;
|
286 | }
|
287 | var bluebird = _dereq_("./promise")();
|
288 | bluebird.noConflict = noConflict;
|
289 | module.exports = bluebird;
|
290 |
|
291 | },{"./promise":22}],5:[function(_dereq_,module,exports){
|
292 | "use strict";
|
293 | var cr = Object.create;
|
294 | if (cr) {
|
295 | var callerCache = cr(null);
|
296 | var getterCache = cr(null);
|
297 | callerCache[" size"] = getterCache[" size"] = 0;
|
298 | }
|
299 |
|
300 | module.exports = function(Promise) {
|
301 | var util = _dereq_("./util");
|
302 | var canEvaluate = util.canEvaluate;
|
303 | var isIdentifier = util.isIdentifier;
|
304 |
|
305 | var getMethodCaller;
|
306 | var getGetter;
|
307 | if (!true) {
|
308 | var makeMethodCaller = function (methodName) {
|
309 | return new Function("ensureMethod", " \n\
|
310 | return function(obj) { \n\
|
311 | 'use strict' \n\
|
312 | var len = this.length; \n\
|
313 | ensureMethod(obj, 'methodName'); \n\
|
314 | switch(len) { \n\
|
315 | case 1: return obj.methodName(this[0]); \n\
|
316 | case 2: return obj.methodName(this[0], this[1]); \n\
|
317 | case 3: return obj.methodName(this[0], this[1], this[2]); \n\
|
318 | case 0: return obj.methodName(); \n\
|
319 | default: \n\
|
320 | return obj.methodName.apply(obj, this); \n\
|
321 | } \n\
|
322 | }; \n\
|
323 | ".replace(/methodName/g, methodName))(ensureMethod);
|
324 | };
|
325 |
|
326 | var makeGetter = function (propertyName) {
|
327 | return new Function("obj", " \n\
|
328 | 'use strict'; \n\
|
329 | return obj.propertyName; \n\
|
330 | ".replace("propertyName", propertyName));
|
331 | };
|
332 |
|
333 | var getCompiled = function(name, compiler, cache) {
|
334 | var ret = cache[name];
|
335 | if (typeof ret !== "function") {
|
336 | if (!isIdentifier(name)) {
|
337 | return null;
|
338 | }
|
339 | ret = compiler(name);
|
340 | cache[name] = ret;
|
341 | cache[" size"]++;
|
342 | if (cache[" size"] > 512) {
|
343 | var keys = Object.keys(cache);
|
344 | for (var i = 0; i < 256; ++i) delete cache[keys[i]];
|
345 | cache[" size"] = keys.length - 256;
|
346 | }
|
347 | }
|
348 | return ret;
|
349 | };
|
350 |
|
351 | getMethodCaller = function(name) {
|
352 | return getCompiled(name, makeMethodCaller, callerCache);
|
353 | };
|
354 |
|
355 | getGetter = function(name) {
|
356 | return getCompiled(name, makeGetter, getterCache);
|
357 | };
|
358 | }
|
359 |
|
360 | function ensureMethod(obj, methodName) {
|
361 | var fn;
|
362 | if (obj != null) fn = obj[methodName];
|
363 | if (typeof fn !== "function") {
|
364 | var message = "Object " + util.classString(obj) + " has no method '" +
|
365 | util.toString(methodName) + "'";
|
366 | throw new Promise.TypeError(message);
|
367 | }
|
368 | return fn;
|
369 | }
|
370 |
|
371 | function caller(obj) {
|
372 | var methodName = this.pop();
|
373 | var fn = ensureMethod(obj, methodName);
|
374 | return fn.apply(obj, this);
|
375 | }
|
376 | Promise.prototype.call = function (methodName) {
|
377 | var args = [].slice.call(arguments, 1);;
|
378 | if (!true) {
|
379 | if (canEvaluate) {
|
380 | var maybeCaller = getMethodCaller(methodName);
|
381 | if (maybeCaller !== null) {
|
382 | return this._then(
|
383 | maybeCaller, undefined, undefined, args, undefined);
|
384 | }
|
385 | }
|
386 | }
|
387 | args.push(methodName);
|
388 | return this._then(caller, undefined, undefined, args, undefined);
|
389 | };
|
390 |
|
391 | function namedGetter(obj) {
|
392 | return obj[this];
|
393 | }
|
394 | function indexedGetter(obj) {
|
395 | var index = +this;
|
396 | if (index < 0) index = Math.max(0, index + obj.length);
|
397 | return obj[index];
|
398 | }
|
399 | Promise.prototype.get = function (propertyName) {
|
400 | var isIndex = (typeof propertyName === "number");
|
401 | var getter;
|
402 | if (!isIndex) {
|
403 | if (canEvaluate) {
|
404 | var maybeGetter = getGetter(propertyName);
|
405 | getter = maybeGetter !== null ? maybeGetter : namedGetter;
|
406 | } else {
|
407 | getter = namedGetter;
|
408 | }
|
409 | } else {
|
410 | getter = indexedGetter;
|
411 | }
|
412 | return this._then(getter, undefined, undefined, propertyName, undefined);
|
413 | };
|
414 | };
|
415 |
|
416 | },{"./util":36}],6:[function(_dereq_,module,exports){
|
417 | "use strict";
|
418 | module.exports = function(Promise, PromiseArray, apiRejection, debug) {
|
419 | var util = _dereq_("./util");
|
420 | var tryCatch = util.tryCatch;
|
421 | var errorObj = util.errorObj;
|
422 | var async = Promise._async;
|
423 |
|
424 | Promise.prototype["break"] = Promise.prototype.cancel = function() {
|
425 | if (!debug.cancellation()) return this._warn("cancellation is disabled");
|
426 |
|
427 | var promise = this;
|
428 | var child = promise;
|
429 | while (promise.isCancellable()) {
|
430 | if (!promise._cancelBy(child)) {
|
431 | if (child._isFollowing()) {
|
432 | child._followee().cancel();
|
433 | } else {
|
434 | child._cancelBranched();
|
435 | }
|
436 | break;
|
437 | }
|
438 |
|
439 | var parent = promise._cancellationParent;
|
440 | if (parent == null || !parent.isCancellable()) {
|
441 | if (promise._isFollowing()) {
|
442 | promise._followee().cancel();
|
443 | } else {
|
444 | promise._cancelBranched();
|
445 | }
|
446 | break;
|
447 | } else {
|
448 | if (promise._isFollowing()) promise._followee().cancel();
|
449 | child = promise;
|
450 | promise = parent;
|
451 | }
|
452 | }
|
453 | };
|
454 |
|
455 | Promise.prototype._branchHasCancelled = function() {
|
456 | this._branchesRemainingToCancel--;
|
457 | };
|
458 |
|
459 | Promise.prototype._enoughBranchesHaveCancelled = function() {
|
460 | return this._branchesRemainingToCancel === undefined ||
|
461 | this._branchesRemainingToCancel <= 0;
|
462 | };
|
463 |
|
464 | Promise.prototype._cancelBy = function(canceller) {
|
465 | if (canceller === this) {
|
466 | this._branchesRemainingToCancel = 0;
|
467 | this._invokeOnCancel();
|
468 | return true;
|
469 | } else {
|
470 | this._branchHasCancelled();
|
471 | if (this._enoughBranchesHaveCancelled()) {
|
472 | this._invokeOnCancel();
|
473 | return true;
|
474 | }
|
475 | }
|
476 | return false;
|
477 | };
|
478 |
|
479 | Promise.prototype._cancelBranched = function() {
|
480 | if (this._enoughBranchesHaveCancelled()) {
|
481 | this._cancel();
|
482 | }
|
483 | };
|
484 |
|
485 | Promise.prototype._cancel = function() {
|
486 | if (!this.isCancellable()) return;
|
487 |
|
488 | this._setCancelled();
|
489 | async.invoke(this._cancelPromises, this, undefined);
|
490 | };
|
491 |
|
492 | Promise.prototype._cancelPromises = function() {
|
493 | if (this._length() > 0) this._settlePromises();
|
494 | };
|
495 |
|
496 | Promise.prototype._unsetOnCancel = function() {
|
497 | this._onCancelField = undefined;
|
498 | };
|
499 |
|
500 | Promise.prototype.isCancellable = function() {
|
501 | return this.isPending() && !this.isCancelled();
|
502 | };
|
503 |
|
504 | Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
|
505 | if (util.isArray(onCancelCallback)) {
|
506 | for (var i = 0; i < onCancelCallback.length; ++i) {
|
507 | this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
|
508 | }
|
509 | } else if (onCancelCallback !== undefined) {
|
510 | if (typeof onCancelCallback === "function") {
|
511 | if (!internalOnly) {
|
512 | var e = tryCatch(onCancelCallback).call(this._boundValue());
|
513 | if (e === errorObj) {
|
514 | this._attachExtraTrace(e.e);
|
515 | async.throwLater(e.e);
|
516 | }
|
517 | }
|
518 | } else {
|
519 | onCancelCallback._resultCancelled(this);
|
520 | }
|
521 | }
|
522 | };
|
523 |
|
524 | Promise.prototype._invokeOnCancel = function() {
|
525 | var onCancelCallback = this._onCancel();
|
526 | this._unsetOnCancel();
|
527 | async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
|
528 | };
|
529 |
|
530 | Promise.prototype._invokeInternalOnCancel = function() {
|
531 | if (this.isCancellable()) {
|
532 | this._doInvokeOnCancel(this._onCancel(), true);
|
533 | this._unsetOnCancel();
|
534 | }
|
535 | };
|
536 |
|
537 | Promise.prototype._resultCancelled = function() {
|
538 | this.cancel();
|
539 | };
|
540 |
|
541 | };
|
542 |
|
543 | },{"./util":36}],7:[function(_dereq_,module,exports){
|
544 | "use strict";
|
545 | module.exports = function(NEXT_FILTER) {
|
546 | var util = _dereq_("./util");
|
547 | var getKeys = _dereq_("./es5").keys;
|
548 | var tryCatch = util.tryCatch;
|
549 | var errorObj = util.errorObj;
|
550 |
|
551 | function catchFilter(instances, cb, promise) {
|
552 | return function(e) {
|
553 | var boundTo = promise._boundValue();
|
554 | predicateLoop: for (var i = 0; i < instances.length; ++i) {
|
555 | var item = instances[i];
|
556 |
|
557 | if (item === Error ||
|
558 | (item != null && item.prototype instanceof Error)) {
|
559 | if (e instanceof item) {
|
560 | return tryCatch(cb).call(boundTo, e);
|
561 | }
|
562 | } else if (typeof item === "function") {
|
563 | var matchesPredicate = tryCatch(item).call(boundTo, e);
|
564 | if (matchesPredicate === errorObj) {
|
565 | return matchesPredicate;
|
566 | } else if (matchesPredicate) {
|
567 | return tryCatch(cb).call(boundTo, e);
|
568 | }
|
569 | } else if (util.isObject(e)) {
|
570 | var keys = getKeys(item);
|
571 | for (var j = 0; j < keys.length; ++j) {
|
572 | var key = keys[j];
|
573 | if (item[key] != e[key]) {
|
574 | continue predicateLoop;
|
575 | }
|
576 | }
|
577 | return tryCatch(cb).call(boundTo, e);
|
578 | }
|
579 | }
|
580 | return NEXT_FILTER;
|
581 | };
|
582 | }
|
583 |
|
584 | return catchFilter;
|
585 | };
|
586 |
|
587 | },{"./es5":13,"./util":36}],8:[function(_dereq_,module,exports){
|
588 | "use strict";
|
589 | module.exports = function(Promise) {
|
590 | var longStackTraces = false;
|
591 | var contextStack = [];
|
592 |
|
593 | Promise.prototype._promiseCreated = function() {};
|
594 | Promise.prototype._pushContext = function() {};
|
595 | Promise.prototype._popContext = function() {return null;};
|
596 | Promise._peekContext = Promise.prototype._peekContext = function() {};
|
597 |
|
598 | function Context() {
|
599 | this._trace = new Context.CapturedTrace(peekContext());
|
600 | }
|
601 | Context.prototype._pushContext = function () {
|
602 | if (this._trace !== undefined) {
|
603 | this._trace._promiseCreated = null;
|
604 | contextStack.push(this._trace);
|
605 | }
|
606 | };
|
607 |
|
608 | Context.prototype._popContext = function () {
|
609 | if (this._trace !== undefined) {
|
610 | var trace = contextStack.pop();
|
611 | var ret = trace._promiseCreated;
|
612 | trace._promiseCreated = null;
|
613 | return ret;
|
614 | }
|
615 | return null;
|
616 | };
|
617 |
|
618 | function createContext() {
|
619 | if (longStackTraces) return new Context();
|
620 | }
|
621 |
|
622 | function peekContext() {
|
623 | var lastIndex = contextStack.length - 1;
|
624 | if (lastIndex >= 0) {
|
625 | return contextStack[lastIndex];
|
626 | }
|
627 | return undefined;
|
628 | }
|
629 | Context.CapturedTrace = null;
|
630 | Context.create = createContext;
|
631 | Context.deactivateLongStackTraces = function() {};
|
632 | Context.activateLongStackTraces = function() {
|
633 | var Promise_pushContext = Promise.prototype._pushContext;
|
634 | var Promise_popContext = Promise.prototype._popContext;
|
635 | var Promise_PeekContext = Promise._peekContext;
|
636 | var Promise_peekContext = Promise.prototype._peekContext;
|
637 | var Promise_promiseCreated = Promise.prototype._promiseCreated;
|
638 | Context.deactivateLongStackTraces = function() {
|
639 | Promise.prototype._pushContext = Promise_pushContext;
|
640 | Promise.prototype._popContext = Promise_popContext;
|
641 | Promise._peekContext = Promise_PeekContext;
|
642 | Promise.prototype._peekContext = Promise_peekContext;
|
643 | Promise.prototype._promiseCreated = Promise_promiseCreated;
|
644 | longStackTraces = false;
|
645 | };
|
646 | longStackTraces = true;
|
647 | Promise.prototype._pushContext = Context.prototype._pushContext;
|
648 | Promise.prototype._popContext = Context.prototype._popContext;
|
649 | Promise._peekContext = Promise.prototype._peekContext = peekContext;
|
650 | Promise.prototype._promiseCreated = function() {
|
651 | var ctx = this._peekContext();
|
652 | if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this;
|
653 | };
|
654 | };
|
655 | return Context;
|
656 | };
|
657 |
|
658 | },{}],9:[function(_dereq_,module,exports){
|
659 | "use strict";
|
660 | module.exports = function(Promise, Context) {
|
661 | var getDomain = Promise._getDomain;
|
662 | var async = Promise._async;
|
663 | var Warning = _dereq_("./errors").Warning;
|
664 | var util = _dereq_("./util");
|
665 | var canAttachTrace = util.canAttachTrace;
|
666 | var unhandledRejectionHandled;
|
667 | var possiblyUnhandledRejection;
|
668 | var bluebirdFramePattern =
|
669 | /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
|
670 | var stackFramePattern = null;
|
671 | var formatStack = null;
|
672 | var indentStackFrames = false;
|
673 | var printWarning;
|
674 | var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 &&
|
675 | (true ||
|
676 | util.env("BLUEBIRD_DEBUG") ||
|
677 | util.env("NODE_ENV") === "development"));
|
678 |
|
679 | var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 &&
|
680 | (debugging || util.env("BLUEBIRD_WARNINGS")));
|
681 |
|
682 | var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 &&
|
683 | (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES")));
|
684 |
|
685 | var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 &&
|
686 | (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN"));
|
687 |
|
688 | Promise.prototype.suppressUnhandledRejections = function() {
|
689 | var target = this._target();
|
690 | target._bitField = ((target._bitField & (~1048576)) |
|
691 | 524288);
|
692 | };
|
693 |
|
694 | Promise.prototype._ensurePossibleRejectionHandled = function () {
|
695 | if ((this._bitField & 524288) !== 0) return;
|
696 | this._setRejectionIsUnhandled();
|
697 | async.invokeLater(this._notifyUnhandledRejection, this, undefined);
|
698 | };
|
699 |
|
700 | Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
|
701 | fireRejectionEvent("rejectionHandled",
|
702 | unhandledRejectionHandled, undefined, this);
|
703 | };
|
704 |
|
705 | Promise.prototype._setReturnedNonUndefined = function() {
|
706 | this._bitField = this._bitField | 268435456;
|
707 | };
|
708 |
|
709 | Promise.prototype._returnedNonUndefined = function() {
|
710 | return (this._bitField & 268435456) !== 0;
|
711 | };
|
712 |
|
713 | Promise.prototype._notifyUnhandledRejection = function () {
|
714 | if (this._isRejectionUnhandled()) {
|
715 | var reason = this._settledValue();
|
716 | this._setUnhandledRejectionIsNotified();
|
717 | fireRejectionEvent("unhandledRejection",
|
718 | possiblyUnhandledRejection, reason, this);
|
719 | }
|
720 | };
|
721 |
|
722 | Promise.prototype._setUnhandledRejectionIsNotified = function () {
|
723 | this._bitField = this._bitField | 262144;
|
724 | };
|
725 |
|
726 | Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
|
727 | this._bitField = this._bitField & (~262144);
|
728 | };
|
729 |
|
730 | Promise.prototype._isUnhandledRejectionNotified = function () {
|
731 | return (this._bitField & 262144) > 0;
|
732 | };
|
733 |
|
734 | Promise.prototype._setRejectionIsUnhandled = function () {
|
735 | this._bitField = this._bitField | 1048576;
|
736 | };
|
737 |
|
738 | Promise.prototype._unsetRejectionIsUnhandled = function () {
|
739 | this._bitField = this._bitField & (~1048576);
|
740 | if (this._isUnhandledRejectionNotified()) {
|
741 | this._unsetUnhandledRejectionIsNotified();
|
742 | this._notifyUnhandledRejectionIsHandled();
|
743 | }
|
744 | };
|
745 |
|
746 | Promise.prototype._isRejectionUnhandled = function () {
|
747 | return (this._bitField & 1048576) > 0;
|
748 | };
|
749 |
|
750 | Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) {
|
751 | return warn(message, shouldUseOwnTrace, promise || this);
|
752 | };
|
753 |
|
754 | Promise.onPossiblyUnhandledRejection = function (fn) {
|
755 | var domain = getDomain();
|
756 | possiblyUnhandledRejection =
|
757 | typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
758 | : undefined;
|
759 | };
|
760 |
|
761 | Promise.onUnhandledRejectionHandled = function (fn) {
|
762 | var domain = getDomain();
|
763 | unhandledRejectionHandled =
|
764 | typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
765 | : undefined;
|
766 | };
|
767 |
|
768 | var disableLongStackTraces = function() {};
|
769 | Promise.longStackTraces = function () {
|
770 | if (async.haveItemsQueued() && !config.longStackTraces) {
|
771 | throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
772 | }
|
773 | if (!config.longStackTraces && longStackTracesIsSupported()) {
|
774 | var Promise_captureStackTrace = Promise.prototype._captureStackTrace;
|
775 | var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace;
|
776 | config.longStackTraces = true;
|
777 | disableLongStackTraces = function() {
|
778 | if (async.haveItemsQueued() && !config.longStackTraces) {
|
779 | throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
780 | }
|
781 | Promise.prototype._captureStackTrace = Promise_captureStackTrace;
|
782 | Promise.prototype._attachExtraTrace = Promise_attachExtraTrace;
|
783 | Context.deactivateLongStackTraces();
|
784 | async.enableTrampoline();
|
785 | config.longStackTraces = false;
|
786 | };
|
787 | Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace;
|
788 | Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace;
|
789 | Context.activateLongStackTraces();
|
790 | async.disableTrampolineIfNecessary();
|
791 | }
|
792 | };
|
793 |
|
794 | Promise.hasLongStackTraces = function () {
|
795 | return config.longStackTraces && longStackTracesIsSupported();
|
796 | };
|
797 |
|
798 | Promise.config = function(opts) {
|
799 | opts = Object(opts);
|
800 | if ("longStackTraces" in opts) {
|
801 | if (opts.longStackTraces) {
|
802 | Promise.longStackTraces();
|
803 | } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) {
|
804 | disableLongStackTraces();
|
805 | }
|
806 | }
|
807 | if ("warnings" in opts) {
|
808 | var warningsOption = opts.warnings;
|
809 | config.warnings = !!warningsOption;
|
810 | wForgottenReturn = config.warnings;
|
811 |
|
812 | if (util.isObject(warningsOption)) {
|
813 | if ("wForgottenReturn" in warningsOption) {
|
814 | wForgottenReturn = !!warningsOption.wForgottenReturn;
|
815 | }
|
816 | }
|
817 | }
|
818 | if ("cancellation" in opts && opts.cancellation && !config.cancellation) {
|
819 | if (async.haveItemsQueued()) {
|
820 | throw new Error(
|
821 | "cannot enable cancellation after promises are in use");
|
822 | }
|
823 | Promise.prototype._clearCancellationData =
|
824 | cancellationClearCancellationData;
|
825 | Promise.prototype._propagateFrom = cancellationPropagateFrom;
|
826 | Promise.prototype._onCancel = cancellationOnCancel;
|
827 | Promise.prototype._setOnCancel = cancellationSetOnCancel;
|
828 | Promise.prototype._attachCancellationCallback =
|
829 | cancellationAttachCancellationCallback;
|
830 | Promise.prototype._execute = cancellationExecute;
|
831 | propagateFromFunction = cancellationPropagateFrom;
|
832 | config.cancellation = true;
|
833 | }
|
834 | };
|
835 |
|
836 | Promise.prototype._execute = function(executor, resolve, reject) {
|
837 | try {
|
838 | executor(resolve, reject);
|
839 | } catch (e) {
|
840 | return e;
|
841 | }
|
842 | };
|
843 | Promise.prototype._onCancel = function () {};
|
844 | Promise.prototype._setOnCancel = function (handler) { ; };
|
845 | Promise.prototype._attachCancellationCallback = function(onCancel) {
|
846 | ;
|
847 | };
|
848 | Promise.prototype._captureStackTrace = function () {};
|
849 | Promise.prototype._attachExtraTrace = function () {};
|
850 | Promise.prototype._clearCancellationData = function() {};
|
851 | Promise.prototype._propagateFrom = function (parent, flags) {
|
852 | ;
|
853 | ;
|
854 | };
|
855 |
|
856 | function cancellationExecute(executor, resolve, reject) {
|
857 | var promise = this;
|
858 | try {
|
859 | executor(resolve, reject, function(onCancel) {
|
860 | if (typeof onCancel !== "function") {
|
861 | throw new TypeError("onCancel must be a function, got: " +
|
862 | util.toString(onCancel));
|
863 | }
|
864 | promise._attachCancellationCallback(onCancel);
|
865 | });
|
866 | } catch (e) {
|
867 | return e;
|
868 | }
|
869 | }
|
870 |
|
871 | function cancellationAttachCancellationCallback(onCancel) {
|
872 | if (!this.isCancellable()) return this;
|
873 |
|
874 | var previousOnCancel = this._onCancel();
|
875 | if (previousOnCancel !== undefined) {
|
876 | if (util.isArray(previousOnCancel)) {
|
877 | previousOnCancel.push(onCancel);
|
878 | } else {
|
879 | this._setOnCancel([previousOnCancel, onCancel]);
|
880 | }
|
881 | } else {
|
882 | this._setOnCancel(onCancel);
|
883 | }
|
884 | }
|
885 |
|
886 | function cancellationOnCancel() {
|
887 | return this._onCancelField;
|
888 | }
|
889 |
|
890 | function cancellationSetOnCancel(onCancel) {
|
891 | this._onCancelField = onCancel;
|
892 | }
|
893 |
|
894 | function cancellationClearCancellationData() {
|
895 | this._cancellationParent = undefined;
|
896 | this._onCancelField = undefined;
|
897 | }
|
898 |
|
899 | function cancellationPropagateFrom(parent, flags) {
|
900 | if ((flags & 1) !== 0) {
|
901 | this._cancellationParent = parent;
|
902 | var branchesRemainingToCancel = parent._branchesRemainingToCancel;
|
903 | if (branchesRemainingToCancel === undefined) {
|
904 | branchesRemainingToCancel = 0;
|
905 | }
|
906 | parent._branchesRemainingToCancel = branchesRemainingToCancel + 1;
|
907 | }
|
908 | if ((flags & 2) !== 0 && parent._isBound()) {
|
909 | this._setBoundTo(parent._boundTo);
|
910 | }
|
911 | }
|
912 |
|
913 | function bindingPropagateFrom(parent, flags) {
|
914 | if ((flags & 2) !== 0 && parent._isBound()) {
|
915 | this._setBoundTo(parent._boundTo);
|
916 | }
|
917 | }
|
918 | var propagateFromFunction = bindingPropagateFrom;
|
919 |
|
920 | function boundValueFunction() {
|
921 | var ret = this._boundTo;
|
922 | if (ret !== undefined) {
|
923 | if (ret instanceof Promise) {
|
924 | if (ret.isFulfilled()) {
|
925 | return ret.value();
|
926 | } else {
|
927 | return undefined;
|
928 | }
|
929 | }
|
930 | }
|
931 | return ret;
|
932 | }
|
933 |
|
934 | function longStackTracesCaptureStackTrace() {
|
935 | this._trace = new CapturedTrace(this._peekContext());
|
936 | }
|
937 |
|
938 | function longStackTracesAttachExtraTrace(error, ignoreSelf) {
|
939 | if (canAttachTrace(error)) {
|
940 | var trace = this._trace;
|
941 | if (trace !== undefined) {
|
942 | if (ignoreSelf) trace = trace._parent;
|
943 | }
|
944 | if (trace !== undefined) {
|
945 | trace.attachExtraTrace(error);
|
946 | } else if (!error.__stackCleaned__) {
|
947 | var parsed = parseStackAndMessage(error);
|
948 | util.notEnumerableProp(error, "stack",
|
949 | parsed.message + "\n" + parsed.stack.join("\n"));
|
950 | util.notEnumerableProp(error, "__stackCleaned__", true);
|
951 | }
|
952 | }
|
953 | }
|
954 |
|
955 | function checkForgottenReturns(returnValue, promiseCreated, name, promise,
|
956 | parent) {
|
957 | if (returnValue === undefined && promiseCreated !== null &&
|
958 | wForgottenReturn) {
|
959 | if (parent !== undefined && parent._returnedNonUndefined()) return;
|
960 |
|
961 | if (name) name = name + " ";
|
962 | var msg = "a promise was created in a " + name +
|
963 | "handler but was not returned from it";
|
964 | promise._warn(msg, true, promiseCreated);
|
965 | }
|
966 | }
|
967 |
|
968 | function deprecated(name, replacement) {
|
969 | var message = name +
|
970 | " is deprecated and will be removed in a future version.";
|
971 | if (replacement) message += " Use " + replacement + " instead.";
|
972 | return warn(message);
|
973 | }
|
974 |
|
975 | function warn(message, shouldUseOwnTrace, promise) {
|
976 | if (!config.warnings) return;
|
977 | var warning = new Warning(message);
|
978 | var ctx;
|
979 | if (shouldUseOwnTrace) {
|
980 | promise._attachExtraTrace(warning);
|
981 | } else if (config.longStackTraces && (ctx = Promise._peekContext())) {
|
982 | ctx.attachExtraTrace(warning);
|
983 | } else {
|
984 | var parsed = parseStackAndMessage(warning);
|
985 | warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
|
986 | }
|
987 | formatAndLogError(warning, "", true);
|
988 | }
|
989 |
|
990 | function reconstructStack(message, stacks) {
|
991 | for (var i = 0; i < stacks.length - 1; ++i) {
|
992 | stacks[i].push("From previous event:");
|
993 | stacks[i] = stacks[i].join("\n");
|
994 | }
|
995 | if (i < stacks.length) {
|
996 | stacks[i] = stacks[i].join("\n");
|
997 | }
|
998 | return message + "\n" + stacks.join("\n");
|
999 | }
|
1000 |
|
1001 | function removeDuplicateOrEmptyJumps(stacks) {
|
1002 | for (var i = 0; i < stacks.length; ++i) {
|
1003 | if (stacks[i].length === 0 ||
|
1004 | ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
|
1005 | stacks.splice(i, 1);
|
1006 | i--;
|
1007 | }
|
1008 | }
|
1009 | }
|
1010 |
|
1011 | function removeCommonRoots(stacks) {
|
1012 | var current = stacks[0];
|
1013 | for (var i = 1; i < stacks.length; ++i) {
|
1014 | var prev = stacks[i];
|
1015 | var currentLastIndex = current.length - 1;
|
1016 | var currentLastLine = current[currentLastIndex];
|
1017 | var commonRootMeetPoint = -1;
|
1018 |
|
1019 | for (var j = prev.length - 1; j >= 0; --j) {
|
1020 | if (prev[j] === currentLastLine) {
|
1021 | commonRootMeetPoint = j;
|
1022 | break;
|
1023 | }
|
1024 | }
|
1025 |
|
1026 | for (var j = commonRootMeetPoint; j >= 0; --j) {
|
1027 | var line = prev[j];
|
1028 | if (current[currentLastIndex] === line) {
|
1029 | current.pop();
|
1030 | currentLastIndex--;
|
1031 | } else {
|
1032 | break;
|
1033 | }
|
1034 | }
|
1035 | current = prev;
|
1036 | }
|
1037 | }
|
1038 |
|
1039 | function cleanStack(stack) {
|
1040 | var ret = [];
|
1041 | for (var i = 0; i < stack.length; ++i) {
|
1042 | var line = stack[i];
|
1043 | var isTraceLine = " (No stack trace)" === line ||
|
1044 | stackFramePattern.test(line);
|
1045 | var isInternalFrame = isTraceLine && shouldIgnore(line);
|
1046 | if (isTraceLine && !isInternalFrame) {
|
1047 | if (indentStackFrames && line.charAt(0) !== " ") {
|
1048 | line = " " + line;
|
1049 | }
|
1050 | ret.push(line);
|
1051 | }
|
1052 | }
|
1053 | return ret;
|
1054 | }
|
1055 |
|
1056 | function stackFramesAsArray(error) {
|
1057 | var stack = error.stack.replace(/\s+$/g, "").split("\n");
|
1058 | for (var i = 0; i < stack.length; ++i) {
|
1059 | var line = stack[i];
|
1060 | if (" (No stack trace)" === line || stackFramePattern.test(line)) {
|
1061 | break;
|
1062 | }
|
1063 | }
|
1064 | if (i > 0) {
|
1065 | stack = stack.slice(i);
|
1066 | }
|
1067 | return stack;
|
1068 | }
|
1069 |
|
1070 | function parseStackAndMessage(error) {
|
1071 | var stack = error.stack;
|
1072 | var message = error.toString();
|
1073 | stack = typeof stack === "string" && stack.length > 0
|
1074 | ? stackFramesAsArray(error) : [" (No stack trace)"];
|
1075 | return {
|
1076 | message: message,
|
1077 | stack: cleanStack(stack)
|
1078 | };
|
1079 | }
|
1080 |
|
1081 | function formatAndLogError(error, title, isSoft) {
|
1082 | if (typeof console !== "undefined") {
|
1083 | var message;
|
1084 | if (util.isObject(error)) {
|
1085 | var stack = error.stack;
|
1086 | message = title + formatStack(stack, error);
|
1087 | } else {
|
1088 | message = title + String(error);
|
1089 | }
|
1090 | if (typeof printWarning === "function") {
|
1091 | printWarning(message, isSoft);
|
1092 | } else if (typeof console.log === "function" ||
|
1093 | typeof console.log === "object") {
|
1094 | console.log(message);
|
1095 | }
|
1096 | }
|
1097 | }
|
1098 |
|
1099 | function fireRejectionEvent(name, localHandler, reason, promise) {
|
1100 | var localEventFired = false;
|
1101 | try {
|
1102 | if (typeof localHandler === "function") {
|
1103 | localEventFired = true;
|
1104 | if (name === "rejectionHandled") {
|
1105 | localHandler(promise);
|
1106 | } else {
|
1107 | localHandler(reason, promise);
|
1108 | }
|
1109 | }
|
1110 | } catch (e) {
|
1111 | async.throwLater(e);
|
1112 | }
|
1113 |
|
1114 | var globalEventFired = false;
|
1115 | try {
|
1116 | globalEventFired = fireGlobalEvent(name, reason, promise);
|
1117 | } catch (e) {
|
1118 | globalEventFired = true;
|
1119 | async.throwLater(e);
|
1120 | }
|
1121 |
|
1122 | var domEventFired = false;
|
1123 | if (fireDomEvent) {
|
1124 | try {
|
1125 | domEventFired = fireDomEvent(name.toLowerCase(), {
|
1126 | reason: reason,
|
1127 | promise: promise
|
1128 | });
|
1129 | } catch (e) {
|
1130 | domEventFired = true;
|
1131 | async.throwLater(e);
|
1132 | }
|
1133 | }
|
1134 |
|
1135 | if (!globalEventFired && !localEventFired && !domEventFired &&
|
1136 | name === "unhandledRejection") {
|
1137 | formatAndLogError(reason, "Unhandled rejection ");
|
1138 | }
|
1139 | }
|
1140 |
|
1141 | function formatNonError(obj) {
|
1142 | var str;
|
1143 | if (typeof obj === "function") {
|
1144 | str = "[function " +
|
1145 | (obj.name || "anonymous") +
|
1146 | "]";
|
1147 | } else {
|
1148 | str = obj && typeof obj.toString === "function"
|
1149 | ? obj.toString() : util.toString(obj);
|
1150 | var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
|
1151 | if (ruselessToString.test(str)) {
|
1152 | try {
|
1153 | var newStr = JSON.stringify(obj);
|
1154 | str = newStr;
|
1155 | }
|
1156 | catch(e) {
|
1157 |
|
1158 | }
|
1159 | }
|
1160 | if (str.length === 0) {
|
1161 | str = "(empty array)";
|
1162 | }
|
1163 | }
|
1164 | return ("(<" + snip(str) + ">, no stack trace)");
|
1165 | }
|
1166 |
|
1167 | function snip(str) {
|
1168 | var maxChars = 41;
|
1169 | if (str.length < maxChars) {
|
1170 | return str;
|
1171 | }
|
1172 | return str.substr(0, maxChars - 3) + "...";
|
1173 | }
|
1174 |
|
1175 | function longStackTracesIsSupported() {
|
1176 | return typeof captureStackTrace === "function";
|
1177 | }
|
1178 |
|
1179 | var shouldIgnore = function() { return false; };
|
1180 | var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
|
1181 | function parseLineInfo(line) {
|
1182 | var matches = line.match(parseLineInfoRegex);
|
1183 | if (matches) {
|
1184 | return {
|
1185 | fileName: matches[1],
|
1186 | line: parseInt(matches[2], 10)
|
1187 | };
|
1188 | }
|
1189 | }
|
1190 |
|
1191 | function setBounds(firstLineError, lastLineError) {
|
1192 | if (!longStackTracesIsSupported()) return;
|
1193 | var firstStackLines = firstLineError.stack.split("\n");
|
1194 | var lastStackLines = lastLineError.stack.split("\n");
|
1195 | var firstIndex = -1;
|
1196 | var lastIndex = -1;
|
1197 | var firstFileName;
|
1198 | var lastFileName;
|
1199 | for (var i = 0; i < firstStackLines.length; ++i) {
|
1200 | var result = parseLineInfo(firstStackLines[i]);
|
1201 | if (result) {
|
1202 | firstFileName = result.fileName;
|
1203 | firstIndex = result.line;
|
1204 | break;
|
1205 | }
|
1206 | }
|
1207 | for (var i = 0; i < lastStackLines.length; ++i) {
|
1208 | var result = parseLineInfo(lastStackLines[i]);
|
1209 | if (result) {
|
1210 | lastFileName = result.fileName;
|
1211 | lastIndex = result.line;
|
1212 | break;
|
1213 | }
|
1214 | }
|
1215 | if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
|
1216 | firstFileName !== lastFileName || firstIndex >= lastIndex) {
|
1217 | return;
|
1218 | }
|
1219 |
|
1220 | shouldIgnore = function(line) {
|
1221 | if (bluebirdFramePattern.test(line)) return true;
|
1222 | var info = parseLineInfo(line);
|
1223 | if (info) {
|
1224 | if (info.fileName === firstFileName &&
|
1225 | (firstIndex <= info.line && info.line <= lastIndex)) {
|
1226 | return true;
|
1227 | }
|
1228 | }
|
1229 | return false;
|
1230 | };
|
1231 | }
|
1232 |
|
1233 | function CapturedTrace(parent) {
|
1234 | this._parent = parent;
|
1235 | this._promisesCreated = 0;
|
1236 | var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
|
1237 | captureStackTrace(this, CapturedTrace);
|
1238 | if (length > 32) this.uncycle();
|
1239 | }
|
1240 | util.inherits(CapturedTrace, Error);
|
1241 | Context.CapturedTrace = CapturedTrace;
|
1242 |
|
1243 | CapturedTrace.prototype.uncycle = function() {
|
1244 | var length = this._length;
|
1245 | if (length < 2) return;
|
1246 | var nodes = [];
|
1247 | var stackToIndex = {};
|
1248 |
|
1249 | for (var i = 0, node = this; node !== undefined; ++i) {
|
1250 | nodes.push(node);
|
1251 | node = node._parent;
|
1252 | }
|
1253 | length = this._length = i;
|
1254 | for (var i = length - 1; i >= 0; --i) {
|
1255 | var stack = nodes[i].stack;
|
1256 | if (stackToIndex[stack] === undefined) {
|
1257 | stackToIndex[stack] = i;
|
1258 | }
|
1259 | }
|
1260 | for (var i = 0; i < length; ++i) {
|
1261 | var currentStack = nodes[i].stack;
|
1262 | var index = stackToIndex[currentStack];
|
1263 | if (index !== undefined && index !== i) {
|
1264 | if (index > 0) {
|
1265 | nodes[index - 1]._parent = undefined;
|
1266 | nodes[index - 1]._length = 1;
|
1267 | }
|
1268 | nodes[i]._parent = undefined;
|
1269 | nodes[i]._length = 1;
|
1270 | var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
|
1271 |
|
1272 | if (index < length - 1) {
|
1273 | cycleEdgeNode._parent = nodes[index + 1];
|
1274 | cycleEdgeNode._parent.uncycle();
|
1275 | cycleEdgeNode._length =
|
1276 | cycleEdgeNode._parent._length + 1;
|
1277 | } else {
|
1278 | cycleEdgeNode._parent = undefined;
|
1279 | cycleEdgeNode._length = 1;
|
1280 | }
|
1281 | var currentChildLength = cycleEdgeNode._length + 1;
|
1282 | for (var j = i - 2; j >= 0; --j) {
|
1283 | nodes[j]._length = currentChildLength;
|
1284 | currentChildLength++;
|
1285 | }
|
1286 | return;
|
1287 | }
|
1288 | }
|
1289 | };
|
1290 |
|
1291 | CapturedTrace.prototype.attachExtraTrace = function(error) {
|
1292 | if (error.__stackCleaned__) return;
|
1293 | this.uncycle();
|
1294 | var parsed = parseStackAndMessage(error);
|
1295 | var message = parsed.message;
|
1296 | var stacks = [parsed.stack];
|
1297 |
|
1298 | var trace = this;
|
1299 | while (trace !== undefined) {
|
1300 | stacks.push(cleanStack(trace.stack.split("\n")));
|
1301 | trace = trace._parent;
|
1302 | }
|
1303 | removeCommonRoots(stacks);
|
1304 | removeDuplicateOrEmptyJumps(stacks);
|
1305 | util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
|
1306 | util.notEnumerableProp(error, "__stackCleaned__", true);
|
1307 | };
|
1308 |
|
1309 | var captureStackTrace = (function stackDetection() {
|
1310 | var v8stackFramePattern = /^\s*at\s*/;
|
1311 | var v8stackFormatter = function(stack, error) {
|
1312 | if (typeof stack === "string") return stack;
|
1313 |
|
1314 | if (error.name !== undefined &&
|
1315 | error.message !== undefined) {
|
1316 | return error.toString();
|
1317 | }
|
1318 | return formatNonError(error);
|
1319 | };
|
1320 |
|
1321 | if (typeof Error.stackTraceLimit === "number" &&
|
1322 | typeof Error.captureStackTrace === "function") {
|
1323 | Error.stackTraceLimit += 6;
|
1324 | stackFramePattern = v8stackFramePattern;
|
1325 | formatStack = v8stackFormatter;
|
1326 | var captureStackTrace = Error.captureStackTrace;
|
1327 |
|
1328 | shouldIgnore = function(line) {
|
1329 | return bluebirdFramePattern.test(line);
|
1330 | };
|
1331 | return function(receiver, ignoreUntil) {
|
1332 | Error.stackTraceLimit += 6;
|
1333 | captureStackTrace(receiver, ignoreUntil);
|
1334 | Error.stackTraceLimit -= 6;
|
1335 | };
|
1336 | }
|
1337 | var err = new Error();
|
1338 |
|
1339 | if (typeof err.stack === "string" &&
|
1340 | err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
|
1341 | stackFramePattern = /@/;
|
1342 | formatStack = v8stackFormatter;
|
1343 | indentStackFrames = true;
|
1344 | return function captureStackTrace(o) {
|
1345 | o.stack = new Error().stack;
|
1346 | };
|
1347 | }
|
1348 |
|
1349 | var hasStackAfterThrow;
|
1350 | try { throw new Error(); }
|
1351 | catch(e) {
|
1352 | hasStackAfterThrow = ("stack" in e);
|
1353 | }
|
1354 | if (!("stack" in err) && hasStackAfterThrow &&
|
1355 | typeof Error.stackTraceLimit === "number") {
|
1356 | stackFramePattern = v8stackFramePattern;
|
1357 | formatStack = v8stackFormatter;
|
1358 | return function captureStackTrace(o) {
|
1359 | Error.stackTraceLimit += 6;
|
1360 | try { throw new Error(); }
|
1361 | catch(e) { o.stack = e.stack; }
|
1362 | Error.stackTraceLimit -= 6;
|
1363 | };
|
1364 | }
|
1365 |
|
1366 | formatStack = function(stack, error) {
|
1367 | if (typeof stack === "string") return stack;
|
1368 |
|
1369 | if ((typeof error === "object" ||
|
1370 | typeof error === "function") &&
|
1371 | error.name !== undefined &&
|
1372 | error.message !== undefined) {
|
1373 | return error.toString();
|
1374 | }
|
1375 | return formatNonError(error);
|
1376 | };
|
1377 |
|
1378 | return null;
|
1379 |
|
1380 | })([]);
|
1381 |
|
1382 | var fireDomEvent;
|
1383 | var fireGlobalEvent = (function() {
|
1384 | if (util.isNode) {
|
1385 | return function(name, reason, promise) {
|
1386 | if (name === "rejectionHandled") {
|
1387 | return process.emit(name, promise);
|
1388 | } else {
|
1389 | return process.emit(name, reason, promise);
|
1390 | }
|
1391 | };
|
1392 | } else {
|
1393 | var globalObject = typeof self !== "undefined" ? self :
|
1394 | typeof window !== "undefined" ? window :
|
1395 | typeof global !== "undefined" ? global :
|
1396 | this !== undefined ? this : null;
|
1397 |
|
1398 | if (!globalObject) {
|
1399 | return function() {
|
1400 | return false;
|
1401 | };
|
1402 | }
|
1403 |
|
1404 | try {
|
1405 | var event = document.createEvent("CustomEvent");
|
1406 | event.initCustomEvent("testingtheevent", false, true, {});
|
1407 | globalObject.dispatchEvent(event);
|
1408 | fireDomEvent = function(type, detail) {
|
1409 | var event = document.createEvent("CustomEvent");
|
1410 | event.initCustomEvent(type, false, true, detail);
|
1411 | return !globalObject.dispatchEvent(event);
|
1412 | };
|
1413 | } catch (e) {}
|
1414 |
|
1415 | var toWindowMethodNameMap = {};
|
1416 | toWindowMethodNameMap["unhandledRejection"] = ("on" +
|
1417 | "unhandledRejection").toLowerCase();
|
1418 | toWindowMethodNameMap["rejectionHandled"] = ("on" +
|
1419 | "rejectionHandled").toLowerCase();
|
1420 |
|
1421 | return function(name, reason, promise) {
|
1422 | var methodName = toWindowMethodNameMap[name];
|
1423 | var method = globalObject[methodName];
|
1424 | if (!method) return false;
|
1425 | if (name === "rejectionHandled") {
|
1426 | method.call(globalObject, promise);
|
1427 | } else {
|
1428 | method.call(globalObject, reason, promise);
|
1429 | }
|
1430 | return true;
|
1431 | };
|
1432 | }
|
1433 | })();
|
1434 |
|
1435 | if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
|
1436 | printWarning = function (message) {
|
1437 | console.warn(message);
|
1438 | };
|
1439 | if (util.isNode && process.stderr.isTTY) {
|
1440 | printWarning = function(message, isSoft) {
|
1441 | var color = isSoft ? "\u001b[33m" : "\u001b[31m";
|
1442 | console.warn(color + message + "\u001b[0m\n");
|
1443 | };
|
1444 | } else if (!util.isNode && typeof (new Error().stack) === "string") {
|
1445 | printWarning = function(message, isSoft) {
|
1446 | console.warn("%c" + message,
|
1447 | isSoft ? "color: darkorange" : "color: red");
|
1448 | };
|
1449 | }
|
1450 | }
|
1451 |
|
1452 | var config = {
|
1453 | warnings: warnings,
|
1454 | longStackTraces: false,
|
1455 | cancellation: false
|
1456 | };
|
1457 |
|
1458 | if (longStackTraces) Promise.longStackTraces();
|
1459 |
|
1460 | return {
|
1461 | longStackTraces: function() {
|
1462 | return config.longStackTraces;
|
1463 | },
|
1464 | warnings: function() {
|
1465 | return config.warnings;
|
1466 | },
|
1467 | cancellation: function() {
|
1468 | return config.cancellation;
|
1469 | },
|
1470 | propagateFromFunction: function() {
|
1471 | return propagateFromFunction;
|
1472 | },
|
1473 | boundValueFunction: function() {
|
1474 | return boundValueFunction;
|
1475 | },
|
1476 | checkForgottenReturns: checkForgottenReturns,
|
1477 | setBounds: setBounds,
|
1478 | warn: warn,
|
1479 | deprecated: deprecated,
|
1480 | CapturedTrace: CapturedTrace
|
1481 | };
|
1482 | };
|
1483 |
|
1484 | },{"./errors":12,"./util":36}],10:[function(_dereq_,module,exports){
|
1485 | "use strict";
|
1486 | module.exports = function(Promise) {
|
1487 | function returner() {
|
1488 | return this.value;
|
1489 | }
|
1490 | function thrower() {
|
1491 | throw this.reason;
|
1492 | }
|
1493 |
|
1494 | Promise.prototype["return"] =
|
1495 | Promise.prototype.thenReturn = function (value) {
|
1496 | if (value instanceof Promise) value.suppressUnhandledRejections();
|
1497 | return this._then(
|
1498 | returner, undefined, undefined, {value: value}, undefined);
|
1499 | };
|
1500 |
|
1501 | Promise.prototype["throw"] =
|
1502 | Promise.prototype.thenThrow = function (reason) {
|
1503 | return this._then(
|
1504 | thrower, undefined, undefined, {reason: reason}, undefined);
|
1505 | };
|
1506 |
|
1507 | Promise.prototype.catchThrow = function (reason) {
|
1508 | if (arguments.length <= 1) {
|
1509 | return this._then(
|
1510 | undefined, thrower, undefined, {reason: reason}, undefined);
|
1511 | } else {
|
1512 | var _reason = arguments[1];
|
1513 | var handler = function() {throw _reason;};
|
1514 | return this.caught(reason, handler);
|
1515 | }
|
1516 | };
|
1517 |
|
1518 | Promise.prototype.catchReturn = function (value) {
|
1519 | if (arguments.length <= 1) {
|
1520 | if (value instanceof Promise) value.suppressUnhandledRejections();
|
1521 | return this._then(
|
1522 | undefined, returner, undefined, {value: value}, undefined);
|
1523 | } else {
|
1524 | var _value = arguments[1];
|
1525 | if (_value instanceof Promise) _value.suppressUnhandledRejections();
|
1526 | var handler = function() {return _value;};
|
1527 | return this.caught(value, handler);
|
1528 | }
|
1529 | };
|
1530 | };
|
1531 |
|
1532 | },{}],11:[function(_dereq_,module,exports){
|
1533 | "use strict";
|
1534 | module.exports = function(Promise, INTERNAL) {
|
1535 | var PromiseReduce = Promise.reduce;
|
1536 | var PromiseAll = Promise.all;
|
1537 |
|
1538 | function promiseAllThis() {
|
1539 | return PromiseAll(this);
|
1540 | }
|
1541 |
|
1542 | function PromiseMapSeries(promises, fn) {
|
1543 | return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
|
1544 | }
|
1545 |
|
1546 | Promise.prototype.each = function (fn) {
|
1547 | return this.mapSeries(fn)
|
1548 | ._then(promiseAllThis, undefined, undefined, this, undefined);
|
1549 | };
|
1550 |
|
1551 | Promise.prototype.mapSeries = function (fn) {
|
1552 | return PromiseReduce(this, fn, INTERNAL, INTERNAL);
|
1553 | };
|
1554 |
|
1555 | Promise.each = function (promises, fn) {
|
1556 | return PromiseMapSeries(promises, fn)
|
1557 | ._then(promiseAllThis, undefined, undefined, promises, undefined);
|
1558 | };
|
1559 |
|
1560 | Promise.mapSeries = PromiseMapSeries;
|
1561 | };
|
1562 |
|
1563 | },{}],12:[function(_dereq_,module,exports){
|
1564 | "use strict";
|
1565 | var es5 = _dereq_("./es5");
|
1566 | var Objectfreeze = es5.freeze;
|
1567 | var util = _dereq_("./util");
|
1568 | var inherits = util.inherits;
|
1569 | var notEnumerableProp = util.notEnumerableProp;
|
1570 |
|
1571 | function subError(nameProperty, defaultMessage) {
|
1572 | function SubError(message) {
|
1573 | if (!(this instanceof SubError)) return new SubError(message);
|
1574 | notEnumerableProp(this, "message",
|
1575 | typeof message === "string" ? message : defaultMessage);
|
1576 | notEnumerableProp(this, "name", nameProperty);
|
1577 | if (Error.captureStackTrace) {
|
1578 | Error.captureStackTrace(this, this.constructor);
|
1579 | } else {
|
1580 | Error.call(this);
|
1581 | }
|
1582 | }
|
1583 | inherits(SubError, Error);
|
1584 | return SubError;
|
1585 | }
|
1586 |
|
1587 | var _TypeError, _RangeError;
|
1588 | var Warning = subError("Warning", "warning");
|
1589 | var CancellationError = subError("CancellationError", "cancellation error");
|
1590 | var TimeoutError = subError("TimeoutError", "timeout error");
|
1591 | var AggregateError = subError("AggregateError", "aggregate error");
|
1592 | try {
|
1593 | _TypeError = TypeError;
|
1594 | _RangeError = RangeError;
|
1595 | } catch(e) {
|
1596 | _TypeError = subError("TypeError", "type error");
|
1597 | _RangeError = subError("RangeError", "range error");
|
1598 | }
|
1599 |
|
1600 | var methods = ("join pop push shift unshift slice filter forEach some " +
|
1601 | "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
|
1602 |
|
1603 | for (var i = 0; i < methods.length; ++i) {
|
1604 | if (typeof Array.prototype[methods[i]] === "function") {
|
1605 | AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
|
1606 | }
|
1607 | }
|
1608 |
|
1609 | es5.defineProperty(AggregateError.prototype, "length", {
|
1610 | value: 0,
|
1611 | configurable: false,
|
1612 | writable: true,
|
1613 | enumerable: true
|
1614 | });
|
1615 | AggregateError.prototype["isOperational"] = true;
|
1616 | var level = 0;
|
1617 | AggregateError.prototype.toString = function() {
|
1618 | var indent = Array(level * 4 + 1).join(" ");
|
1619 | var ret = "\n" + indent + "AggregateError of:" + "\n";
|
1620 | level++;
|
1621 | indent = Array(level * 4 + 1).join(" ");
|
1622 | for (var i = 0; i < this.length; ++i) {
|
1623 | var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
|
1624 | var lines = str.split("\n");
|
1625 | for (var j = 0; j < lines.length; ++j) {
|
1626 | lines[j] = indent + lines[j];
|
1627 | }
|
1628 | str = lines.join("\n");
|
1629 | ret += str + "\n";
|
1630 | }
|
1631 | level--;
|
1632 | return ret;
|
1633 | };
|
1634 |
|
1635 | function OperationalError(message) {
|
1636 | if (!(this instanceof OperationalError))
|
1637 | return new OperationalError(message);
|
1638 | notEnumerableProp(this, "name", "OperationalError");
|
1639 | notEnumerableProp(this, "message", message);
|
1640 | this.cause = message;
|
1641 | this["isOperational"] = true;
|
1642 |
|
1643 | if (message instanceof Error) {
|
1644 | notEnumerableProp(this, "message", message.message);
|
1645 | notEnumerableProp(this, "stack", message.stack);
|
1646 | } else if (Error.captureStackTrace) {
|
1647 | Error.captureStackTrace(this, this.constructor);
|
1648 | }
|
1649 |
|
1650 | }
|
1651 | inherits(OperationalError, Error);
|
1652 |
|
1653 | var errorTypes = Error["__BluebirdErrorTypes__"];
|
1654 | if (!errorTypes) {
|
1655 | errorTypes = Objectfreeze({
|
1656 | CancellationError: CancellationError,
|
1657 | TimeoutError: TimeoutError,
|
1658 | OperationalError: OperationalError,
|
1659 | RejectionError: OperationalError,
|
1660 | AggregateError: AggregateError
|
1661 | });
|
1662 | notEnumerableProp(Error, "__BluebirdErrorTypes__", errorTypes);
|
1663 | }
|
1664 |
|
1665 | module.exports = {
|
1666 | Error: Error,
|
1667 | TypeError: _TypeError,
|
1668 | RangeError: _RangeError,
|
1669 | CancellationError: errorTypes.CancellationError,
|
1670 | OperationalError: errorTypes.OperationalError,
|
1671 | TimeoutError: errorTypes.TimeoutError,
|
1672 | AggregateError: errorTypes.AggregateError,
|
1673 | Warning: Warning
|
1674 | };
|
1675 |
|
1676 | },{"./es5":13,"./util":36}],13:[function(_dereq_,module,exports){
|
1677 | var isES5 = (function(){
|
1678 | "use strict";
|
1679 | return this === undefined;
|
1680 | })();
|
1681 |
|
1682 | if (isES5) {
|
1683 | module.exports = {
|
1684 | freeze: Object.freeze,
|
1685 | defineProperty: Object.defineProperty,
|
1686 | getDescriptor: Object.getOwnPropertyDescriptor,
|
1687 | keys: Object.keys,
|
1688 | names: Object.getOwnPropertyNames,
|
1689 | getPrototypeOf: Object.getPrototypeOf,
|
1690 | isArray: Array.isArray,
|
1691 | isES5: isES5,
|
1692 | propertyIsWritable: function(obj, prop) {
|
1693 | var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
1694 | return !!(!descriptor || descriptor.writable || descriptor.set);
|
1695 | }
|
1696 | };
|
1697 | } else {
|
1698 | var has = {}.hasOwnProperty;
|
1699 | var str = {}.toString;
|
1700 | var proto = {}.constructor.prototype;
|
1701 |
|
1702 | var ObjectKeys = function (o) {
|
1703 | var ret = [];
|
1704 | for (var key in o) {
|
1705 | if (has.call(o, key)) {
|
1706 | ret.push(key);
|
1707 | }
|
1708 | }
|
1709 | return ret;
|
1710 | };
|
1711 |
|
1712 | var ObjectGetDescriptor = function(o, key) {
|
1713 | return {value: o[key]};
|
1714 | };
|
1715 |
|
1716 | var ObjectDefineProperty = function (o, key, desc) {
|
1717 | o[key] = desc.value;
|
1718 | return o;
|
1719 | };
|
1720 |
|
1721 | var ObjectFreeze = function (obj) {
|
1722 | return obj;
|
1723 | };
|
1724 |
|
1725 | var ObjectGetPrototypeOf = function (obj) {
|
1726 | try {
|
1727 | return Object(obj).constructor.prototype;
|
1728 | }
|
1729 | catch (e) {
|
1730 | return proto;
|
1731 | }
|
1732 | };
|
1733 |
|
1734 | var ArrayIsArray = function (obj) {
|
1735 | try {
|
1736 | return str.call(obj) === "[object Array]";
|
1737 | }
|
1738 | catch(e) {
|
1739 | return false;
|
1740 | }
|
1741 | };
|
1742 |
|
1743 | module.exports = {
|
1744 | isArray: ArrayIsArray,
|
1745 | keys: ObjectKeys,
|
1746 | names: ObjectKeys,
|
1747 | defineProperty: ObjectDefineProperty,
|
1748 | getDescriptor: ObjectGetDescriptor,
|
1749 | freeze: ObjectFreeze,
|
1750 | getPrototypeOf: ObjectGetPrototypeOf,
|
1751 | isES5: isES5,
|
1752 | propertyIsWritable: function() {
|
1753 | return true;
|
1754 | }
|
1755 | };
|
1756 | }
|
1757 |
|
1758 | },{}],14:[function(_dereq_,module,exports){
|
1759 | "use strict";
|
1760 | module.exports = function(Promise, INTERNAL) {
|
1761 | var PromiseMap = Promise.map;
|
1762 |
|
1763 | Promise.prototype.filter = function (fn, options) {
|
1764 | return PromiseMap(this, fn, options, INTERNAL);
|
1765 | };
|
1766 |
|
1767 | Promise.filter = function (promises, fn, options) {
|
1768 | return PromiseMap(promises, fn, options, INTERNAL);
|
1769 | };
|
1770 | };
|
1771 |
|
1772 | },{}],15:[function(_dereq_,module,exports){
|
1773 | "use strict";
|
1774 | module.exports = function(Promise, tryConvertToPromise) {
|
1775 | var util = _dereq_("./util");
|
1776 | var CancellationError = Promise.CancellationError;
|
1777 | var errorObj = util.errorObj;
|
1778 |
|
1779 | function FinallyHandlerCancelReaction(finallyHandler) {
|
1780 | this.finallyHandler = finallyHandler;
|
1781 | }
|
1782 |
|
1783 | FinallyHandlerCancelReaction.prototype._resultCancelled = function() {
|
1784 | checkCancel(this.finallyHandler);
|
1785 | };
|
1786 |
|
1787 | function checkCancel(ctx, reason) {
|
1788 | if (ctx.cancelPromise != null) {
|
1789 | if (arguments.length > 1) {
|
1790 | ctx.cancelPromise._reject(reason);
|
1791 | } else {
|
1792 | ctx.cancelPromise._cancel();
|
1793 | }
|
1794 | ctx.cancelPromise = null;
|
1795 | return true;
|
1796 | }
|
1797 | return false;
|
1798 | }
|
1799 |
|
1800 | function succeed() {
|
1801 | return finallyHandler.call(this, this.promise._target()._settledValue());
|
1802 | }
|
1803 | function fail(reason) {
|
1804 | if (checkCancel(this, reason)) return;
|
1805 | errorObj.e = reason;
|
1806 | return errorObj;
|
1807 | }
|
1808 | function finallyHandler(reasonOrValue) {
|
1809 | var promise = this.promise;
|
1810 | var handler = this.handler;
|
1811 |
|
1812 | if (!this.called) {
|
1813 | this.called = true;
|
1814 | var ret = this.type === 0
|
1815 | ? handler.call(promise._boundValue())
|
1816 | : handler.call(promise._boundValue(), reasonOrValue);
|
1817 | if (ret !== undefined) {
|
1818 | promise._setReturnedNonUndefined();
|
1819 | var maybePromise = tryConvertToPromise(ret, promise);
|
1820 | if (maybePromise instanceof Promise) {
|
1821 | if (this.cancelPromise != null) {
|
1822 | if (maybePromise.isCancelled()) {
|
1823 | var reason =
|
1824 | new CancellationError("late cancellation observer");
|
1825 | promise._attachExtraTrace(reason);
|
1826 | errorObj.e = reason;
|
1827 | return errorObj;
|
1828 | } else if (maybePromise.isPending()) {
|
1829 | maybePromise._attachCancellationCallback(
|
1830 | new FinallyHandlerCancelReaction(this));
|
1831 | }
|
1832 | }
|
1833 | return maybePromise._then(
|
1834 | succeed, fail, undefined, this, undefined);
|
1835 | }
|
1836 | }
|
1837 | }
|
1838 |
|
1839 | if (promise.isRejected()) {
|
1840 | checkCancel(this);
|
1841 | errorObj.e = reasonOrValue;
|
1842 | return errorObj;
|
1843 | } else {
|
1844 | checkCancel(this);
|
1845 | return reasonOrValue;
|
1846 | }
|
1847 | }
|
1848 |
|
1849 | Promise.prototype._passThrough = function(handler, type, success, fail) {
|
1850 | if (typeof handler !== "function") return this.then();
|
1851 | return this._then(success, fail, undefined, {
|
1852 | promise: this,
|
1853 | handler: handler,
|
1854 | called: false,
|
1855 | cancelPromise: null,
|
1856 | type: type
|
1857 | }, undefined);
|
1858 | };
|
1859 |
|
1860 | Promise.prototype.lastly =
|
1861 | Promise.prototype["finally"] = function (handler) {
|
1862 | return this._passThrough(handler,
|
1863 | 0,
|
1864 | finallyHandler,
|
1865 | finallyHandler);
|
1866 | };
|
1867 |
|
1868 | Promise.prototype.tap = function (handler) {
|
1869 | return this._passThrough(handler, 1, finallyHandler);
|
1870 | };
|
1871 |
|
1872 | return finallyHandler;
|
1873 | };
|
1874 |
|
1875 | },{"./util":36}],16:[function(_dereq_,module,exports){
|
1876 | "use strict";
|
1877 | module.exports = function(Promise,
|
1878 | apiRejection,
|
1879 | INTERNAL,
|
1880 | tryConvertToPromise,
|
1881 | Proxyable,
|
1882 | debug) {
|
1883 | var errors = _dereq_("./errors");
|
1884 | var TypeError = errors.TypeError;
|
1885 | var util = _dereq_("./util");
|
1886 | var errorObj = util.errorObj;
|
1887 | var tryCatch = util.tryCatch;
|
1888 | var yieldHandlers = [];
|
1889 |
|
1890 | function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
|
1891 | for (var i = 0; i < yieldHandlers.length; ++i) {
|
1892 | traceParent._pushContext();
|
1893 | var result = tryCatch(yieldHandlers[i])(value);
|
1894 | traceParent._popContext();
|
1895 | if (result === errorObj) {
|
1896 | traceParent._pushContext();
|
1897 | var ret = Promise.reject(errorObj.e);
|
1898 | traceParent._popContext();
|
1899 | return ret;
|
1900 | }
|
1901 | var maybePromise = tryConvertToPromise(result, traceParent);
|
1902 | if (maybePromise instanceof Promise) return maybePromise;
|
1903 | }
|
1904 | return null;
|
1905 | }
|
1906 |
|
1907 | function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
|
1908 | var promise = this._promise = new Promise(INTERNAL);
|
1909 | promise._captureStackTrace();
|
1910 | promise._setOnCancel(this);
|
1911 | this._stack = stack;
|
1912 | this._generatorFunction = generatorFunction;
|
1913 | this._receiver = receiver;
|
1914 | this._generator = undefined;
|
1915 | this._yieldHandlers = typeof yieldHandler === "function"
|
1916 | ? [yieldHandler].concat(yieldHandlers)
|
1917 | : yieldHandlers;
|
1918 | this._yieldedPromise = null;
|
1919 | }
|
1920 | util.inherits(PromiseSpawn, Proxyable);
|
1921 |
|
1922 | PromiseSpawn.prototype._isResolved = function() {
|
1923 | return this._promise === null;
|
1924 | };
|
1925 |
|
1926 | PromiseSpawn.prototype._cleanup = function() {
|
1927 | this._promise = this._generator = null;
|
1928 | };
|
1929 |
|
1930 | PromiseSpawn.prototype._promiseCancelled = function() {
|
1931 | if (this._isResolved()) return;
|
1932 | var implementsReturn = typeof this._generator["return"] !== "undefined";
|
1933 |
|
1934 | var result;
|
1935 | if (!implementsReturn) {
|
1936 | var reason = new Promise.CancellationError(
|
1937 | "generator .return() sentinel");
|
1938 | Promise.coroutine.returnSentinel = reason;
|
1939 | this._promise._attachExtraTrace(reason);
|
1940 | this._promise._pushContext();
|
1941 | result = tryCatch(this._generator["throw"]).call(this._generator,
|
1942 | reason);
|
1943 | this._promise._popContext();
|
1944 | if (result === errorObj && result.e === reason) {
|
1945 | result = null;
|
1946 | }
|
1947 | } else {
|
1948 | this._promise._pushContext();
|
1949 | result = tryCatch(this._generator["return"]).call(this._generator,
|
1950 | undefined);
|
1951 | this._promise._popContext();
|
1952 | }
|
1953 | var promise = this._promise;
|
1954 | this._cleanup();
|
1955 | if (result === errorObj) {
|
1956 | promise._rejectCallback(result.e, false);
|
1957 | } else {
|
1958 | promise.cancel();
|
1959 | }
|
1960 | };
|
1961 |
|
1962 | PromiseSpawn.prototype._promiseFulfilled = function(value) {
|
1963 | this._yieldedPromise = null;
|
1964 | this._promise._pushContext();
|
1965 | var result = tryCatch(this._generator.next).call(this._generator, value);
|
1966 | this._promise._popContext();
|
1967 | this._continue(result);
|
1968 | };
|
1969 |
|
1970 | PromiseSpawn.prototype._promiseRejected = function(reason) {
|
1971 | this._yieldedPromise = null;
|
1972 | this._promise._attachExtraTrace(reason);
|
1973 | this._promise._pushContext();
|
1974 | var result = tryCatch(this._generator["throw"])
|
1975 | .call(this._generator, reason);
|
1976 | this._promise._popContext();
|
1977 | this._continue(result);
|
1978 | };
|
1979 |
|
1980 | PromiseSpawn.prototype._resultCancelled = function() {
|
1981 | if (this._yieldedPromise instanceof Promise) {
|
1982 | var promise = this._yieldedPromise;
|
1983 | this._yieldedPromise = null;
|
1984 | promise.cancel();
|
1985 | }
|
1986 | };
|
1987 |
|
1988 | PromiseSpawn.prototype.promise = function () {
|
1989 | return this._promise;
|
1990 | };
|
1991 |
|
1992 | PromiseSpawn.prototype._run = function () {
|
1993 | this._generator = this._generatorFunction.call(this._receiver);
|
1994 | this._receiver =
|
1995 | this._generatorFunction = undefined;
|
1996 | this._promiseFulfilled(undefined);
|
1997 | };
|
1998 |
|
1999 | PromiseSpawn.prototype._continue = function (result) {
|
2000 | var promise = this._promise;
|
2001 | if (result === errorObj) {
|
2002 | this._cleanup();
|
2003 | return promise._rejectCallback(result.e, false);
|
2004 | }
|
2005 |
|
2006 | var value = result.value;
|
2007 | if (result.done === true) {
|
2008 | this._cleanup();
|
2009 | return promise._resolveCallback(value);
|
2010 | } else {
|
2011 | var maybePromise = tryConvertToPromise(value, this._promise);
|
2012 | if (!(maybePromise instanceof Promise)) {
|
2013 | maybePromise =
|
2014 | promiseFromYieldHandler(maybePromise,
|
2015 | this._yieldHandlers,
|
2016 | this._promise);
|
2017 | if (maybePromise === null) {
|
2018 | this._promiseRejected(
|
2019 | new TypeError(
|
2020 | "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", value) +
|
2021 | "From coroutine:\u000a" +
|
2022 | this._stack.split("\n").slice(1, -7).join("\n")
|
2023 | )
|
2024 | );
|
2025 | return;
|
2026 | }
|
2027 | }
|
2028 | maybePromise = maybePromise._target();
|
2029 | var bitField = maybePromise._bitField;
|
2030 | ;
|
2031 | if (((bitField & 50397184) === 0)) {
|
2032 | this._yieldedPromise = maybePromise;
|
2033 | maybePromise._proxy(this, null);
|
2034 | } else if (((bitField & 33554432) !== 0)) {
|
2035 | this._promiseFulfilled(maybePromise._value());
|
2036 | } else if (((bitField & 16777216) !== 0)) {
|
2037 | this._promiseRejected(maybePromise._reason());
|
2038 | } else {
|
2039 | this._promiseCancelled();
|
2040 | }
|
2041 | }
|
2042 | };
|
2043 |
|
2044 | Promise.coroutine = function (generatorFunction, options) {
|
2045 | if (typeof generatorFunction !== "function") {
|
2046 | throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
2047 | }
|
2048 | var yieldHandler = Object(options).yieldHandler;
|
2049 | var PromiseSpawn$ = PromiseSpawn;
|
2050 | var stack = new Error().stack;
|
2051 | return function () {
|
2052 | var generator = generatorFunction.apply(this, arguments);
|
2053 | var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
|
2054 | stack);
|
2055 | var ret = spawn.promise();
|
2056 | spawn._generator = generator;
|
2057 | spawn._promiseFulfilled(undefined);
|
2058 | return ret;
|
2059 | };
|
2060 | };
|
2061 |
|
2062 | Promise.coroutine.addYieldHandler = function(fn) {
|
2063 | if (typeof fn !== "function") {
|
2064 | throw new TypeError("expecting a function but got " + util.classString(fn));
|
2065 | }
|
2066 | yieldHandlers.push(fn);
|
2067 | };
|
2068 |
|
2069 | Promise.spawn = function (generatorFunction) {
|
2070 | debug.deprecated("Promise.spawn()", "Promise.coroutine()");
|
2071 | if (typeof generatorFunction !== "function") {
|
2072 | return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
2073 | }
|
2074 | var spawn = new PromiseSpawn(generatorFunction, this);
|
2075 | var ret = spawn.promise();
|
2076 | spawn._run(Promise.spawn);
|
2077 | return ret;
|
2078 | };
|
2079 | };
|
2080 |
|
2081 | },{"./errors":12,"./util":36}],17:[function(_dereq_,module,exports){
|
2082 | "use strict";
|
2083 | module.exports =
|
2084 | function(Promise, PromiseArray, tryConvertToPromise, INTERNAL) {
|
2085 | var util = _dereq_("./util");
|
2086 | var canEvaluate = util.canEvaluate;
|
2087 | var tryCatch = util.tryCatch;
|
2088 | var errorObj = util.errorObj;
|
2089 | var reject;
|
2090 |
|
2091 | if (!true) {
|
2092 | if (canEvaluate) {
|
2093 | var thenCallback = function(i) {
|
2094 | return new Function("value", "holder", " \n\
|
2095 | 'use strict'; \n\
|
2096 | holder.pIndex = value; \n\
|
2097 | holder.checkFulfillment(this); \n\
|
2098 | ".replace(/Index/g, i));
|
2099 | };
|
2100 |
|
2101 | var promiseSetter = function(i) {
|
2102 | return new Function("promise", "holder", " \n\
|
2103 | 'use strict'; \n\
|
2104 | holder.pIndex = promise; \n\
|
2105 | ".replace(/Index/g, i));
|
2106 | };
|
2107 |
|
2108 | var generateHolderClass = function(total) {
|
2109 | var props = new Array(total);
|
2110 | for (var i = 0; i < props.length; ++i) {
|
2111 | props[i] = "this.p" + (i+1);
|
2112 | }
|
2113 | var assignment = props.join(" = ") + " = null;";
|
2114 | var cancellationCode= "var promise;\n" + props.map(function(prop) {
|
2115 | return " \n\
|
2116 | promise = " + prop + "; \n\
|
2117 | if (promise instanceof Promise) { \n\
|
2118 | promise.cancel(); \n\
|
2119 | } \n\
|
2120 | ";
|
2121 | }).join("\n");
|
2122 | var passedArguments = props.join(", ");
|
2123 | var name = "Holder$" + total;
|
2124 |
|
2125 |
|
2126 | var code = "return function(tryCatch, errorObj, Promise) { \n\
|
2127 | 'use strict'; \n\
|
2128 | function [TheName](fn) { \n\
|
2129 | [TheProperties] \n\
|
2130 | this.fn = fn; \n\
|
2131 | this.now = 0; \n\
|
2132 | } \n\
|
2133 | [TheName].prototype.checkFulfillment = function(promise) { \n\
|
2134 | var now = ++this.now; \n\
|
2135 | if (now === [TheTotal]) { \n\
|
2136 | promise._pushContext(); \n\
|
2137 | var callback = this.fn; \n\
|
2138 | var ret = tryCatch(callback)([ThePassedArguments]); \n\
|
2139 | promise._popContext(); \n\
|
2140 | if (ret === errorObj) { \n\
|
2141 | promise._rejectCallback(ret.e, false); \n\
|
2142 | } else { \n\
|
2143 | promise._resolveCallback(ret); \n\
|
2144 | } \n\
|
2145 | } \n\
|
2146 | }; \n\
|
2147 | \n\
|
2148 | [TheName].prototype._resultCancelled = function() { \n\
|
2149 | [CancellationCode] \n\
|
2150 | }; \n\
|
2151 | \n\
|
2152 | return [TheName]; \n\
|
2153 | }(tryCatch, errorObj, Promise); \n\
|
2154 | ";
|
2155 |
|
2156 | code = code.replace(/\[TheName\]/g, name)
|
2157 | .replace(/\[TheTotal\]/g, total)
|
2158 | .replace(/\[ThePassedArguments\]/g, passedArguments)
|
2159 | .replace(/\[TheProperties\]/g, assignment)
|
2160 | .replace(/\[CancellationCode\]/g, cancellationCode);
|
2161 |
|
2162 | return new Function("tryCatch", "errorObj", "Promise", code)
|
2163 | (tryCatch, errorObj, Promise);
|
2164 | };
|
2165 |
|
2166 | var holderClasses = [];
|
2167 | var thenCallbacks = [];
|
2168 | var promiseSetters = [];
|
2169 |
|
2170 | for (var i = 0; i < 8; ++i) {
|
2171 | holderClasses.push(generateHolderClass(i + 1));
|
2172 | thenCallbacks.push(thenCallback(i + 1));
|
2173 | promiseSetters.push(promiseSetter(i + 1));
|
2174 | }
|
2175 |
|
2176 | reject = function (reason) {
|
2177 | this._reject(reason);
|
2178 | };
|
2179 | }}
|
2180 |
|
2181 | Promise.join = function () {
|
2182 | var last = arguments.length - 1;
|
2183 | var fn;
|
2184 | if (last > 0 && typeof arguments[last] === "function") {
|
2185 | fn = arguments[last];
|
2186 | if (!true) {
|
2187 | if (last <= 8 && canEvaluate) {
|
2188 | var ret = new Promise(INTERNAL);
|
2189 | ret._captureStackTrace();
|
2190 | var HolderClass = holderClasses[last - 1];
|
2191 | var holder = new HolderClass(fn);
|
2192 | var callbacks = thenCallbacks;
|
2193 |
|
2194 | for (var i = 0; i < last; ++i) {
|
2195 | var maybePromise = tryConvertToPromise(arguments[i], ret);
|
2196 | if (maybePromise instanceof Promise) {
|
2197 | maybePromise = maybePromise._target();
|
2198 | var bitField = maybePromise._bitField;
|
2199 | ;
|
2200 | if (((bitField & 50397184) === 0)) {
|
2201 | maybePromise._then(callbacks[i], reject,
|
2202 | undefined, ret, holder);
|
2203 | promiseSetters[i](maybePromise, holder);
|
2204 | } else if (((bitField & 33554432) !== 0)) {
|
2205 | callbacks[i].call(ret,
|
2206 | maybePromise._value(), holder);
|
2207 | } else if (((bitField & 16777216) !== 0)) {
|
2208 | ret._reject(maybePromise._reason());
|
2209 | } else {
|
2210 | ret._cancel();
|
2211 | }
|
2212 | } else {
|
2213 | callbacks[i].call(ret, maybePromise, holder);
|
2214 | }
|
2215 | }
|
2216 | if (!ret._isFateSealed()) {
|
2217 | ret._setAsyncGuaranteed();
|
2218 | ret._setOnCancel(holder);
|
2219 | }
|
2220 | return ret;
|
2221 | }
|
2222 | }
|
2223 | }
|
2224 | var args = [].slice.call(arguments);;
|
2225 | if (fn) args.pop();
|
2226 | var ret = new PromiseArray(args).promise();
|
2227 | return fn !== undefined ? ret.spread(fn) : ret;
|
2228 | };
|
2229 |
|
2230 | };
|
2231 |
|
2232 | },{"./util":36}],18:[function(_dereq_,module,exports){
|
2233 | "use strict";
|
2234 | module.exports = function(Promise,
|
2235 | PromiseArray,
|
2236 | apiRejection,
|
2237 | tryConvertToPromise,
|
2238 | INTERNAL,
|
2239 | debug) {
|
2240 | var getDomain = Promise._getDomain;
|
2241 | var util = _dereq_("./util");
|
2242 | var tryCatch = util.tryCatch;
|
2243 | var errorObj = util.errorObj;
|
2244 | var EMPTY_ARRAY = [];
|
2245 |
|
2246 | function MappingPromiseArray(promises, fn, limit, _filter) {
|
2247 | this.constructor$(promises);
|
2248 | this._promise._captureStackTrace();
|
2249 | var domain = getDomain();
|
2250 | this._callback = domain === null ? fn : domain.bind(fn);
|
2251 | this._preservedValues = _filter === INTERNAL
|
2252 | ? new Array(this.length())
|
2253 | : null;
|
2254 | this._limit = limit;
|
2255 | this._inFlight = 0;
|
2256 | this._queue = limit >= 1 ? [] : EMPTY_ARRAY;
|
2257 | this._init$(undefined, -2);
|
2258 | }
|
2259 | util.inherits(MappingPromiseArray, PromiseArray);
|
2260 |
|
2261 | MappingPromiseArray.prototype._init = function () {};
|
2262 |
|
2263 | MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
2264 | var values = this._values;
|
2265 | var length = this.length();
|
2266 | var preservedValues = this._preservedValues;
|
2267 | var limit = this._limit;
|
2268 |
|
2269 | if (index < 0) {
|
2270 | index = (index * -1) - 1;
|
2271 | values[index] = value;
|
2272 | if (limit >= 1) {
|
2273 | this._inFlight--;
|
2274 | this._drainQueue();
|
2275 | if (this._isResolved()) return true;
|
2276 | }
|
2277 | } else {
|
2278 | if (limit >= 1 && this._inFlight >= limit) {
|
2279 | values[index] = value;
|
2280 | this._queue.push(index);
|
2281 | return false;
|
2282 | }
|
2283 | if (preservedValues !== null) preservedValues[index] = value;
|
2284 |
|
2285 | var promise = this._promise;
|
2286 | var callback = this._callback;
|
2287 | var receiver = promise._boundValue();
|
2288 | promise._pushContext();
|
2289 | var ret = tryCatch(callback).call(receiver, value, index, length);
|
2290 | var promiseCreated = promise._popContext();
|
2291 | debug.checkForgottenReturns(
|
2292 | ret,
|
2293 | promiseCreated,
|
2294 | preservedValues !== null ? "Promise.filter" : "Promise.map",
|
2295 | promise
|
2296 | );
|
2297 | if (ret === errorObj) {
|
2298 | this._reject(ret.e);
|
2299 | return true;
|
2300 | }
|
2301 |
|
2302 | var maybePromise = tryConvertToPromise(ret, this._promise);
|
2303 | if (maybePromise instanceof Promise) {
|
2304 | maybePromise = maybePromise._target();
|
2305 | var bitField = maybePromise._bitField;
|
2306 | ;
|
2307 | if (((bitField & 50397184) === 0)) {
|
2308 | if (limit >= 1) this._inFlight++;
|
2309 | values[index] = maybePromise;
|
2310 | maybePromise._proxy(this, (index + 1) * -1);
|
2311 | return false;
|
2312 | } else if (((bitField & 33554432) !== 0)) {
|
2313 | ret = maybePromise._value();
|
2314 | } else if (((bitField & 16777216) !== 0)) {
|
2315 | this._reject(maybePromise._reason());
|
2316 | return true;
|
2317 | } else {
|
2318 | this._cancel();
|
2319 | return true;
|
2320 | }
|
2321 | }
|
2322 | values[index] = ret;
|
2323 | }
|
2324 | var totalResolved = ++this._totalResolved;
|
2325 | if (totalResolved >= length) {
|
2326 | if (preservedValues !== null) {
|
2327 | this._filter(values, preservedValues);
|
2328 | } else {
|
2329 | this._resolve(values);
|
2330 | }
|
2331 | return true;
|
2332 | }
|
2333 | return false;
|
2334 | };
|
2335 |
|
2336 | MappingPromiseArray.prototype._drainQueue = function () {
|
2337 | var queue = this._queue;
|
2338 | var limit = this._limit;
|
2339 | var values = this._values;
|
2340 | while (queue.length > 0 && this._inFlight < limit) {
|
2341 | if (this._isResolved()) return;
|
2342 | var index = queue.pop();
|
2343 | this._promiseFulfilled(values[index], index);
|
2344 | }
|
2345 | };
|
2346 |
|
2347 | MappingPromiseArray.prototype._filter = function (booleans, values) {
|
2348 | var len = values.length;
|
2349 | var ret = new Array(len);
|
2350 | var j = 0;
|
2351 | for (var i = 0; i < len; ++i) {
|
2352 | if (booleans[i]) ret[j++] = values[i];
|
2353 | }
|
2354 | ret.length = j;
|
2355 | this._resolve(ret);
|
2356 | };
|
2357 |
|
2358 | MappingPromiseArray.prototype.preservedValues = function () {
|
2359 | return this._preservedValues;
|
2360 | };
|
2361 |
|
2362 | function map(promises, fn, options, _filter) {
|
2363 | if (typeof fn !== "function") {
|
2364 | return apiRejection("expecting a function but got " + util.classString(fn));
|
2365 | }
|
2366 | var limit = typeof options === "object" && options !== null
|
2367 | ? options.concurrency
|
2368 | : 0;
|
2369 | limit = typeof limit === "number" &&
|
2370 | isFinite(limit) && limit >= 1 ? limit : 0;
|
2371 | return new MappingPromiseArray(promises, fn, limit, _filter).promise();
|
2372 | }
|
2373 |
|
2374 | Promise.prototype.map = function (fn, options) {
|
2375 | return map(this, fn, options, null);
|
2376 | };
|
2377 |
|
2378 | Promise.map = function (promises, fn, options, _filter) {
|
2379 | return map(promises, fn, options, _filter);
|
2380 | };
|
2381 |
|
2382 |
|
2383 | };
|
2384 |
|
2385 | },{"./util":36}],19:[function(_dereq_,module,exports){
|
2386 | "use strict";
|
2387 | module.exports =
|
2388 | function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
|
2389 | var util = _dereq_("./util");
|
2390 | var tryCatch = util.tryCatch;
|
2391 |
|
2392 | Promise.method = function (fn) {
|
2393 | if (typeof fn !== "function") {
|
2394 | throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
|
2395 | }
|
2396 | return function () {
|
2397 | var ret = new Promise(INTERNAL);
|
2398 | ret._captureStackTrace();
|
2399 | ret._pushContext();
|
2400 | var value = tryCatch(fn).apply(this, arguments);
|
2401 | var promiseCreated = ret._popContext();
|
2402 | debug.checkForgottenReturns(
|
2403 | value, promiseCreated, "Promise.method", ret);
|
2404 | ret._resolveFromSyncValue(value);
|
2405 | return ret;
|
2406 | };
|
2407 | };
|
2408 |
|
2409 | Promise.attempt = Promise["try"] = function (fn) {
|
2410 | if (typeof fn !== "function") {
|
2411 | return apiRejection("expecting a function but got " + util.classString(fn));
|
2412 | }
|
2413 | var ret = new Promise(INTERNAL);
|
2414 | ret._captureStackTrace();
|
2415 | ret._pushContext();
|
2416 | var value;
|
2417 | if (arguments.length > 1) {
|
2418 | debug.deprecated("calling Promise.try with more than 1 argument");
|
2419 | var arg = arguments[1];
|
2420 | var ctx = arguments[2];
|
2421 | value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
|
2422 | : tryCatch(fn).call(ctx, arg);
|
2423 | } else {
|
2424 | value = tryCatch(fn)();
|
2425 | }
|
2426 | var promiseCreated = ret._popContext();
|
2427 | debug.checkForgottenReturns(
|
2428 | value, promiseCreated, "Promise.try", ret);
|
2429 | ret._resolveFromSyncValue(value);
|
2430 | return ret;
|
2431 | };
|
2432 |
|
2433 | Promise.prototype._resolveFromSyncValue = function (value) {
|
2434 | if (value === util.errorObj) {
|
2435 | this._rejectCallback(value.e, false);
|
2436 | } else {
|
2437 | this._resolveCallback(value, true);
|
2438 | }
|
2439 | };
|
2440 | };
|
2441 |
|
2442 | },{"./util":36}],20:[function(_dereq_,module,exports){
|
2443 | "use strict";
|
2444 | var util = _dereq_("./util");
|
2445 | var maybeWrapAsError = util.maybeWrapAsError;
|
2446 | var errors = _dereq_("./errors");
|
2447 | var OperationalError = errors.OperationalError;
|
2448 | var es5 = _dereq_("./es5");
|
2449 |
|
2450 | function isUntypedError(obj) {
|
2451 | return obj instanceof Error &&
|
2452 | es5.getPrototypeOf(obj) === Error.prototype;
|
2453 | }
|
2454 |
|
2455 | var rErrorKey = /^(?:name|message|stack|cause)$/;
|
2456 | function wrapAsOperationalError(obj) {
|
2457 | var ret;
|
2458 | if (isUntypedError(obj)) {
|
2459 | ret = new OperationalError(obj);
|
2460 | ret.name = obj.name;
|
2461 | ret.message = obj.message;
|
2462 | ret.stack = obj.stack;
|
2463 | var keys = es5.keys(obj);
|
2464 | for (var i = 0; i < keys.length; ++i) {
|
2465 | var key = keys[i];
|
2466 | if (!rErrorKey.test(key)) {
|
2467 | ret[key] = obj[key];
|
2468 | }
|
2469 | }
|
2470 | return ret;
|
2471 | }
|
2472 | util.markAsOriginatingFromRejection(obj);
|
2473 | return obj;
|
2474 | }
|
2475 |
|
2476 | function nodebackForPromise(promise, multiArgs) {
|
2477 | return function(err, value) {
|
2478 | if (promise === null) return;
|
2479 | if (err) {
|
2480 | var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
|
2481 | promise._attachExtraTrace(wrapped);
|
2482 | promise._reject(wrapped);
|
2483 | } else if (!multiArgs) {
|
2484 | promise._fulfill(value);
|
2485 | } else {
|
2486 | var args = [].slice.call(arguments, 1);;
|
2487 | promise._fulfill(args);
|
2488 | }
|
2489 | promise = null;
|
2490 | };
|
2491 | }
|
2492 |
|
2493 | module.exports = nodebackForPromise;
|
2494 |
|
2495 | },{"./errors":12,"./es5":13,"./util":36}],21:[function(_dereq_,module,exports){
|
2496 | "use strict";
|
2497 | module.exports = function(Promise) {
|
2498 | var util = _dereq_("./util");
|
2499 | var async = Promise._async;
|
2500 | var tryCatch = util.tryCatch;
|
2501 | var errorObj = util.errorObj;
|
2502 |
|
2503 | function spreadAdapter(val, nodeback) {
|
2504 | var promise = this;
|
2505 | if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
|
2506 | var ret =
|
2507 | tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
|
2508 | if (ret === errorObj) {
|
2509 | async.throwLater(ret.e);
|
2510 | }
|
2511 | }
|
2512 |
|
2513 | function successAdapter(val, nodeback) {
|
2514 | var promise = this;
|
2515 | var receiver = promise._boundValue();
|
2516 | var ret = val === undefined
|
2517 | ? tryCatch(nodeback).call(receiver, null)
|
2518 | : tryCatch(nodeback).call(receiver, null, val);
|
2519 | if (ret === errorObj) {
|
2520 | async.throwLater(ret.e);
|
2521 | }
|
2522 | }
|
2523 | function errorAdapter(reason, nodeback) {
|
2524 | var promise = this;
|
2525 | if (!reason) {
|
2526 | var newReason = new Error(reason + "");
|
2527 | newReason.cause = reason;
|
2528 | reason = newReason;
|
2529 | }
|
2530 | var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
|
2531 | if (ret === errorObj) {
|
2532 | async.throwLater(ret.e);
|
2533 | }
|
2534 | }
|
2535 |
|
2536 | Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
|
2537 | options) {
|
2538 | if (typeof nodeback == "function") {
|
2539 | var adapter = successAdapter;
|
2540 | if (options !== undefined && Object(options).spread) {
|
2541 | adapter = spreadAdapter;
|
2542 | }
|
2543 | this._then(
|
2544 | adapter,
|
2545 | errorAdapter,
|
2546 | undefined,
|
2547 | this,
|
2548 | nodeback
|
2549 | );
|
2550 | }
|
2551 | return this;
|
2552 | };
|
2553 | };
|
2554 |
|
2555 | },{"./util":36}],22:[function(_dereq_,module,exports){
|
2556 | "use strict";
|
2557 | module.exports = function() {
|
2558 | var makeSelfResolutionError = function () {
|
2559 | return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
2560 | };
|
2561 | var reflectHandler = function() {
|
2562 | return new Promise.PromiseInspection(this._target());
|
2563 | };
|
2564 | var apiRejection = function(msg) {
|
2565 | return Promise.reject(new TypeError(msg));
|
2566 | };
|
2567 | function Proxyable() {}
|
2568 | var UNDEFINED_BINDING = {};
|
2569 | var util = _dereq_("./util");
|
2570 |
|
2571 | var getDomain;
|
2572 | if (util.isNode) {
|
2573 | getDomain = function() {
|
2574 | var ret = process.domain;
|
2575 | if (ret === undefined) ret = null;
|
2576 | return ret;
|
2577 | };
|
2578 | } else {
|
2579 | getDomain = function() {
|
2580 | return null;
|
2581 | };
|
2582 | }
|
2583 | util.notEnumerableProp(Promise, "_getDomain", getDomain);
|
2584 |
|
2585 | var es5 = _dereq_("./es5");
|
2586 | var Async = _dereq_("./async");
|
2587 | var async = new Async();
|
2588 | es5.defineProperty(Promise, "_async", {value: async});
|
2589 | var errors = _dereq_("./errors");
|
2590 | var TypeError = Promise.TypeError = errors.TypeError;
|
2591 | Promise.RangeError = errors.RangeError;
|
2592 | var CancellationError = Promise.CancellationError = errors.CancellationError;
|
2593 | Promise.TimeoutError = errors.TimeoutError;
|
2594 | Promise.OperationalError = errors.OperationalError;
|
2595 | Promise.RejectionError = errors.OperationalError;
|
2596 | Promise.AggregateError = errors.AggregateError;
|
2597 | var INTERNAL = function(){};
|
2598 | var APPLY = {};
|
2599 | var NEXT_FILTER = {};
|
2600 | var tryConvertToPromise = _dereq_("./thenables")(Promise, INTERNAL);
|
2601 | var PromiseArray =
|
2602 | _dereq_("./promise_array")(Promise, INTERNAL,
|
2603 | tryConvertToPromise, apiRejection, Proxyable);
|
2604 | var Context = _dereq_("./context")(Promise);
|
2605 |
|
2606 | var createContext = Context.create;
|
2607 | var debug = _dereq_("./debuggability")(Promise, Context);
|
2608 | var CapturedTrace = debug.CapturedTrace;
|
2609 | var finallyHandler = _dereq_("./finally")(Promise, tryConvertToPromise);
|
2610 | var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER);
|
2611 | var nodebackForPromise = _dereq_("./nodeback");
|
2612 | var errorObj = util.errorObj;
|
2613 | var tryCatch = util.tryCatch;
|
2614 | function check(self, executor) {
|
2615 | if (typeof executor !== "function") {
|
2616 | throw new TypeError("expecting a function but got " + util.classString(executor));
|
2617 | }
|
2618 | if (self.constructor !== Promise) {
|
2619 | throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
2620 | }
|
2621 | }
|
2622 |
|
2623 | function Promise(executor) {
|
2624 | this._bitField = 0;
|
2625 | this._fulfillmentHandler0 = undefined;
|
2626 | this._rejectionHandler0 = undefined;
|
2627 | this._promise0 = undefined;
|
2628 | this._receiver0 = undefined;
|
2629 | if (executor !== INTERNAL) {
|
2630 | check(this, executor);
|
2631 | this._resolveFromExecutor(executor);
|
2632 | }
|
2633 | this._promiseCreated();
|
2634 | }
|
2635 |
|
2636 | Promise.prototype.toString = function () {
|
2637 | return "[object Promise]";
|
2638 | };
|
2639 |
|
2640 | Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
|
2641 | var len = arguments.length;
|
2642 | if (len > 1) {
|
2643 | var catchInstances = new Array(len - 1),
|
2644 | j = 0, i;
|
2645 | for (i = 0; i < len - 1; ++i) {
|
2646 | var item = arguments[i];
|
2647 | if (util.isObject(item)) {
|
2648 | catchInstances[j++] = item;
|
2649 | } else {
|
2650 | return apiRejection("expecting an object but got " + util.classString(item));
|
2651 | }
|
2652 | }
|
2653 | catchInstances.length = j;
|
2654 | fn = arguments[i];
|
2655 | return this.then(undefined, catchFilter(catchInstances, fn, this));
|
2656 | }
|
2657 | return this.then(undefined, fn);
|
2658 | };
|
2659 |
|
2660 | Promise.prototype.reflect = function () {
|
2661 | return this._then(reflectHandler,
|
2662 | reflectHandler, undefined, this, undefined);
|
2663 | };
|
2664 |
|
2665 | Promise.prototype.then = function (didFulfill, didReject) {
|
2666 | if (debug.warnings() && arguments.length > 0 &&
|
2667 | typeof didFulfill !== "function" &&
|
2668 | typeof didReject !== "function") {
|
2669 | var msg = ".then() only accepts functions but was passed: " +
|
2670 | util.classString(didFulfill);
|
2671 | if (arguments.length > 1) {
|
2672 | msg += ", " + util.classString(didReject);
|
2673 | }
|
2674 | this._warn(msg);
|
2675 | }
|
2676 | return this._then(didFulfill, didReject, undefined, undefined, undefined);
|
2677 | };
|
2678 |
|
2679 | Promise.prototype.done = function (didFulfill, didReject) {
|
2680 | var promise =
|
2681 | this._then(didFulfill, didReject, undefined, undefined, undefined);
|
2682 | promise._setIsFinal();
|
2683 | };
|
2684 |
|
2685 | Promise.prototype.spread = function (fn) {
|
2686 | if (typeof fn !== "function") {
|
2687 | return apiRejection("expecting a function but got " + util.classString(fn));
|
2688 | }
|
2689 | return this.all()._then(fn, undefined, undefined, APPLY, undefined);
|
2690 | };
|
2691 |
|
2692 | Promise.prototype.toJSON = function () {
|
2693 | var ret = {
|
2694 | isFulfilled: false,
|
2695 | isRejected: false,
|
2696 | fulfillmentValue: undefined,
|
2697 | rejectionReason: undefined
|
2698 | };
|
2699 | if (this.isFulfilled()) {
|
2700 | ret.fulfillmentValue = this.value();
|
2701 | ret.isFulfilled = true;
|
2702 | } else if (this.isRejected()) {
|
2703 | ret.rejectionReason = this.reason();
|
2704 | ret.isRejected = true;
|
2705 | }
|
2706 | return ret;
|
2707 | };
|
2708 |
|
2709 | Promise.prototype.all = function () {
|
2710 | if (arguments.length > 0) {
|
2711 | this._warn(".all() was passed arguments but it does not take any");
|
2712 | }
|
2713 | return new PromiseArray(this).promise();
|
2714 | };
|
2715 |
|
2716 | Promise.prototype.error = function (fn) {
|
2717 | return this.caught(util.originatesFromRejection, fn);
|
2718 | };
|
2719 |
|
2720 | Promise.is = function (val) {
|
2721 | return val instanceof Promise;
|
2722 | };
|
2723 |
|
2724 | Promise.fromNode = Promise.fromCallback = function(fn) {
|
2725 | var ret = new Promise(INTERNAL);
|
2726 | var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
|
2727 | : false;
|
2728 | var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
|
2729 | if (result === errorObj) {
|
2730 | ret._rejectCallback(result.e, true);
|
2731 | }
|
2732 | if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
|
2733 | return ret;
|
2734 | };
|
2735 |
|
2736 | Promise.all = function (promises) {
|
2737 | return new PromiseArray(promises).promise();
|
2738 | };
|
2739 |
|
2740 | Promise.cast = function (obj) {
|
2741 | var ret = tryConvertToPromise(obj);
|
2742 | if (!(ret instanceof Promise)) {
|
2743 | ret = new Promise(INTERNAL);
|
2744 | ret._captureStackTrace();
|
2745 | ret._setFulfilled();
|
2746 | ret._rejectionHandler0 = obj;
|
2747 | }
|
2748 | return ret;
|
2749 | };
|
2750 |
|
2751 | Promise.resolve = Promise.fulfilled = Promise.cast;
|
2752 |
|
2753 | Promise.reject = Promise.rejected = function (reason) {
|
2754 | var ret = new Promise(INTERNAL);
|
2755 | ret._captureStackTrace();
|
2756 | ret._rejectCallback(reason, true);
|
2757 | return ret;
|
2758 | };
|
2759 |
|
2760 | Promise.setScheduler = function(fn) {
|
2761 | if (typeof fn !== "function") {
|
2762 | throw new TypeError("expecting a function but got " + util.classString(fn));
|
2763 | }
|
2764 | var prev = async._schedule;
|
2765 | async._schedule = fn;
|
2766 | return prev;
|
2767 | };
|
2768 |
|
2769 | Promise.prototype._then = function (
|
2770 | didFulfill,
|
2771 | didReject,
|
2772 | _, receiver,
|
2773 | internalData
|
2774 | ) {
|
2775 | var haveInternalData = internalData !== undefined;
|
2776 | var promise = haveInternalData ? internalData : new Promise(INTERNAL);
|
2777 | var target = this._target();
|
2778 | var bitField = target._bitField;
|
2779 |
|
2780 | if (!haveInternalData) {
|
2781 | promise._propagateFrom(this, 3);
|
2782 | promise._captureStackTrace();
|
2783 | if (receiver === undefined &&
|
2784 | ((this._bitField & 2097152) !== 0)) {
|
2785 | if (!((bitField & 50397184) === 0)) {
|
2786 | receiver = this._boundValue();
|
2787 | } else {
|
2788 | receiver = target === this ? undefined : this._boundTo;
|
2789 | }
|
2790 | }
|
2791 | }
|
2792 |
|
2793 | var domain = getDomain();
|
2794 | if (!((bitField & 50397184) === 0)) {
|
2795 | var handler, value, settler = target._settlePromiseCtx;
|
2796 | if (((bitField & 33554432) !== 0)) {
|
2797 | value = target._rejectionHandler0;
|
2798 | handler = didFulfill;
|
2799 | } else if (((bitField & 16777216) !== 0)) {
|
2800 | value = target._fulfillmentHandler0;
|
2801 | handler = didReject;
|
2802 | target._unsetRejectionIsUnhandled();
|
2803 | } else {
|
2804 | settler = target._settlePromiseLateCancellationObserver;
|
2805 | value = new CancellationError("late cancellation observer");
|
2806 | target._attachExtraTrace(value);
|
2807 | handler = didReject;
|
2808 | }
|
2809 |
|
2810 | async.invoke(settler, target, {
|
2811 | handler: domain === null ? handler
|
2812 | : (typeof handler === "function" && domain.bind(handler)),
|
2813 | promise: promise,
|
2814 | receiver: receiver,
|
2815 | value: value
|
2816 | });
|
2817 | } else {
|
2818 | target._addCallbacks(didFulfill, didReject, promise, receiver, domain);
|
2819 | }
|
2820 |
|
2821 | return promise;
|
2822 | };
|
2823 |
|
2824 | Promise.prototype._length = function () {
|
2825 | return this._bitField & 65535;
|
2826 | };
|
2827 |
|
2828 | Promise.prototype._isFateSealed = function () {
|
2829 | return (this._bitField & 117506048) !== 0;
|
2830 | };
|
2831 |
|
2832 | Promise.prototype._isFollowing = function () {
|
2833 | return (this._bitField & 67108864) === 67108864;
|
2834 | };
|
2835 |
|
2836 | Promise.prototype._setLength = function (len) {
|
2837 | this._bitField = (this._bitField & -65536) |
|
2838 | (len & 65535);
|
2839 | };
|
2840 |
|
2841 | Promise.prototype._setFulfilled = function () {
|
2842 | this._bitField = this._bitField | 33554432;
|
2843 | };
|
2844 |
|
2845 | Promise.prototype._setRejected = function () {
|
2846 | this._bitField = this._bitField | 16777216;
|
2847 | };
|
2848 |
|
2849 | Promise.prototype._setFollowing = function () {
|
2850 | this._bitField = this._bitField | 67108864;
|
2851 | };
|
2852 |
|
2853 | Promise.prototype._setIsFinal = function () {
|
2854 | this._bitField = this._bitField | 4194304;
|
2855 | };
|
2856 |
|
2857 | Promise.prototype._isFinal = function () {
|
2858 | return (this._bitField & 4194304) > 0;
|
2859 | };
|
2860 |
|
2861 | Promise.prototype._unsetCancelled = function() {
|
2862 | this._bitField = this._bitField & (~65536);
|
2863 | };
|
2864 |
|
2865 | Promise.prototype._setCancelled = function() {
|
2866 | this._bitField = this._bitField | 65536;
|
2867 | };
|
2868 |
|
2869 | Promise.prototype._setAsyncGuaranteed = function() {
|
2870 | this._bitField = this._bitField | 134217728;
|
2871 | };
|
2872 |
|
2873 | Promise.prototype._receiverAt = function (index) {
|
2874 | var ret = index === 0 ? this._receiver0 : this[
|
2875 | index * 4 - 4 + 3];
|
2876 | if (ret === UNDEFINED_BINDING) {
|
2877 | return undefined;
|
2878 | } else if (ret === undefined && this._isBound()) {
|
2879 | return this._boundValue();
|
2880 | }
|
2881 | return ret;
|
2882 | };
|
2883 |
|
2884 | Promise.prototype._promiseAt = function (index) {
|
2885 | return this[
|
2886 | index * 4 - 4 + 2];
|
2887 | };
|
2888 |
|
2889 | Promise.prototype._fulfillmentHandlerAt = function (index) {
|
2890 | return this[
|
2891 | index * 4 - 4 + 0];
|
2892 | };
|
2893 |
|
2894 | Promise.prototype._rejectionHandlerAt = function (index) {
|
2895 | return this[
|
2896 | index * 4 - 4 + 1];
|
2897 | };
|
2898 |
|
2899 | Promise.prototype._boundValue = function() {};
|
2900 |
|
2901 | Promise.prototype._migrateCallback0 = function (follower) {
|
2902 | var bitField = follower._bitField;
|
2903 | var fulfill = follower._fulfillmentHandler0;
|
2904 | var reject = follower._rejectionHandler0;
|
2905 | var promise = follower._promise0;
|
2906 | var receiver = follower._receiverAt(0);
|
2907 | if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
2908 | this._addCallbacks(fulfill, reject, promise, receiver, null);
|
2909 | };
|
2910 |
|
2911 | Promise.prototype._migrateCallbackAt = function (follower, index) {
|
2912 | var fulfill = follower._fulfillmentHandlerAt(index);
|
2913 | var reject = follower._rejectionHandlerAt(index);
|
2914 | var promise = follower._promiseAt(index);
|
2915 | var receiver = follower._receiverAt(index);
|
2916 | if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
2917 | this._addCallbacks(fulfill, reject, promise, receiver, null);
|
2918 | };
|
2919 |
|
2920 | Promise.prototype._addCallbacks = function (
|
2921 | fulfill,
|
2922 | reject,
|
2923 | promise,
|
2924 | receiver,
|
2925 | domain
|
2926 | ) {
|
2927 | var index = this._length();
|
2928 |
|
2929 | if (index >= 65535 - 4) {
|
2930 | index = 0;
|
2931 | this._setLength(0);
|
2932 | }
|
2933 |
|
2934 | if (index === 0) {
|
2935 | this._promise0 = promise;
|
2936 | this._receiver0 = receiver;
|
2937 | if (typeof fulfill === "function") {
|
2938 | this._fulfillmentHandler0 =
|
2939 | domain === null ? fulfill : domain.bind(fulfill);
|
2940 | }
|
2941 | if (typeof reject === "function") {
|
2942 | this._rejectionHandler0 =
|
2943 | domain === null ? reject : domain.bind(reject);
|
2944 | }
|
2945 | } else {
|
2946 | var base = index * 4 - 4;
|
2947 | this[base + 2] = promise;
|
2948 | this[base + 3] = receiver;
|
2949 | if (typeof fulfill === "function") {
|
2950 | this[base + 0] =
|
2951 | domain === null ? fulfill : domain.bind(fulfill);
|
2952 | }
|
2953 | if (typeof reject === "function") {
|
2954 | this[base + 1] =
|
2955 | domain === null ? reject : domain.bind(reject);
|
2956 | }
|
2957 | }
|
2958 | this._setLength(index + 1);
|
2959 | return index;
|
2960 | };
|
2961 |
|
2962 | Promise.prototype._proxy = function (proxyable, arg) {
|
2963 | this._addCallbacks(undefined, undefined, arg, proxyable, null);
|
2964 | };
|
2965 |
|
2966 | Promise.prototype._resolveCallback = function(value, shouldBind) {
|
2967 | if (((this._bitField & 117506048) !== 0)) return;
|
2968 | if (value === this)
|
2969 | return this._rejectCallback(makeSelfResolutionError(), false);
|
2970 | var maybePromise = tryConvertToPromise(value, this);
|
2971 | if (!(maybePromise instanceof Promise)) return this._fulfill(value);
|
2972 |
|
2973 | if (shouldBind) this._propagateFrom(maybePromise, 2);
|
2974 |
|
2975 | var promise = maybePromise._target();
|
2976 | var bitField = promise._bitField;
|
2977 | if (((bitField & 50397184) === 0)) {
|
2978 | var len = this._length();
|
2979 | if (len > 0) promise._migrateCallback0(this);
|
2980 | for (var i = 1; i < len; ++i) {
|
2981 | promise._migrateCallbackAt(this, i);
|
2982 | }
|
2983 | this._setFollowing();
|
2984 | this._setLength(0);
|
2985 | this._setFollowee(promise);
|
2986 | } else if (((bitField & 33554432) !== 0)) {
|
2987 | this._fulfill(promise._value());
|
2988 | } else if (((bitField & 16777216) !== 0)) {
|
2989 | this._reject(promise._reason());
|
2990 | } else {
|
2991 | var reason = new CancellationError("late cancellation observer");
|
2992 | promise._attachExtraTrace(reason);
|
2993 | this._reject(reason);
|
2994 | }
|
2995 | };
|
2996 |
|
2997 | Promise.prototype._rejectCallback =
|
2998 | function(reason, synchronous, ignoreNonErrorWarnings) {
|
2999 | var trace = util.ensureErrorObject(reason);
|
3000 | var hasStack = trace === reason;
|
3001 | if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
|
3002 | var message = "a promise was rejected with a non-error: " +
|
3003 | util.classString(reason);
|
3004 | this._warn(message, true);
|
3005 | }
|
3006 | this._attachExtraTrace(trace, synchronous ? hasStack : false);
|
3007 | this._reject(reason);
|
3008 | };
|
3009 |
|
3010 | Promise.prototype._resolveFromExecutor = function (executor) {
|
3011 | var promise = this;
|
3012 | this._captureStackTrace();
|
3013 | this._pushContext();
|
3014 | var synchronous = true;
|
3015 | var r = this._execute(executor, function(value) {
|
3016 | promise._resolveCallback(value);
|
3017 | }, function (reason) {
|
3018 | promise._rejectCallback(reason, synchronous);
|
3019 | });
|
3020 | synchronous = false;
|
3021 | this._popContext();
|
3022 |
|
3023 | if (r !== undefined) {
|
3024 | promise._rejectCallback(r, true);
|
3025 | }
|
3026 | };
|
3027 |
|
3028 | Promise.prototype._settlePromiseFromHandler = function (
|
3029 | handler, receiver, value, promise
|
3030 | ) {
|
3031 | var bitField = promise._bitField;
|
3032 | if (((bitField & 65536) !== 0)) return;
|
3033 | promise._pushContext();
|
3034 | var x;
|
3035 | if (receiver === APPLY) {
|
3036 | if (!value || typeof value.length !== "number") {
|
3037 | x = errorObj;
|
3038 | x.e = new TypeError("cannot .spread() a non-array: " +
|
3039 | util.classString(value));
|
3040 | } else {
|
3041 | x = tryCatch(handler).apply(this._boundValue(), value);
|
3042 | }
|
3043 | } else {
|
3044 | x = tryCatch(handler).call(receiver, value);
|
3045 | }
|
3046 | var promiseCreated = promise._popContext();
|
3047 | bitField = promise._bitField;
|
3048 | if (((bitField & 65536) !== 0)) return;
|
3049 |
|
3050 | if (x === NEXT_FILTER) {
|
3051 | promise._reject(value);
|
3052 | } else if (x === errorObj || x === promise) {
|
3053 | var err = x === promise ? makeSelfResolutionError() : x.e;
|
3054 | promise._rejectCallback(err, false);
|
3055 | } else {
|
3056 | debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
|
3057 | promise._resolveCallback(x);
|
3058 | }
|
3059 | };
|
3060 |
|
3061 | Promise.prototype._target = function() {
|
3062 | var ret = this;
|
3063 | while (ret._isFollowing()) ret = ret._followee();
|
3064 | return ret;
|
3065 | };
|
3066 |
|
3067 | Promise.prototype._followee = function() {
|
3068 | return this._rejectionHandler0;
|
3069 | };
|
3070 |
|
3071 | Promise.prototype._setFollowee = function(promise) {
|
3072 | this._rejectionHandler0 = promise;
|
3073 | };
|
3074 |
|
3075 | Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
|
3076 | var isPromise = promise instanceof Promise;
|
3077 | var bitField = this._bitField;
|
3078 | var asyncGuaranteed = ((bitField & 134217728) !== 0);
|
3079 | if (((bitField & 65536) !== 0)) {
|
3080 | if (isPromise) promise._invokeInternalOnCancel();
|
3081 |
|
3082 | if (handler === finallyHandler) {
|
3083 | receiver.cancelPromise = promise;
|
3084 | if (tryCatch(handler).call(receiver, value) === errorObj) {
|
3085 | promise._reject(errorObj.e);
|
3086 | }
|
3087 | } else if (handler === reflectHandler) {
|
3088 | promise._fulfill(reflectHandler.call(receiver));
|
3089 | } else if (receiver instanceof Proxyable) {
|
3090 | receiver._promiseCancelled(promise);
|
3091 | } else if (isPromise || promise instanceof PromiseArray) {
|
3092 | promise._cancel();
|
3093 | } else {
|
3094 | receiver.cancel();
|
3095 | }
|
3096 | } else if (typeof handler === "function") {
|
3097 | if (!isPromise) {
|
3098 | handler.call(receiver, value, promise);
|
3099 | } else {
|
3100 | if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
3101 | this._settlePromiseFromHandler(handler, receiver, value, promise);
|
3102 | }
|
3103 | } else if (receiver instanceof Proxyable) {
|
3104 | if (!receiver._isResolved()) {
|
3105 | if (((bitField & 33554432) !== 0)) {
|
3106 | receiver._promiseFulfilled(value, promise);
|
3107 | } else {
|
3108 | receiver._promiseRejected(value, promise);
|
3109 | }
|
3110 | }
|
3111 | } else if (isPromise) {
|
3112 | if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
3113 | if (((bitField & 33554432) !== 0)) {
|
3114 | promise._fulfill(value);
|
3115 | } else {
|
3116 | promise._reject(value);
|
3117 | }
|
3118 | }
|
3119 | };
|
3120 |
|
3121 | Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
|
3122 | var handler = ctx.handler;
|
3123 | var promise = ctx.promise;
|
3124 | var receiver = ctx.receiver;
|
3125 | var value = ctx.value;
|
3126 | if (typeof handler === "function") {
|
3127 | if (!(promise instanceof Promise)) {
|
3128 | handler.call(receiver, value, promise);
|
3129 | } else {
|
3130 | this._settlePromiseFromHandler(handler, receiver, value, promise);
|
3131 | }
|
3132 | } else if (promise instanceof Promise) {
|
3133 | promise._reject(value);
|
3134 | }
|
3135 | };
|
3136 |
|
3137 | Promise.prototype._settlePromiseCtx = function(ctx) {
|
3138 | this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
|
3139 | };
|
3140 |
|
3141 | Promise.prototype._settlePromise0 = function(handler, value, bitField) {
|
3142 | var promise = this._promise0;
|
3143 | var receiver = this._receiverAt(0);
|
3144 | this._promise0 = undefined;
|
3145 | this._receiver0 = undefined;
|
3146 | this._settlePromise(promise, handler, receiver, value);
|
3147 | };
|
3148 |
|
3149 | Promise.prototype._clearCallbackDataAtIndex = function(index) {
|
3150 | var base = index * 4 - 4;
|
3151 | this[base + 2] =
|
3152 | this[base + 3] =
|
3153 | this[base + 0] =
|
3154 | this[base + 1] = undefined;
|
3155 | };
|
3156 |
|
3157 | Promise.prototype._fulfill = function (value) {
|
3158 | var bitField = this._bitField;
|
3159 | if (((bitField & 117506048) >>> 16)) return;
|
3160 | if (value === this) {
|
3161 | var err = makeSelfResolutionError();
|
3162 | this._attachExtraTrace(err);
|
3163 | return this._reject(err);
|
3164 | }
|
3165 | this._setFulfilled();
|
3166 | this._rejectionHandler0 = value;
|
3167 |
|
3168 | if ((bitField & 65535) > 0) {
|
3169 | if (((bitField & 134217728) !== 0)) {
|
3170 | this._settlePromises();
|
3171 | } else {
|
3172 | async.settlePromises(this);
|
3173 | }
|
3174 | }
|
3175 | };
|
3176 |
|
3177 | Promise.prototype._reject = function (reason) {
|
3178 | var bitField = this._bitField;
|
3179 | if (((bitField & 117506048) >>> 16)) return;
|
3180 | this._setRejected();
|
3181 | this._fulfillmentHandler0 = reason;
|
3182 |
|
3183 | if (this._isFinal()) {
|
3184 | return async.fatalError(reason, util.isNode);
|
3185 | }
|
3186 |
|
3187 | if ((bitField & 65535) > 0) {
|
3188 | if (((bitField & 134217728) !== 0)) {
|
3189 | this._settlePromises();
|
3190 | } else {
|
3191 | async.settlePromises(this);
|
3192 | }
|
3193 | } else {
|
3194 | this._ensurePossibleRejectionHandled();
|
3195 | }
|
3196 | };
|
3197 |
|
3198 | Promise.prototype._fulfillPromises = function (len, value) {
|
3199 | for (var i = 1; i < len; i++) {
|
3200 | var handler = this._fulfillmentHandlerAt(i);
|
3201 | var promise = this._promiseAt(i);
|
3202 | var receiver = this._receiverAt(i);
|
3203 | this._clearCallbackDataAtIndex(i);
|
3204 | this._settlePromise(promise, handler, receiver, value);
|
3205 | }
|
3206 | };
|
3207 |
|
3208 | Promise.prototype._rejectPromises = function (len, reason) {
|
3209 | for (var i = 1; i < len; i++) {
|
3210 | var handler = this._rejectionHandlerAt(i);
|
3211 | var promise = this._promiseAt(i);
|
3212 | var receiver = this._receiverAt(i);
|
3213 | this._clearCallbackDataAtIndex(i);
|
3214 | this._settlePromise(promise, handler, receiver, reason);
|
3215 | }
|
3216 | };
|
3217 |
|
3218 | Promise.prototype._settlePromises = function () {
|
3219 | var bitField = this._bitField;
|
3220 | var len = (bitField & 65535);
|
3221 |
|
3222 | if (len > 0) {
|
3223 | if (((bitField & 16842752) !== 0)) {
|
3224 | var reason = this._fulfillmentHandler0;
|
3225 | this._settlePromise0(this._rejectionHandler0, reason, bitField);
|
3226 | this._rejectPromises(len, reason);
|
3227 | } else {
|
3228 | var value = this._rejectionHandler0;
|
3229 | this._settlePromise0(this._fulfillmentHandler0, value, bitField);
|
3230 | this._fulfillPromises(len, value);
|
3231 | }
|
3232 | this._setLength(0);
|
3233 | }
|
3234 | this._clearCancellationData();
|
3235 | };
|
3236 |
|
3237 | Promise.prototype._settledValue = function() {
|
3238 | var bitField = this._bitField;
|
3239 | if (((bitField & 33554432) !== 0)) {
|
3240 | return this._rejectionHandler0;
|
3241 | } else if (((bitField & 16777216) !== 0)) {
|
3242 | return this._fulfillmentHandler0;
|
3243 | }
|
3244 | };
|
3245 |
|
3246 | function deferResolve(v) {this.promise._resolveCallback(v);}
|
3247 | function deferReject(v) {this.promise._rejectCallback(v, false);}
|
3248 |
|
3249 | Promise.defer = Promise.pending = function() {
|
3250 | debug.deprecated("Promise.defer", "new Promise");
|
3251 | var promise = new Promise(INTERNAL);
|
3252 | return {
|
3253 | promise: promise,
|
3254 | resolve: deferResolve,
|
3255 | reject: deferReject
|
3256 | };
|
3257 | };
|
3258 |
|
3259 | util.notEnumerableProp(Promise,
|
3260 | "_makeSelfResolutionError",
|
3261 | makeSelfResolutionError);
|
3262 |
|
3263 | _dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
|
3264 | debug);
|
3265 | _dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
|
3266 | _dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug);
|
3267 | _dereq_("./direct_resolve")(Promise);
|
3268 | _dereq_("./synchronous_inspection")(Promise);
|
3269 | _dereq_("./join")(
|
3270 | Promise, PromiseArray, tryConvertToPromise, INTERNAL, debug);
|
3271 | Promise.Promise = Promise;
|
3272 | _dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
3273 | _dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
|
3274 | _dereq_('./timers.js')(Promise, INTERNAL);
|
3275 | _dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
|
3276 | _dereq_('./nodeify.js')(Promise);
|
3277 | _dereq_('./call_get.js')(Promise);
|
3278 | _dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
|
3279 | _dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
3280 | _dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
3281 | _dereq_('./settle.js')(Promise, PromiseArray, debug);
|
3282 | _dereq_('./some.js')(Promise, PromiseArray, apiRejection);
|
3283 | _dereq_('./promisify.js')(Promise, INTERNAL);
|
3284 | _dereq_('./any.js')(Promise);
|
3285 | _dereq_('./each.js')(Promise, INTERNAL);
|
3286 | _dereq_('./filter.js')(Promise, INTERNAL);
|
3287 |
|
3288 | util.toFastProperties(Promise);
|
3289 | util.toFastProperties(Promise.prototype);
|
3290 | function fillTypes(value) {
|
3291 | var p = new Promise(INTERNAL);
|
3292 | p._fulfillmentHandler0 = value;
|
3293 | p._rejectionHandler0 = value;
|
3294 | p._promise0 = value;
|
3295 | p._receiver0 = value;
|
3296 | }
|
3297 |
|
3298 |
|
3299 | fillTypes({a: 1});
|
3300 | fillTypes({b: 2});
|
3301 | fillTypes({c: 3});
|
3302 | fillTypes(1);
|
3303 | fillTypes(function(){});
|
3304 | fillTypes(undefined);
|
3305 | fillTypes(false);
|
3306 | fillTypes(new Promise(INTERNAL));
|
3307 | debug.setBounds(Async.firstLineError, util.lastLineError);
|
3308 | return Promise;
|
3309 |
|
3310 | };
|
3311 |
|
3312 | },{"./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){
|
3313 | "use strict";
|
3314 | module.exports = function(Promise, INTERNAL, tryConvertToPromise,
|
3315 | apiRejection, Proxyable) {
|
3316 | var util = _dereq_("./util");
|
3317 | var isArray = util.isArray;
|
3318 |
|
3319 | function toResolutionValue(val) {
|
3320 | switch(val) {
|
3321 | case -2: return [];
|
3322 | case -3: return {};
|
3323 | }
|
3324 | }
|
3325 |
|
3326 | function PromiseArray(values) {
|
3327 | var promise = this._promise = new Promise(INTERNAL);
|
3328 | if (values instanceof Promise) {
|
3329 | promise._propagateFrom(values, 3);
|
3330 | }
|
3331 | promise._setOnCancel(this);
|
3332 | this._values = values;
|
3333 | this._length = 0;
|
3334 | this._totalResolved = 0;
|
3335 | this._init(undefined, -2);
|
3336 | }
|
3337 | util.inherits(PromiseArray, Proxyable);
|
3338 |
|
3339 | PromiseArray.prototype.length = function () {
|
3340 | return this._length;
|
3341 | };
|
3342 |
|
3343 | PromiseArray.prototype.promise = function () {
|
3344 | return this._promise;
|
3345 | };
|
3346 |
|
3347 | PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
|
3348 | var values = tryConvertToPromise(this._values, this._promise);
|
3349 | if (values instanceof Promise) {
|
3350 | values = values._target();
|
3351 | var bitField = values._bitField;
|
3352 | ;
|
3353 | this._values = values;
|
3354 |
|
3355 | if (((bitField & 50397184) === 0)) {
|
3356 | this._promise._setAsyncGuaranteed();
|
3357 | return values._then(
|
3358 | init,
|
3359 | this._reject,
|
3360 | undefined,
|
3361 | this,
|
3362 | resolveValueIfEmpty
|
3363 | );
|
3364 | } else if (((bitField & 33554432) !== 0)) {
|
3365 | values = values._value();
|
3366 | } else if (((bitField & 16777216) !== 0)) {
|
3367 | return this._reject(values._reason());
|
3368 | } else {
|
3369 | return this._cancel();
|
3370 | }
|
3371 | }
|
3372 | values = util.asArray(values);
|
3373 | if (values === null) {
|
3374 | var err = apiRejection(
|
3375 | "expecting an array or an iterable object but got " + util.classString(values)).reason();
|
3376 | this._promise._rejectCallback(err, false);
|
3377 | return;
|
3378 | }
|
3379 |
|
3380 | if (values.length === 0) {
|
3381 | if (resolveValueIfEmpty === -5) {
|
3382 | this._resolveEmptyArray();
|
3383 | }
|
3384 | else {
|
3385 | this._resolve(toResolutionValue(resolveValueIfEmpty));
|
3386 | }
|
3387 | return;
|
3388 | }
|
3389 | this._iterate(values);
|
3390 | };
|
3391 |
|
3392 | PromiseArray.prototype._iterate = function(values) {
|
3393 | var len = this.getActualLength(values.length);
|
3394 | this._length = len;
|
3395 | this._values = this.shouldCopyValues() ? new Array(len) : this._values;
|
3396 | var result = this._promise;
|
3397 | var isResolved = false;
|
3398 | var bitField = null;
|
3399 | for (var i = 0; i < len; ++i) {
|
3400 | var maybePromise = tryConvertToPromise(values[i], result);
|
3401 |
|
3402 | if (maybePromise instanceof Promise) {
|
3403 | maybePromise = maybePromise._target();
|
3404 | bitField = maybePromise._bitField;
|
3405 | } else {
|
3406 | bitField = null;
|
3407 | }
|
3408 |
|
3409 | if (isResolved) {
|
3410 | if (bitField !== null) {
|
3411 | maybePromise.suppressUnhandledRejections();
|
3412 | }
|
3413 | } else if (bitField !== null) {
|
3414 | if (((bitField & 50397184) === 0)) {
|
3415 | maybePromise._proxy(this, i);
|
3416 | this._values[i] = maybePromise;
|
3417 | } else if (((bitField & 33554432) !== 0)) {
|
3418 | isResolved = this._promiseFulfilled(maybePromise._value(), i);
|
3419 | } else if (((bitField & 16777216) !== 0)) {
|
3420 | isResolved = this._promiseRejected(maybePromise._reason(), i);
|
3421 | } else {
|
3422 | isResolved = this._promiseCancelled(i);
|
3423 | }
|
3424 | } else {
|
3425 | isResolved = this._promiseFulfilled(maybePromise, i);
|
3426 | }
|
3427 | }
|
3428 | if (!isResolved) result._setAsyncGuaranteed();
|
3429 | };
|
3430 |
|
3431 | PromiseArray.prototype._isResolved = function () {
|
3432 | return this._values === null;
|
3433 | };
|
3434 |
|
3435 | PromiseArray.prototype._resolve = function (value) {
|
3436 | this._values = null;
|
3437 | this._promise._fulfill(value);
|
3438 | };
|
3439 |
|
3440 | PromiseArray.prototype._cancel = function() {
|
3441 | if (this._isResolved() || !this._promise.isCancellable()) return;
|
3442 | this._values = null;
|
3443 | this._promise._cancel();
|
3444 | };
|
3445 |
|
3446 | PromiseArray.prototype._reject = function (reason) {
|
3447 | this._values = null;
|
3448 | this._promise._rejectCallback(reason, false);
|
3449 | };
|
3450 |
|
3451 | PromiseArray.prototype._promiseFulfilled = function (value, index) {
|
3452 | this._values[index] = value;
|
3453 | var totalResolved = ++this._totalResolved;
|
3454 | if (totalResolved >= this._length) {
|
3455 | this._resolve(this._values);
|
3456 | return true;
|
3457 | }
|
3458 | return false;
|
3459 | };
|
3460 |
|
3461 | PromiseArray.prototype._promiseCancelled = function() {
|
3462 | this._cancel();
|
3463 | return true;
|
3464 | };
|
3465 |
|
3466 | PromiseArray.prototype._promiseRejected = function (reason) {
|
3467 | this._totalResolved++;
|
3468 | this._reject(reason);
|
3469 | return true;
|
3470 | };
|
3471 |
|
3472 | PromiseArray.prototype._resultCancelled = function() {
|
3473 | if (this._isResolved()) return;
|
3474 | var values = this._values;
|
3475 | this._cancel();
|
3476 | if (values instanceof Promise) {
|
3477 | values.cancel();
|
3478 | } else {
|
3479 | for (var i = 0; i < values.length; ++i) {
|
3480 | if (values[i] instanceof Promise) {
|
3481 | values[i].cancel();
|
3482 | }
|
3483 | }
|
3484 | }
|
3485 | };
|
3486 |
|
3487 | PromiseArray.prototype.shouldCopyValues = function () {
|
3488 | return true;
|
3489 | };
|
3490 |
|
3491 | PromiseArray.prototype.getActualLength = function (len) {
|
3492 | return len;
|
3493 | };
|
3494 |
|
3495 | return PromiseArray;
|
3496 | };
|
3497 |
|
3498 | },{"./util":36}],24:[function(_dereq_,module,exports){
|
3499 | "use strict";
|
3500 | module.exports = function(Promise, INTERNAL) {
|
3501 | var THIS = {};
|
3502 | var util = _dereq_("./util");
|
3503 | var nodebackForPromise = _dereq_("./nodeback");
|
3504 | var withAppended = util.withAppended;
|
3505 | var maybeWrapAsError = util.maybeWrapAsError;
|
3506 | var canEvaluate = util.canEvaluate;
|
3507 | var TypeError = _dereq_("./errors").TypeError;
|
3508 | var defaultSuffix = "Async";
|
3509 | var defaultPromisified = {__isPromisified__: true};
|
3510 | var noCopyProps = [
|
3511 | "arity", "length",
|
3512 | "name",
|
3513 | "arguments",
|
3514 | "caller",
|
3515 | "callee",
|
3516 | "prototype",
|
3517 | "__isPromisified__"
|
3518 | ];
|
3519 | var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
|
3520 |
|
3521 | var defaultFilter = function(name) {
|
3522 | return util.isIdentifier(name) &&
|
3523 | name.charAt(0) !== "_" &&
|
3524 | name !== "constructor";
|
3525 | };
|
3526 |
|
3527 | function propsFilter(key) {
|
3528 | return !noCopyPropsPattern.test(key);
|
3529 | }
|
3530 |
|
3531 | function isPromisified(fn) {
|
3532 | try {
|
3533 | return fn.__isPromisified__ === true;
|
3534 | }
|
3535 | catch (e) {
|
3536 | return false;
|
3537 | }
|
3538 | }
|
3539 |
|
3540 | function hasPromisified(obj, key, suffix) {
|
3541 | var val = util.getDataPropertyOrDefault(obj, key + suffix,
|
3542 | defaultPromisified);
|
3543 | return val ? isPromisified(val) : false;
|
3544 | }
|
3545 | function checkValid(ret, suffix, suffixRegexp) {
|
3546 | for (var i = 0; i < ret.length; i += 2) {
|
3547 | var key = ret[i];
|
3548 | if (suffixRegexp.test(key)) {
|
3549 | var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
|
3550 | for (var j = 0; j < ret.length; j += 2) {
|
3551 | if (ret[j] === keyWithoutAsyncSuffix) {
|
3552 | throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/MqrFmX\u000a"
|
3553 | .replace("%s", suffix));
|
3554 | }
|
3555 | }
|
3556 | }
|
3557 | }
|
3558 | }
|
3559 |
|
3560 | function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
|
3561 | var keys = util.inheritedDataKeys(obj);
|
3562 | var ret = [];
|
3563 | for (var i = 0; i < keys.length; ++i) {
|
3564 | var key = keys[i];
|
3565 | var value = obj[key];
|
3566 | var passesDefaultFilter = filter === defaultFilter
|
3567 | ? true : defaultFilter(key, value, obj);
|
3568 | if (typeof value === "function" &&
|
3569 | !isPromisified(value) &&
|
3570 | !hasPromisified(obj, key, suffix) &&
|
3571 | filter(key, value, obj, passesDefaultFilter)) {
|
3572 | ret.push(key, value);
|
3573 | }
|
3574 | }
|
3575 | checkValid(ret, suffix, suffixRegexp);
|
3576 | return ret;
|
3577 | }
|
3578 |
|
3579 | var escapeIdentRegex = function(str) {
|
3580 | return str.replace(/([$])/, "\\$");
|
3581 | };
|
3582 |
|
3583 | var makeNodePromisifiedEval;
|
3584 | if (!true) {
|
3585 | var switchCaseArgumentOrder = function(likelyArgumentCount) {
|
3586 | var ret = [likelyArgumentCount];
|
3587 | var min = Math.max(0, likelyArgumentCount - 1 - 3);
|
3588 | for(var i = likelyArgumentCount - 1; i >= min; --i) {
|
3589 | ret.push(i);
|
3590 | }
|
3591 | for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
|
3592 | ret.push(i);
|
3593 | }
|
3594 | return ret;
|
3595 | };
|
3596 |
|
3597 | var argumentSequence = function(argumentCount) {
|
3598 | return util.filledRange(argumentCount, "_arg", "");
|
3599 | };
|
3600 |
|
3601 | var parameterDeclaration = function(parameterCount) {
|
3602 | return util.filledRange(
|
3603 | Math.max(parameterCount, 3), "_arg", "");
|
3604 | };
|
3605 |
|
3606 | var parameterCount = function(fn) {
|
3607 | if (typeof fn.length === "number") {
|
3608 | return Math.max(Math.min(fn.length, 1023 + 1), 0);
|
3609 | }
|
3610 | return 0;
|
3611 | };
|
3612 |
|
3613 | makeNodePromisifiedEval =
|
3614 | function(callback, receiver, originalName, fn, _, multiArgs) {
|
3615 | var newParameterCount = Math.max(0, parameterCount(fn) - 1);
|
3616 | var argumentOrder = switchCaseArgumentOrder(newParameterCount);
|
3617 | var shouldProxyThis = typeof callback === "string" || receiver === THIS;
|
3618 |
|
3619 | function generateCallForArgumentCount(count) {
|
3620 | var args = argumentSequence(count).join(", ");
|
3621 | var comma = count > 0 ? ", " : "";
|
3622 | var ret;
|
3623 | if (shouldProxyThis) {
|
3624 | ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
|
3625 | } else {
|
3626 | ret = receiver === undefined
|
3627 | ? "ret = callback({{args}}, nodeback); break;\n"
|
3628 | : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
|
3629 | }
|
3630 | return ret.replace("{{args}}", args).replace(", ", comma);
|
3631 | }
|
3632 |
|
3633 | function generateArgumentSwitchCase() {
|
3634 | var ret = "";
|
3635 | for (var i = 0; i < argumentOrder.length; ++i) {
|
3636 | ret += "case " + argumentOrder[i] +":" +
|
3637 | generateCallForArgumentCount(argumentOrder[i]);
|
3638 | }
|
3639 |
|
3640 | ret += " \n\
|
3641 | default: \n\
|
3642 | var args = new Array(len + 1); \n\
|
3643 | var i = 0; \n\
|
3644 | for (var i = 0; i < len; ++i) { \n\
|
3645 | args[i] = arguments[i]; \n\
|
3646 | } \n\
|
3647 | args[i] = nodeback; \n\
|
3648 | [CodeForCall] \n\
|
3649 | break; \n\
|
3650 | ".replace("[CodeForCall]", (shouldProxyThis
|
3651 | ? "ret = callback.apply(this, args);\n"
|
3652 | : "ret = callback.apply(receiver, args);\n"));
|
3653 | return ret;
|
3654 | }
|
3655 |
|
3656 | var getFunctionCode = typeof callback === "string"
|
3657 | ? ("this != null ? this['"+callback+"'] : fn")
|
3658 | : "fn";
|
3659 | var body = "'use strict'; \n\
|
3660 | var ret = function (Parameters) { \n\
|
3661 | 'use strict'; \n\
|
3662 | var len = arguments.length; \n\
|
3663 | var promise = new Promise(INTERNAL); \n\
|
3664 | promise._captureStackTrace(); \n\
|
3665 | var nodeback = nodebackForPromise(promise, " + multiArgs + "); \n\
|
3666 | var ret; \n\
|
3667 | var callback = tryCatch([GetFunctionCode]); \n\
|
3668 | switch(len) { \n\
|
3669 | [CodeForSwitchCase] \n\
|
3670 | } \n\
|
3671 | if (ret === errorObj) { \n\
|
3672 | promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
|
3673 | } \n\
|
3674 | if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); \n\
|
3675 | return promise; \n\
|
3676 | }; \n\
|
3677 | notEnumerableProp(ret, '__isPromisified__', true); \n\
|
3678 | return ret; \n\
|
3679 | ".replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
|
3680 | .replace("[GetFunctionCode]", getFunctionCode);
|
3681 | body = body.replace("Parameters", parameterDeclaration(newParameterCount));
|
3682 | return new Function("Promise",
|
3683 | "fn",
|
3684 | "receiver",
|
3685 | "withAppended",
|
3686 | "maybeWrapAsError",
|
3687 | "nodebackForPromise",
|
3688 | "tryCatch",
|
3689 | "errorObj",
|
3690 | "notEnumerableProp",
|
3691 | "INTERNAL",
|
3692 | body)(
|
3693 | Promise,
|
3694 | fn,
|
3695 | receiver,
|
3696 | withAppended,
|
3697 | maybeWrapAsError,
|
3698 | nodebackForPromise,
|
3699 | util.tryCatch,
|
3700 | util.errorObj,
|
3701 | util.notEnumerableProp,
|
3702 | INTERNAL);
|
3703 | };
|
3704 | }
|
3705 |
|
3706 | function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) {
|
3707 | var defaultThis = (function() {return this;})();
|
3708 | var method = callback;
|
3709 | if (typeof method === "string") {
|
3710 | callback = fn;
|
3711 | }
|
3712 | function promisified() {
|
3713 | var _receiver = receiver;
|
3714 | if (receiver === THIS) _receiver = this;
|
3715 | var promise = new Promise(INTERNAL);
|
3716 | promise._captureStackTrace();
|
3717 | var cb = typeof method === "string" && this !== defaultThis
|
3718 | ? this[method] : callback;
|
3719 | var fn = nodebackForPromise(promise, multiArgs);
|
3720 | try {
|
3721 | cb.apply(_receiver, withAppended(arguments, fn));
|
3722 | } catch(e) {
|
3723 | promise._rejectCallback(maybeWrapAsError(e), true, true);
|
3724 | }
|
3725 | if (!promise._isFateSealed()) promise._setAsyncGuaranteed();
|
3726 | return promise;
|
3727 | }
|
3728 | util.notEnumerableProp(promisified, "__isPromisified__", true);
|
3729 | return promisified;
|
3730 | }
|
3731 |
|
3732 | var makeNodePromisified = canEvaluate
|
3733 | ? makeNodePromisifiedEval
|
3734 | : makeNodePromisifiedClosure;
|
3735 |
|
3736 | function promisifyAll(obj, suffix, filter, promisifier, multiArgs) {
|
3737 | var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
|
3738 | var methods =
|
3739 | promisifiableMethods(obj, suffix, suffixRegexp, filter);
|
3740 |
|
3741 | for (var i = 0, len = methods.length; i < len; i+= 2) {
|
3742 | var key = methods[i];
|
3743 | var fn = methods[i+1];
|
3744 | var promisifiedKey = key + suffix;
|
3745 | if (promisifier === makeNodePromisified) {
|
3746 | obj[promisifiedKey] =
|
3747 | makeNodePromisified(key, THIS, key, fn, suffix, multiArgs);
|
3748 | } else {
|
3749 | var promisified = promisifier(fn, function() {
|
3750 | return makeNodePromisified(key, THIS, key,
|
3751 | fn, suffix, multiArgs);
|
3752 | });
|
3753 | util.notEnumerableProp(promisified, "__isPromisified__", true);
|
3754 | obj[promisifiedKey] = promisified;
|
3755 | }
|
3756 | }
|
3757 | util.toFastProperties(obj);
|
3758 | return obj;
|
3759 | }
|
3760 |
|
3761 | function promisify(callback, receiver, multiArgs) {
|
3762 | return makeNodePromisified(callback, receiver, undefined,
|
3763 | callback, null, multiArgs);
|
3764 | }
|
3765 |
|
3766 | Promise.promisify = function (fn, options) {
|
3767 | if (typeof fn !== "function") {
|
3768 | throw new TypeError("expecting a function but got " + util.classString(fn));
|
3769 | }
|
3770 | if (isPromisified(fn)) {
|
3771 | return fn;
|
3772 | }
|
3773 | options = Object(options);
|
3774 | var receiver = options.context === undefined ? THIS : options.context;
|
3775 | var multiArgs = !!options.multiArgs;
|
3776 | var ret = promisify(fn, receiver, multiArgs);
|
3777 | util.copyDescriptors(fn, ret, propsFilter);
|
3778 | return ret;
|
3779 | };
|
3780 |
|
3781 | Promise.promisifyAll = function (target, options) {
|
3782 | if (typeof target !== "function" && typeof target !== "object") {
|
3783 | throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
3784 | }
|
3785 | options = Object(options);
|
3786 | var multiArgs = !!options.multiArgs;
|
3787 | var suffix = options.suffix;
|
3788 | if (typeof suffix !== "string") suffix = defaultSuffix;
|
3789 | var filter = options.filter;
|
3790 | if (typeof filter !== "function") filter = defaultFilter;
|
3791 | var promisifier = options.promisifier;
|
3792 | if (typeof promisifier !== "function") promisifier = makeNodePromisified;
|
3793 |
|
3794 | if (!util.isIdentifier(suffix)) {
|
3795 | throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
3796 | }
|
3797 |
|
3798 | var keys = util.inheritedDataKeys(target);
|
3799 | for (var i = 0; i < keys.length; ++i) {
|
3800 | var value = target[keys[i]];
|
3801 | if (keys[i] !== "constructor" &&
|
3802 | util.isClass(value)) {
|
3803 | promisifyAll(value.prototype, suffix, filter, promisifier,
|
3804 | multiArgs);
|
3805 | promisifyAll(value, suffix, filter, promisifier, multiArgs);
|
3806 | }
|
3807 | }
|
3808 |
|
3809 | return promisifyAll(target, suffix, filter, promisifier, multiArgs);
|
3810 | };
|
3811 | };
|
3812 |
|
3813 |
|
3814 | },{"./errors":12,"./nodeback":20,"./util":36}],25:[function(_dereq_,module,exports){
|
3815 | "use strict";
|
3816 | module.exports = function(
|
3817 | Promise, PromiseArray, tryConvertToPromise, apiRejection) {
|
3818 | var util = _dereq_("./util");
|
3819 | var isObject = util.isObject;
|
3820 | var es5 = _dereq_("./es5");
|
3821 | var Es6Map;
|
3822 | if (typeof Map === "function") Es6Map = Map;
|
3823 |
|
3824 | var mapToEntries = (function() {
|
3825 | var index = 0;
|
3826 | var size = 0;
|
3827 |
|
3828 | function extractEntry(value, key) {
|
3829 | this[index] = value;
|
3830 | this[index + size] = key;
|
3831 | index++;
|
3832 | }
|
3833 |
|
3834 | return function mapToEntries(map) {
|
3835 | size = map.size;
|
3836 | index = 0;
|
3837 | var ret = new Array(map.size * 2);
|
3838 | map.forEach(extractEntry, ret);
|
3839 | return ret;
|
3840 | };
|
3841 | })();
|
3842 |
|
3843 | var entriesToMap = function(entries) {
|
3844 | var ret = new Es6Map();
|
3845 | var length = entries.length / 2 | 0;
|
3846 | for (var i = 0; i < length; ++i) {
|
3847 | var key = entries[length + i];
|
3848 | var value = entries[i];
|
3849 | ret.set(key, value);
|
3850 | }
|
3851 | return ret;
|
3852 | };
|
3853 |
|
3854 | function PropertiesPromiseArray(obj) {
|
3855 | var isMap = false;
|
3856 | var entries;
|
3857 | if (Es6Map !== undefined && obj instanceof Es6Map) {
|
3858 | entries = mapToEntries(obj);
|
3859 | isMap = true;
|
3860 | } else {
|
3861 | var keys = es5.keys(obj);
|
3862 | var len = keys.length;
|
3863 | entries = new Array(len * 2);
|
3864 | for (var i = 0; i < len; ++i) {
|
3865 | var key = keys[i];
|
3866 | entries[i] = obj[key];
|
3867 | entries[i + len] = key;
|
3868 | }
|
3869 | }
|
3870 | this.constructor$(entries);
|
3871 | this._isMap = isMap;
|
3872 | this._init$(undefined, -3);
|
3873 | }
|
3874 | util.inherits(PropertiesPromiseArray, PromiseArray);
|
3875 |
|
3876 | PropertiesPromiseArray.prototype._init = function () {};
|
3877 |
|
3878 | PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
3879 | this._values[index] = value;
|
3880 | var totalResolved = ++this._totalResolved;
|
3881 | if (totalResolved >= this._length) {
|
3882 | var val;
|
3883 | if (this._isMap) {
|
3884 | val = entriesToMap(this._values);
|
3885 | } else {
|
3886 | val = {};
|
3887 | var keyOffset = this.length();
|
3888 | for (var i = 0, len = this.length(); i < len; ++i) {
|
3889 | val[this._values[i + keyOffset]] = this._values[i];
|
3890 | }
|
3891 | }
|
3892 | this._resolve(val);
|
3893 | return true;
|
3894 | }
|
3895 | return false;
|
3896 | };
|
3897 |
|
3898 | PropertiesPromiseArray.prototype.shouldCopyValues = function () {
|
3899 | return false;
|
3900 | };
|
3901 |
|
3902 | PropertiesPromiseArray.prototype.getActualLength = function (len) {
|
3903 | return len >> 1;
|
3904 | };
|
3905 |
|
3906 | function props(promises) {
|
3907 | var ret;
|
3908 | var castValue = tryConvertToPromise(promises);
|
3909 |
|
3910 | if (!isObject(castValue)) {
|
3911 | return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
3912 | } else if (castValue instanceof Promise) {
|
3913 | ret = castValue._then(
|
3914 | Promise.props, undefined, undefined, undefined, undefined);
|
3915 | } else {
|
3916 | ret = new PropertiesPromiseArray(castValue).promise();
|
3917 | }
|
3918 |
|
3919 | if (castValue instanceof Promise) {
|
3920 | ret._propagateFrom(castValue, 2);
|
3921 | }
|
3922 | return ret;
|
3923 | }
|
3924 |
|
3925 | Promise.prototype.props = function () {
|
3926 | return props(this);
|
3927 | };
|
3928 |
|
3929 | Promise.props = function (promises) {
|
3930 | return props(promises);
|
3931 | };
|
3932 | };
|
3933 |
|
3934 | },{"./es5":13,"./util":36}],26:[function(_dereq_,module,exports){
|
3935 | "use strict";
|
3936 | function arrayMove(src, srcIndex, dst, dstIndex, len) {
|
3937 | for (var j = 0; j < len; ++j) {
|
3938 | dst[j + dstIndex] = src[j + srcIndex];
|
3939 | src[j + srcIndex] = void 0;
|
3940 | }
|
3941 | }
|
3942 |
|
3943 | function Queue(capacity) {
|
3944 | this._capacity = capacity;
|
3945 | this._length = 0;
|
3946 | this._front = 0;
|
3947 | }
|
3948 |
|
3949 | Queue.prototype._willBeOverCapacity = function (size) {
|
3950 | return this._capacity < size;
|
3951 | };
|
3952 |
|
3953 | Queue.prototype._pushOne = function (arg) {
|
3954 | var length = this.length();
|
3955 | this._checkCapacity(length + 1);
|
3956 | var i = (this._front + length) & (this._capacity - 1);
|
3957 | this[i] = arg;
|
3958 | this._length = length + 1;
|
3959 | };
|
3960 |
|
3961 | Queue.prototype._unshiftOne = function(value) {
|
3962 | var capacity = this._capacity;
|
3963 | this._checkCapacity(this.length() + 1);
|
3964 | var front = this._front;
|
3965 | var i = (((( front - 1 ) &
|
3966 | ( capacity - 1) ) ^ capacity ) - capacity );
|
3967 | this[i] = value;
|
3968 | this._front = i;
|
3969 | this._length = this.length() + 1;
|
3970 | };
|
3971 |
|
3972 | Queue.prototype.unshift = function(fn, receiver, arg) {
|
3973 | this._unshiftOne(arg);
|
3974 | this._unshiftOne(receiver);
|
3975 | this._unshiftOne(fn);
|
3976 | };
|
3977 |
|
3978 | Queue.prototype.push = function (fn, receiver, arg) {
|
3979 | var length = this.length() + 3;
|
3980 | if (this._willBeOverCapacity(length)) {
|
3981 | this._pushOne(fn);
|
3982 | this._pushOne(receiver);
|
3983 | this._pushOne(arg);
|
3984 | return;
|
3985 | }
|
3986 | var j = this._front + length - 3;
|
3987 | this._checkCapacity(length);
|
3988 | var wrapMask = this._capacity - 1;
|
3989 | this[(j + 0) & wrapMask] = fn;
|
3990 | this[(j + 1) & wrapMask] = receiver;
|
3991 | this[(j + 2) & wrapMask] = arg;
|
3992 | this._length = length;
|
3993 | };
|
3994 |
|
3995 | Queue.prototype.shift = function () {
|
3996 | var front = this._front,
|
3997 | ret = this[front];
|
3998 |
|
3999 | this[front] = undefined;
|
4000 | this._front = (front + 1) & (this._capacity - 1);
|
4001 | this._length--;
|
4002 | return ret;
|
4003 | };
|
4004 |
|
4005 | Queue.prototype.length = function () {
|
4006 | return this._length;
|
4007 | };
|
4008 |
|
4009 | Queue.prototype._checkCapacity = function (size) {
|
4010 | if (this._capacity < size) {
|
4011 | this._resizeTo(this._capacity << 1);
|
4012 | }
|
4013 | };
|
4014 |
|
4015 | Queue.prototype._resizeTo = function (capacity) {
|
4016 | var oldCapacity = this._capacity;
|
4017 | this._capacity = capacity;
|
4018 | var front = this._front;
|
4019 | var length = this._length;
|
4020 | var moveItemsCount = (front + length) & (oldCapacity - 1);
|
4021 | arrayMove(this, 0, this, oldCapacity, moveItemsCount);
|
4022 | };
|
4023 |
|
4024 | module.exports = Queue;
|
4025 |
|
4026 | },{}],27:[function(_dereq_,module,exports){
|
4027 | "use strict";
|
4028 | module.exports = function(
|
4029 | Promise, INTERNAL, tryConvertToPromise, apiRejection) {
|
4030 | var util = _dereq_("./util");
|
4031 |
|
4032 | var raceLater = function (promise) {
|
4033 | return promise.then(function(array) {
|
4034 | return race(array, promise);
|
4035 | });
|
4036 | };
|
4037 |
|
4038 | function race(promises, parent) {
|
4039 | var maybePromise = tryConvertToPromise(promises);
|
4040 |
|
4041 | if (maybePromise instanceof Promise) {
|
4042 | return raceLater(maybePromise);
|
4043 | } else {
|
4044 | promises = util.asArray(promises);
|
4045 | if (promises === null)
|
4046 | return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
|
4047 | }
|
4048 |
|
4049 | var ret = new Promise(INTERNAL);
|
4050 | if (parent !== undefined) {
|
4051 | ret._propagateFrom(parent, 3);
|
4052 | }
|
4053 | var fulfill = ret._fulfill;
|
4054 | var reject = ret._reject;
|
4055 | for (var i = 0, len = promises.length; i < len; ++i) {
|
4056 | var val = promises[i];
|
4057 |
|
4058 | if (val === undefined && !(i in promises)) {
|
4059 | continue;
|
4060 | }
|
4061 |
|
4062 | Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
|
4063 | }
|
4064 | return ret;
|
4065 | }
|
4066 |
|
4067 | Promise.race = function (promises) {
|
4068 | return race(promises, undefined);
|
4069 | };
|
4070 |
|
4071 | Promise.prototype.race = function () {
|
4072 | return race(this, undefined);
|
4073 | };
|
4074 |
|
4075 | };
|
4076 |
|
4077 | },{"./util":36}],28:[function(_dereq_,module,exports){
|
4078 | "use strict";
|
4079 | module.exports = function(Promise,
|
4080 | PromiseArray,
|
4081 | apiRejection,
|
4082 | tryConvertToPromise,
|
4083 | INTERNAL,
|
4084 | debug) {
|
4085 | var getDomain = Promise._getDomain;
|
4086 | var util = _dereq_("./util");
|
4087 | var tryCatch = util.tryCatch;
|
4088 |
|
4089 | function ReductionPromiseArray(promises, fn, initialValue, _each) {
|
4090 | this.constructor$(promises);
|
4091 | var domain = getDomain();
|
4092 | this._fn = domain === null ? fn : domain.bind(fn);
|
4093 | if (initialValue !== undefined) {
|
4094 | initialValue = Promise.resolve(initialValue);
|
4095 | initialValue._attachCancellationCallback(this);
|
4096 | }
|
4097 | this._initialValue = initialValue;
|
4098 | this._currentCancellable = null;
|
4099 | this._eachValues = _each === INTERNAL ? [] : undefined;
|
4100 | this._promise._captureStackTrace();
|
4101 | this._init$(undefined, -5);
|
4102 | }
|
4103 | util.inherits(ReductionPromiseArray, PromiseArray);
|
4104 |
|
4105 | ReductionPromiseArray.prototype._gotAccum = function(accum) {
|
4106 | if (this._eachValues !== undefined && accum !== INTERNAL) {
|
4107 | this._eachValues.push(accum);
|
4108 | }
|
4109 | };
|
4110 |
|
4111 | ReductionPromiseArray.prototype._eachComplete = function(value) {
|
4112 | this._eachValues.push(value);
|
4113 | return this._eachValues;
|
4114 | };
|
4115 |
|
4116 | ReductionPromiseArray.prototype._init = function() {};
|
4117 |
|
4118 | ReductionPromiseArray.prototype._resolveEmptyArray = function() {
|
4119 | this._resolve(this._eachValues !== undefined ? this._eachValues
|
4120 | : this._initialValue);
|
4121 | };
|
4122 |
|
4123 | ReductionPromiseArray.prototype.shouldCopyValues = function () {
|
4124 | return false;
|
4125 | };
|
4126 |
|
4127 | ReductionPromiseArray.prototype._resolve = function(value) {
|
4128 | this._promise._resolveCallback(value);
|
4129 | this._values = null;
|
4130 | };
|
4131 |
|
4132 | ReductionPromiseArray.prototype._resultCancelled = function(sender) {
|
4133 | if (sender === this._initialValue) return this._cancel();
|
4134 | if (this._isResolved()) return;
|
4135 | this._resultCancelled$();
|
4136 | if (this._currentCancellable instanceof Promise) {
|
4137 | this._currentCancellable.cancel();
|
4138 | }
|
4139 | if (this._initialValue instanceof Promise) {
|
4140 | this._initialValue.cancel();
|
4141 | }
|
4142 | };
|
4143 |
|
4144 | ReductionPromiseArray.prototype._iterate = function (values) {
|
4145 | this._values = values;
|
4146 | var value;
|
4147 | var i;
|
4148 | var length = values.length;
|
4149 | if (this._initialValue !== undefined) {
|
4150 | value = this._initialValue;
|
4151 | i = 0;
|
4152 | } else {
|
4153 | value = Promise.resolve(values[0]);
|
4154 | i = 1;
|
4155 | }
|
4156 |
|
4157 | this._currentCancellable = value;
|
4158 |
|
4159 | if (!value.isRejected()) {
|
4160 | for (; i < length; ++i) {
|
4161 | var ctx = {
|
4162 | accum: null,
|
4163 | value: values[i],
|
4164 | index: i,
|
4165 | length: length,
|
4166 | array: this
|
4167 | };
|
4168 | value = value._then(gotAccum, undefined, undefined, ctx, undefined);
|
4169 | }
|
4170 | }
|
4171 |
|
4172 | if (this._eachValues !== undefined) {
|
4173 | value = value
|
4174 | ._then(this._eachComplete, undefined, undefined, this, undefined);
|
4175 | }
|
4176 | value._then(completed, completed, undefined, value, this);
|
4177 | };
|
4178 |
|
4179 | Promise.prototype.reduce = function (fn, initialValue) {
|
4180 | return reduce(this, fn, initialValue, null);
|
4181 | };
|
4182 |
|
4183 | Promise.reduce = function (promises, fn, initialValue, _each) {
|
4184 | return reduce(promises, fn, initialValue, _each);
|
4185 | };
|
4186 |
|
4187 | function completed(valueOrReason, array) {
|
4188 | if (this.isFulfilled()) {
|
4189 | array._resolve(valueOrReason);
|
4190 | } else {
|
4191 | array._reject(valueOrReason);
|
4192 | }
|
4193 | }
|
4194 |
|
4195 | function reduce(promises, fn, initialValue, _each) {
|
4196 | if (typeof fn !== "function") {
|
4197 | return apiRejection("expecting a function but got " + util.classString(fn));
|
4198 | }
|
4199 | var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
|
4200 | return array.promise();
|
4201 | }
|
4202 |
|
4203 | function gotAccum(accum) {
|
4204 | this.accum = accum;
|
4205 | this.array._gotAccum(accum);
|
4206 | var value = tryConvertToPromise(this.value, this.array._promise);
|
4207 | if (value instanceof Promise) {
|
4208 | this.array._currentCancellable = value;
|
4209 | return value._then(gotValue, undefined, undefined, this, undefined);
|
4210 | } else {
|
4211 | return gotValue.call(this, value);
|
4212 | }
|
4213 | }
|
4214 |
|
4215 | function gotValue(value) {
|
4216 | var array = this.array;
|
4217 | var promise = array._promise;
|
4218 | var fn = tryCatch(array._fn);
|
4219 | promise._pushContext();
|
4220 | var ret;
|
4221 | if (array._eachValues !== undefined) {
|
4222 | ret = fn.call(promise._boundValue(), value, this.index, this.length);
|
4223 | } else {
|
4224 | ret = fn.call(promise._boundValue(),
|
4225 | this.accum, value, this.index, this.length);
|
4226 | }
|
4227 | if (ret instanceof Promise) {
|
4228 | array._currentCancellable = ret;
|
4229 | }
|
4230 | var promiseCreated = promise._popContext();
|
4231 | debug.checkForgottenReturns(
|
4232 | ret,
|
4233 | promiseCreated,
|
4234 | array._eachValues !== undefined ? "Promise.each" : "Promise.reduce",
|
4235 | promise
|
4236 | );
|
4237 | return ret;
|
4238 | }
|
4239 | };
|
4240 |
|
4241 | },{"./util":36}],29:[function(_dereq_,module,exports){
|
4242 | "use strict";
|
4243 | var util = _dereq_("./util");
|
4244 | var schedule;
|
4245 | var noAsyncScheduler = function() {
|
4246 | throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
4247 | };
|
4248 | if (util.isNode && typeof MutationObserver === "undefined") {
|
4249 | var GlobalSetImmediate = global.setImmediate;
|
4250 | var ProcessNextTick = process.nextTick;
|
4251 | schedule = util.isRecentNode
|
4252 | ? function(fn) { GlobalSetImmediate.call(global, fn); }
|
4253 | : function(fn) { ProcessNextTick.call(process, fn); };
|
4254 | } else if ((typeof MutationObserver !== "undefined") &&
|
4255 | !(typeof window !== "undefined" &&
|
4256 | window.navigator &&
|
4257 | window.navigator.standalone)) {
|
4258 | schedule = (function() {
|
4259 | var div = document.createElement("div");
|
4260 | var opts = {attributes: true};
|
4261 | var toggleScheduled = false;
|
4262 | var div2 = document.createElement("div");
|
4263 | var o2 = new MutationObserver(function() {
|
4264 | div.classList.toggle("foo");
|
4265 | toggleScheduled = false;
|
4266 | });
|
4267 | o2.observe(div2, opts);
|
4268 |
|
4269 | var scheduleToggle = function() {
|
4270 | if (toggleScheduled) return;
|
4271 | toggleScheduled = true;
|
4272 | div2.classList.toggle("foo");
|
4273 | };
|
4274 |
|
4275 | return function schedule(fn) {
|
4276 | var o = new MutationObserver(function() {
|
4277 | o.disconnect();
|
4278 | fn();
|
4279 | });
|
4280 | o.observe(div, opts);
|
4281 | scheduleToggle();
|
4282 | };
|
4283 | })();
|
4284 | } else if (typeof setImmediate !== "undefined") {
|
4285 | schedule = function (fn) {
|
4286 | setImmediate(fn);
|
4287 | };
|
4288 | } else if (typeof setTimeout !== "undefined") {
|
4289 | schedule = function (fn) {
|
4290 | setTimeout(fn, 0);
|
4291 | };
|
4292 | } else {
|
4293 | schedule = noAsyncScheduler;
|
4294 | }
|
4295 | module.exports = schedule;
|
4296 |
|
4297 | },{"./util":36}],30:[function(_dereq_,module,exports){
|
4298 | "use strict";
|
4299 | module.exports =
|
4300 | function(Promise, PromiseArray, debug) {
|
4301 | var PromiseInspection = Promise.PromiseInspection;
|
4302 | var util = _dereq_("./util");
|
4303 |
|
4304 | function SettledPromiseArray(values) {
|
4305 | this.constructor$(values);
|
4306 | }
|
4307 | util.inherits(SettledPromiseArray, PromiseArray);
|
4308 |
|
4309 | SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
|
4310 | this._values[index] = inspection;
|
4311 | var totalResolved = ++this._totalResolved;
|
4312 | if (totalResolved >= this._length) {
|
4313 | this._resolve(this._values);
|
4314 | return true;
|
4315 | }
|
4316 | return false;
|
4317 | };
|
4318 |
|
4319 | SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
4320 | var ret = new PromiseInspection();
|
4321 | ret._bitField = 33554432;
|
4322 | ret._settledValueField = value;
|
4323 | return this._promiseResolved(index, ret);
|
4324 | };
|
4325 | SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
|
4326 | var ret = new PromiseInspection();
|
4327 | ret._bitField = 16777216;
|
4328 | ret._settledValueField = reason;
|
4329 | return this._promiseResolved(index, ret);
|
4330 | };
|
4331 |
|
4332 | Promise.settle = function (promises) {
|
4333 | debug.deprecated(".settle()", ".reflect()");
|
4334 | return new SettledPromiseArray(promises).promise();
|
4335 | };
|
4336 |
|
4337 | Promise.prototype.settle = function () {
|
4338 | return Promise.settle(this);
|
4339 | };
|
4340 | };
|
4341 |
|
4342 | },{"./util":36}],31:[function(_dereq_,module,exports){
|
4343 | "use strict";
|
4344 | module.exports =
|
4345 | function(Promise, PromiseArray, apiRejection) {
|
4346 | var util = _dereq_("./util");
|
4347 | var RangeError = _dereq_("./errors").RangeError;
|
4348 | var AggregateError = _dereq_("./errors").AggregateError;
|
4349 | var isArray = util.isArray;
|
4350 | var CANCELLATION = {};
|
4351 |
|
4352 |
|
4353 | function SomePromiseArray(values) {
|
4354 | this.constructor$(values);
|
4355 | this._howMany = 0;
|
4356 | this._unwrap = false;
|
4357 | this._initialized = false;
|
4358 | }
|
4359 | util.inherits(SomePromiseArray, PromiseArray);
|
4360 |
|
4361 | SomePromiseArray.prototype._init = function () {
|
4362 | if (!this._initialized) {
|
4363 | return;
|
4364 | }
|
4365 | if (this._howMany === 0) {
|
4366 | this._resolve([]);
|
4367 | return;
|
4368 | }
|
4369 | this._init$(undefined, -5);
|
4370 | var isArrayResolved = isArray(this._values);
|
4371 | if (!this._isResolved() &&
|
4372 | isArrayResolved &&
|
4373 | this._howMany > this._canPossiblyFulfill()) {
|
4374 | this._reject(this._getRangeError(this.length()));
|
4375 | }
|
4376 | };
|
4377 |
|
4378 | SomePromiseArray.prototype.init = function () {
|
4379 | this._initialized = true;
|
4380 | this._init();
|
4381 | };
|
4382 |
|
4383 | SomePromiseArray.prototype.setUnwrap = function () {
|
4384 | this._unwrap = true;
|
4385 | };
|
4386 |
|
4387 | SomePromiseArray.prototype.howMany = function () {
|
4388 | return this._howMany;
|
4389 | };
|
4390 |
|
4391 | SomePromiseArray.prototype.setHowMany = function (count) {
|
4392 | this._howMany = count;
|
4393 | };
|
4394 |
|
4395 | SomePromiseArray.prototype._promiseFulfilled = function (value) {
|
4396 | this._addFulfilled(value);
|
4397 | if (this._fulfilled() === this.howMany()) {
|
4398 | this._values.length = this.howMany();
|
4399 | if (this.howMany() === 1 && this._unwrap) {
|
4400 | this._resolve(this._values[0]);
|
4401 | } else {
|
4402 | this._resolve(this._values);
|
4403 | }
|
4404 | return true;
|
4405 | }
|
4406 | return false;
|
4407 |
|
4408 | };
|
4409 | SomePromiseArray.prototype._promiseRejected = function (reason) {
|
4410 | this._addRejected(reason);
|
4411 | return this._checkOutcome();
|
4412 | };
|
4413 |
|
4414 | SomePromiseArray.prototype._promiseCancelled = function () {
|
4415 | if (this._values instanceof Promise || this._values == null) {
|
4416 | return this._cancel();
|
4417 | }
|
4418 | this._addRejected(CANCELLATION);
|
4419 | return this._checkOutcome();
|
4420 | };
|
4421 |
|
4422 | SomePromiseArray.prototype._checkOutcome = function() {
|
4423 | if (this.howMany() > this._canPossiblyFulfill()) {
|
4424 | var e = new AggregateError();
|
4425 | for (var i = this.length(); i < this._values.length; ++i) {
|
4426 | if (this._values[i] !== CANCELLATION) {
|
4427 | e.push(this._values[i]);
|
4428 | }
|
4429 | }
|
4430 | if (e.length > 0) {
|
4431 | this._reject(e);
|
4432 | } else {
|
4433 | this._cancel();
|
4434 | }
|
4435 | return true;
|
4436 | }
|
4437 | return false;
|
4438 | };
|
4439 |
|
4440 | SomePromiseArray.prototype._fulfilled = function () {
|
4441 | return this._totalResolved;
|
4442 | };
|
4443 |
|
4444 | SomePromiseArray.prototype._rejected = function () {
|
4445 | return this._values.length - this.length();
|
4446 | };
|
4447 |
|
4448 | SomePromiseArray.prototype._addRejected = function (reason) {
|
4449 | this._values.push(reason);
|
4450 | };
|
4451 |
|
4452 | SomePromiseArray.prototype._addFulfilled = function (value) {
|
4453 | this._values[this._totalResolved++] = value;
|
4454 | };
|
4455 |
|
4456 | SomePromiseArray.prototype._canPossiblyFulfill = function () {
|
4457 | return this.length() - this._rejected();
|
4458 | };
|
4459 |
|
4460 | SomePromiseArray.prototype._getRangeError = function (count) {
|
4461 | var message = "Input array must contain at least " +
|
4462 | this._howMany + " items but contains only " + count + " items";
|
4463 | return new RangeError(message);
|
4464 | };
|
4465 |
|
4466 | SomePromiseArray.prototype._resolveEmptyArray = function () {
|
4467 | this._reject(this._getRangeError(0));
|
4468 | };
|
4469 |
|
4470 | function some(promises, howMany) {
|
4471 | if ((howMany | 0) !== howMany || howMany < 0) {
|
4472 | return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
4473 | }
|
4474 | var ret = new SomePromiseArray(promises);
|
4475 | var promise = ret.promise();
|
4476 | ret.setHowMany(howMany);
|
4477 | ret.init();
|
4478 | return promise;
|
4479 | }
|
4480 |
|
4481 | Promise.some = function (promises, howMany) {
|
4482 | return some(promises, howMany);
|
4483 | };
|
4484 |
|
4485 | Promise.prototype.some = function (howMany) {
|
4486 | return some(this, howMany);
|
4487 | };
|
4488 |
|
4489 | Promise._SomePromiseArray = SomePromiseArray;
|
4490 | };
|
4491 |
|
4492 | },{"./errors":12,"./util":36}],32:[function(_dereq_,module,exports){
|
4493 | "use strict";
|
4494 | module.exports = function(Promise) {
|
4495 | function PromiseInspection(promise) {
|
4496 | if (promise !== undefined) {
|
4497 | promise = promise._target();
|
4498 | this._bitField = promise._bitField;
|
4499 | this._settledValueField = promise._isFateSealed()
|
4500 | ? promise._settledValue() : undefined;
|
4501 | }
|
4502 | else {
|
4503 | this._bitField = 0;
|
4504 | this._settledValueField = undefined;
|
4505 | }
|
4506 | }
|
4507 |
|
4508 | PromiseInspection.prototype._settledValue = function() {
|
4509 | return this._settledValueField;
|
4510 | };
|
4511 |
|
4512 | var value = PromiseInspection.prototype.value = function () {
|
4513 | if (!this.isFulfilled()) {
|
4514 | throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
4515 | }
|
4516 | return this._settledValue();
|
4517 | };
|
4518 |
|
4519 | var reason = PromiseInspection.prototype.error =
|
4520 | PromiseInspection.prototype.reason = function () {
|
4521 | if (!this.isRejected()) {
|
4522 | throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
4523 | }
|
4524 | return this._settledValue();
|
4525 | };
|
4526 |
|
4527 | var isFulfilled = PromiseInspection.prototype.isFulfilled = function() {
|
4528 | return (this._bitField & 33554432) !== 0;
|
4529 | };
|
4530 |
|
4531 | var isRejected = PromiseInspection.prototype.isRejected = function () {
|
4532 | return (this._bitField & 16777216) !== 0;
|
4533 | };
|
4534 |
|
4535 | var isPending = PromiseInspection.prototype.isPending = function () {
|
4536 | return (this._bitField & 50397184) === 0;
|
4537 | };
|
4538 |
|
4539 | var isResolved = PromiseInspection.prototype.isResolved = function () {
|
4540 | return (this._bitField & 50331648) !== 0;
|
4541 | };
|
4542 |
|
4543 | PromiseInspection.prototype.isCancelled =
|
4544 | Promise.prototype._isCancelled = function() {
|
4545 | return (this._bitField & 65536) === 65536;
|
4546 | };
|
4547 |
|
4548 | Promise.prototype.isCancelled = function() {
|
4549 | return this._target()._isCancelled();
|
4550 | };
|
4551 |
|
4552 | Promise.prototype.isPending = function() {
|
4553 | return isPending.call(this._target());
|
4554 | };
|
4555 |
|
4556 | Promise.prototype.isRejected = function() {
|
4557 | return isRejected.call(this._target());
|
4558 | };
|
4559 |
|
4560 | Promise.prototype.isFulfilled = function() {
|
4561 | return isFulfilled.call(this._target());
|
4562 | };
|
4563 |
|
4564 | Promise.prototype.isResolved = function() {
|
4565 | return isResolved.call(this._target());
|
4566 | };
|
4567 |
|
4568 | Promise.prototype.value = function() {
|
4569 | return value.call(this._target());
|
4570 | };
|
4571 |
|
4572 | Promise.prototype.reason = function() {
|
4573 | var target = this._target();
|
4574 | target._unsetRejectionIsUnhandled();
|
4575 | return reason.call(target);
|
4576 | };
|
4577 |
|
4578 | Promise.prototype._value = function() {
|
4579 | return this._settledValue();
|
4580 | };
|
4581 |
|
4582 | Promise.prototype._reason = function() {
|
4583 | this._unsetRejectionIsUnhandled();
|
4584 | return this._settledValue();
|
4585 | };
|
4586 |
|
4587 | Promise.PromiseInspection = PromiseInspection;
|
4588 | };
|
4589 |
|
4590 | },{}],33:[function(_dereq_,module,exports){
|
4591 | "use strict";
|
4592 | module.exports = function(Promise, INTERNAL) {
|
4593 | var util = _dereq_("./util");
|
4594 | var errorObj = util.errorObj;
|
4595 | var isObject = util.isObject;
|
4596 |
|
4597 | function tryConvertToPromise(obj, context) {
|
4598 | if (isObject(obj)) {
|
4599 | if (obj instanceof Promise) return obj;
|
4600 | var then = getThen(obj);
|
4601 | if (then === errorObj) {
|
4602 | if (context) context._pushContext();
|
4603 | var ret = Promise.reject(then.e);
|
4604 | if (context) context._popContext();
|
4605 | return ret;
|
4606 | } else if (typeof then === "function") {
|
4607 | if (isAnyBluebirdPromise(obj)) {
|
4608 | var ret = new Promise(INTERNAL);
|
4609 | obj._then(
|
4610 | ret._fulfill,
|
4611 | ret._reject,
|
4612 | undefined,
|
4613 | ret,
|
4614 | null
|
4615 | );
|
4616 | return ret;
|
4617 | }
|
4618 | return doThenable(obj, then, context);
|
4619 | }
|
4620 | }
|
4621 | return obj;
|
4622 | }
|
4623 |
|
4624 | function doGetThen(obj) {
|
4625 | return obj.then;
|
4626 | }
|
4627 |
|
4628 | function getThen(obj) {
|
4629 | try {
|
4630 | return doGetThen(obj);
|
4631 | } catch (e) {
|
4632 | errorObj.e = e;
|
4633 | return errorObj;
|
4634 | }
|
4635 | }
|
4636 |
|
4637 | var hasProp = {}.hasOwnProperty;
|
4638 | function isAnyBluebirdPromise(obj) {
|
4639 | return hasProp.call(obj, "_promise0");
|
4640 | }
|
4641 |
|
4642 | function doThenable(x, then, context) {
|
4643 | var promise = new Promise(INTERNAL);
|
4644 | var ret = promise;
|
4645 | if (context) context._pushContext();
|
4646 | promise._captureStackTrace();
|
4647 | if (context) context._popContext();
|
4648 | var synchronous = true;
|
4649 | var result = util.tryCatch(then).call(x, resolve, reject);
|
4650 | synchronous = false;
|
4651 |
|
4652 | if (promise && result === errorObj) {
|
4653 | promise._rejectCallback(result.e, true, true);
|
4654 | promise = null;
|
4655 | }
|
4656 |
|
4657 | function resolve(value) {
|
4658 | if (!promise) return;
|
4659 | promise._resolveCallback(value);
|
4660 | promise = null;
|
4661 | }
|
4662 |
|
4663 | function reject(reason) {
|
4664 | if (!promise) return;
|
4665 | promise._rejectCallback(reason, synchronous, true);
|
4666 | promise = null;
|
4667 | }
|
4668 | return ret;
|
4669 | }
|
4670 |
|
4671 | return tryConvertToPromise;
|
4672 | };
|
4673 |
|
4674 | },{"./util":36}],34:[function(_dereq_,module,exports){
|
4675 | "use strict";
|
4676 | module.exports = function(Promise, INTERNAL) {
|
4677 | var util = _dereq_("./util");
|
4678 | var TimeoutError = Promise.TimeoutError;
|
4679 |
|
4680 | var afterTimeout = function (promise, message, parent) {
|
4681 | if (!promise.isPending()) return;
|
4682 | var err;
|
4683 | if (typeof message !== "string") {
|
4684 | if (message instanceof Error) {
|
4685 | err = message;
|
4686 | } else {
|
4687 | err = new TimeoutError("operation timed out");
|
4688 | }
|
4689 | } else {
|
4690 | err = new TimeoutError(message);
|
4691 | }
|
4692 | util.markAsOriginatingFromRejection(err);
|
4693 | promise._attachExtraTrace(err);
|
4694 | promise._reject(err);
|
4695 | parent.cancel();
|
4696 | };
|
4697 |
|
4698 | var afterValue = function(value) { return delay(+this).thenReturn(value); };
|
4699 | var delay = Promise.delay = function (ms, value) {
|
4700 | var ret;
|
4701 | if (value !== undefined) {
|
4702 | ret = Promise.resolve(value)
|
4703 | ._then(afterValue, null, null, ms, undefined);
|
4704 | } else {
|
4705 | ret = new Promise(INTERNAL);
|
4706 | setTimeout(function() { ret._fulfill(); }, +ms);
|
4707 | }
|
4708 | ret._setAsyncGuaranteed();
|
4709 | return ret;
|
4710 | };
|
4711 |
|
4712 | Promise.prototype.delay = function (ms) {
|
4713 | return delay(ms, this);
|
4714 | };
|
4715 |
|
4716 | function successClear(value) {
|
4717 | var handle = this;
|
4718 | if (handle instanceof Number) handle = +handle;
|
4719 | clearTimeout(handle);
|
4720 | return value;
|
4721 | }
|
4722 |
|
4723 | function failureClear(reason) {
|
4724 | var handle = this;
|
4725 | if (handle instanceof Number) handle = +handle;
|
4726 | clearTimeout(handle);
|
4727 | throw reason;
|
4728 | }
|
4729 |
|
4730 | Promise.prototype.timeout = function (ms, message) {
|
4731 | ms = +ms;
|
4732 | var parent = this.then();
|
4733 | var ret = parent.then();
|
4734 | var handle = setTimeout(function timeoutTimeout() {
|
4735 | afterTimeout(ret, message, parent);
|
4736 | }, ms);
|
4737 | return ret._then(successClear, failureClear, undefined, handle, undefined);
|
4738 | };
|
4739 |
|
4740 | };
|
4741 |
|
4742 | },{"./util":36}],35:[function(_dereq_,module,exports){
|
4743 | "use strict";
|
4744 | module.exports = function (Promise, apiRejection, tryConvertToPromise,
|
4745 | createContext, INTERNAL, debug) {
|
4746 | var util = _dereq_("./util");
|
4747 | var TypeError = _dereq_("./errors").TypeError;
|
4748 | var inherits = _dereq_("./util").inherits;
|
4749 | var errorObj = util.errorObj;
|
4750 | var tryCatch = util.tryCatch;
|
4751 |
|
4752 | function thrower(e) {
|
4753 | setTimeout(function(){throw e;}, 0);
|
4754 | }
|
4755 |
|
4756 | function castPreservingDisposable(thenable) {
|
4757 | var maybePromise = tryConvertToPromise(thenable);
|
4758 | if (maybePromise !== thenable &&
|
4759 | typeof thenable._isDisposable === "function" &&
|
4760 | typeof thenable._getDisposer === "function" &&
|
4761 | thenable._isDisposable()) {
|
4762 | maybePromise._setDisposable(thenable._getDisposer());
|
4763 | }
|
4764 | return maybePromise;
|
4765 | }
|
4766 | function dispose(resources, inspection) {
|
4767 | var i = 0;
|
4768 | var len = resources.length;
|
4769 | var ret = new Promise(INTERNAL);
|
4770 | function iterator() {
|
4771 | if (i >= len) return ret._fulfill();
|
4772 | var maybePromise = castPreservingDisposable(resources[i++]);
|
4773 | if (maybePromise instanceof Promise &&
|
4774 | maybePromise._isDisposable()) {
|
4775 | try {
|
4776 | maybePromise = tryConvertToPromise(
|
4777 | maybePromise._getDisposer().tryDispose(inspection),
|
4778 | resources.promise);
|
4779 | } catch (e) {
|
4780 | return thrower(e);
|
4781 | }
|
4782 | if (maybePromise instanceof Promise) {
|
4783 | return maybePromise._then(iterator, thrower,
|
4784 | null, null, null);
|
4785 | }
|
4786 | }
|
4787 | iterator();
|
4788 | }
|
4789 | iterator();
|
4790 | return ret;
|
4791 | }
|
4792 |
|
4793 | function Disposer(data, promise, context) {
|
4794 | this._data = data;
|
4795 | this._promise = promise;
|
4796 | this._context = context;
|
4797 | }
|
4798 |
|
4799 | Disposer.prototype.data = function () {
|
4800 | return this._data;
|
4801 | };
|
4802 |
|
4803 | Disposer.prototype.promise = function () {
|
4804 | return this._promise;
|
4805 | };
|
4806 |
|
4807 | Disposer.prototype.resource = function () {
|
4808 | if (this.promise().isFulfilled()) {
|
4809 | return this.promise().value();
|
4810 | }
|
4811 | return null;
|
4812 | };
|
4813 |
|
4814 | Disposer.prototype.tryDispose = function(inspection) {
|
4815 | var resource = this.resource();
|
4816 | var context = this._context;
|
4817 | if (context !== undefined) context._pushContext();
|
4818 | var ret = resource !== null
|
4819 | ? this.doDispose(resource, inspection) : null;
|
4820 | if (context !== undefined) context._popContext();
|
4821 | this._promise._unsetDisposable();
|
4822 | this._data = null;
|
4823 | return ret;
|
4824 | };
|
4825 |
|
4826 | Disposer.isDisposer = function (d) {
|
4827 | return (d != null &&
|
4828 | typeof d.resource === "function" &&
|
4829 | typeof d.tryDispose === "function");
|
4830 | };
|
4831 |
|
4832 | function FunctionDisposer(fn, promise, context) {
|
4833 | this.constructor$(fn, promise, context);
|
4834 | }
|
4835 | inherits(FunctionDisposer, Disposer);
|
4836 |
|
4837 | FunctionDisposer.prototype.doDispose = function (resource, inspection) {
|
4838 | var fn = this.data();
|
4839 | return fn.call(resource, resource, inspection);
|
4840 | };
|
4841 |
|
4842 | function maybeUnwrapDisposer(value) {
|
4843 | if (Disposer.isDisposer(value)) {
|
4844 | this.resources[this.index]._setDisposable(value);
|
4845 | return value.promise();
|
4846 | }
|
4847 | return value;
|
4848 | }
|
4849 |
|
4850 | function ResourceList(length) {
|
4851 | this.length = length;
|
4852 | this.promise = null;
|
4853 | this[length-1] = null;
|
4854 | }
|
4855 |
|
4856 | ResourceList.prototype._resultCancelled = function() {
|
4857 | var len = this.length;
|
4858 | for (var i = 0; i < len; ++i) {
|
4859 | var item = this[i];
|
4860 | if (item instanceof Promise) {
|
4861 | item.cancel();
|
4862 | }
|
4863 | }
|
4864 | };
|
4865 |
|
4866 | Promise.using = function () {
|
4867 | var len = arguments.length;
|
4868 | if (len < 2) return apiRejection(
|
4869 | "you must pass at least 2 arguments to Promise.using");
|
4870 | var fn = arguments[len - 1];
|
4871 | if (typeof fn !== "function") {
|
4872 | return apiRejection("expecting a function but got " + util.classString(fn));
|
4873 | }
|
4874 | var input;
|
4875 | var spreadArgs = true;
|
4876 | if (len === 2 && Array.isArray(arguments[0])) {
|
4877 | input = arguments[0];
|
4878 | len = input.length;
|
4879 | spreadArgs = false;
|
4880 | } else {
|
4881 | input = arguments;
|
4882 | len--;
|
4883 | }
|
4884 | var resources = new ResourceList(len);
|
4885 | for (var i = 0; i < len; ++i) {
|
4886 | var resource = input[i];
|
4887 | if (Disposer.isDisposer(resource)) {
|
4888 | var disposer = resource;
|
4889 | resource = resource.promise();
|
4890 | resource._setDisposable(disposer);
|
4891 | } else {
|
4892 | var maybePromise = tryConvertToPromise(resource);
|
4893 | if (maybePromise instanceof Promise) {
|
4894 | resource =
|
4895 | maybePromise._then(maybeUnwrapDisposer, null, null, {
|
4896 | resources: resources,
|
4897 | index: i
|
4898 | }, undefined);
|
4899 | }
|
4900 | }
|
4901 | resources[i] = resource;
|
4902 | }
|
4903 |
|
4904 | var reflectedResources = new Array(resources.length);
|
4905 | for (var i = 0; i < reflectedResources.length; ++i) {
|
4906 | reflectedResources[i] = Promise.resolve(resources[i]).reflect();
|
4907 | }
|
4908 |
|
4909 | var resultPromise = Promise.all(reflectedResources)
|
4910 | .then(function(inspections) {
|
4911 | for (var i = 0; i < inspections.length; ++i) {
|
4912 | var inspection = inspections[i];
|
4913 | if (inspection.isRejected()) {
|
4914 | errorObj.e = inspection.error();
|
4915 | return errorObj;
|
4916 | } else if (!inspection.isFulfilled()) {
|
4917 | resultPromise.cancel();
|
4918 | return;
|
4919 | }
|
4920 | inspections[i] = inspection.value();
|
4921 | }
|
4922 | promise._pushContext();
|
4923 |
|
4924 | fn = tryCatch(fn);
|
4925 | var ret = spreadArgs
|
4926 | ? fn.apply(undefined, inspections) : fn(inspections);
|
4927 | var promiseCreated = promise._popContext();
|
4928 | debug.checkForgottenReturns(
|
4929 | ret, promiseCreated, "Promise.using", promise);
|
4930 | return ret;
|
4931 | });
|
4932 |
|
4933 | var promise = resultPromise.lastly(function() {
|
4934 | var inspection = new Promise.PromiseInspection(resultPromise);
|
4935 | return dispose(resources, inspection);
|
4936 | });
|
4937 | resources.promise = promise;
|
4938 | promise._setOnCancel(resources);
|
4939 | return promise;
|
4940 | };
|
4941 |
|
4942 | Promise.prototype._setDisposable = function (disposer) {
|
4943 | this._bitField = this._bitField | 131072;
|
4944 | this._disposer = disposer;
|
4945 | };
|
4946 |
|
4947 | Promise.prototype._isDisposable = function () {
|
4948 | return (this._bitField & 131072) > 0;
|
4949 | };
|
4950 |
|
4951 | Promise.prototype._getDisposer = function () {
|
4952 | return this._disposer;
|
4953 | };
|
4954 |
|
4955 | Promise.prototype._unsetDisposable = function () {
|
4956 | this._bitField = this._bitField & (~131072);
|
4957 | this._disposer = undefined;
|
4958 | };
|
4959 |
|
4960 | Promise.prototype.disposer = function (fn) {
|
4961 | if (typeof fn === "function") {
|
4962 | return new FunctionDisposer(fn, this, createContext());
|
4963 | }
|
4964 | throw new TypeError();
|
4965 | };
|
4966 |
|
4967 | };
|
4968 |
|
4969 | },{"./errors":12,"./util":36}],36:[function(_dereq_,module,exports){
|
4970 | "use strict";
|
4971 | var es5 = _dereq_("./es5");
|
4972 | var canEvaluate = typeof navigator == "undefined";
|
4973 |
|
4974 | var errorObj = {e: {}};
|
4975 | var tryCatchTarget;
|
4976 | function tryCatcher() {
|
4977 | try {
|
4978 | var target = tryCatchTarget;
|
4979 | tryCatchTarget = null;
|
4980 | return target.apply(this, arguments);
|
4981 | } catch (e) {
|
4982 | errorObj.e = e;
|
4983 | return errorObj;
|
4984 | }
|
4985 | }
|
4986 | function tryCatch(fn) {
|
4987 | tryCatchTarget = fn;
|
4988 | return tryCatcher;
|
4989 | }
|
4990 |
|
4991 | var inherits = function(Child, Parent) {
|
4992 | var hasProp = {}.hasOwnProperty;
|
4993 |
|
4994 | function T() {
|
4995 | this.constructor = Child;
|
4996 | this.constructor$ = Parent;
|
4997 | for (var propertyName in Parent.prototype) {
|
4998 | if (hasProp.call(Parent.prototype, propertyName) &&
|
4999 | propertyName.charAt(propertyName.length-1) !== "$"
|
5000 | ) {
|
5001 | this[propertyName + "$"] = Parent.prototype[propertyName];
|
5002 | }
|
5003 | }
|
5004 | }
|
5005 | T.prototype = Parent.prototype;
|
5006 | Child.prototype = new T();
|
5007 | return Child.prototype;
|
5008 | };
|
5009 |
|
5010 |
|
5011 | function isPrimitive(val) {
|
5012 | return val == null || val === true || val === false ||
|
5013 | typeof val === "string" || typeof val === "number";
|
5014 |
|
5015 | }
|
5016 |
|
5017 | function isObject(value) {
|
5018 | return typeof value === "function" ||
|
5019 | typeof value === "object" && value !== null;
|
5020 | }
|
5021 |
|
5022 | function maybeWrapAsError(maybeError) {
|
5023 | if (!isPrimitive(maybeError)) return maybeError;
|
5024 |
|
5025 | return new Error(safeToString(maybeError));
|
5026 | }
|
5027 |
|
5028 | function withAppended(target, appendee) {
|
5029 | var len = target.length;
|
5030 | var ret = new Array(len + 1);
|
5031 | var i;
|
5032 | for (i = 0; i < len; ++i) {
|
5033 | ret[i] = target[i];
|
5034 | }
|
5035 | ret[i] = appendee;
|
5036 | return ret;
|
5037 | }
|
5038 |
|
5039 | function getDataPropertyOrDefault(obj, key, defaultValue) {
|
5040 | if (es5.isES5) {
|
5041 | var desc = Object.getOwnPropertyDescriptor(obj, key);
|
5042 |
|
5043 | if (desc != null) {
|
5044 | return desc.get == null && desc.set == null
|
5045 | ? desc.value
|
5046 | : defaultValue;
|
5047 | }
|
5048 | } else {
|
5049 | return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
5050 | }
|
5051 | }
|
5052 |
|
5053 | function notEnumerableProp(obj, name, value) {
|
5054 | if (isPrimitive(obj)) return obj;
|
5055 | var descriptor = {
|
5056 | value: value,
|
5057 | configurable: true,
|
5058 | enumerable: false,
|
5059 | writable: true
|
5060 | };
|
5061 | es5.defineProperty(obj, name, descriptor);
|
5062 | return obj;
|
5063 | }
|
5064 |
|
5065 | function thrower(r) {
|
5066 | throw r;
|
5067 | }
|
5068 |
|
5069 | var inheritedDataKeys = (function() {
|
5070 | var excludedPrototypes = [
|
5071 | Array.prototype,
|
5072 | Object.prototype,
|
5073 | Function.prototype
|
5074 | ];
|
5075 |
|
5076 | var isExcludedProto = function(val) {
|
5077 | for (var i = 0; i < excludedPrototypes.length; ++i) {
|
5078 | if (excludedPrototypes[i] === val) {
|
5079 | return true;
|
5080 | }
|
5081 | }
|
5082 | return false;
|
5083 | };
|
5084 |
|
5085 | if (es5.isES5) {
|
5086 | var getKeys = Object.getOwnPropertyNames;
|
5087 | return function(obj) {
|
5088 | var ret = [];
|
5089 | var visitedKeys = Object.create(null);
|
5090 | while (obj != null && !isExcludedProto(obj)) {
|
5091 | var keys;
|
5092 | try {
|
5093 | keys = getKeys(obj);
|
5094 | } catch (e) {
|
5095 | return ret;
|
5096 | }
|
5097 | for (var i = 0; i < keys.length; ++i) {
|
5098 | var key = keys[i];
|
5099 | if (visitedKeys[key]) continue;
|
5100 | visitedKeys[key] = true;
|
5101 | var desc = Object.getOwnPropertyDescriptor(obj, key);
|
5102 | if (desc != null && desc.get == null && desc.set == null) {
|
5103 | ret.push(key);
|
5104 | }
|
5105 | }
|
5106 | obj = es5.getPrototypeOf(obj);
|
5107 | }
|
5108 | return ret;
|
5109 | };
|
5110 | } else {
|
5111 | var hasProp = {}.hasOwnProperty;
|
5112 | return function(obj) {
|
5113 | if (isExcludedProto(obj)) return [];
|
5114 | var ret = [];
|
5115 |
|
5116 |
|
5117 | enumeration: for (var key in obj) {
|
5118 | if (hasProp.call(obj, key)) {
|
5119 | ret.push(key);
|
5120 | } else {
|
5121 | for (var i = 0; i < excludedPrototypes.length; ++i) {
|
5122 | if (hasProp.call(excludedPrototypes[i], key)) {
|
5123 | continue enumeration;
|
5124 | }
|
5125 | }
|
5126 | ret.push(key);
|
5127 | }
|
5128 | }
|
5129 | return ret;
|
5130 | };
|
5131 | }
|
5132 |
|
5133 | })();
|
5134 |
|
5135 | var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
|
5136 | function isClass(fn) {
|
5137 | try {
|
5138 | if (typeof fn === "function") {
|
5139 | var keys = es5.names(fn.prototype);
|
5140 |
|
5141 | var hasMethods = es5.isES5 && keys.length > 1;
|
5142 | var hasMethodsOtherThanConstructor = keys.length > 0 &&
|
5143 | !(keys.length === 1 && keys[0] === "constructor");
|
5144 | var hasThisAssignmentAndStaticMethods =
|
5145 | thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
|
5146 |
|
5147 | if (hasMethods || hasMethodsOtherThanConstructor ||
|
5148 | hasThisAssignmentAndStaticMethods) {
|
5149 | return true;
|
5150 | }
|
5151 | }
|
5152 | return false;
|
5153 | } catch (e) {
|
5154 | return false;
|
5155 | }
|
5156 | }
|
5157 |
|
5158 | function toFastProperties(obj) {
|
5159 |
|
5160 | function FakeConstructor() {}
|
5161 | FakeConstructor.prototype = obj;
|
5162 | var l = 8;
|
5163 | while (l--) new FakeConstructor();
|
5164 | return obj;
|
5165 | eval(obj);
|
5166 | }
|
5167 |
|
5168 | var rident = /^[a-z$_][a-z$_0-9]*$/i;
|
5169 | function isIdentifier(str) {
|
5170 | return rident.test(str);
|
5171 | }
|
5172 |
|
5173 | function filledRange(count, prefix, suffix) {
|
5174 | var ret = new Array(count);
|
5175 | for(var i = 0; i < count; ++i) {
|
5176 | ret[i] = prefix + i + suffix;
|
5177 | }
|
5178 | return ret;
|
5179 | }
|
5180 |
|
5181 | function safeToString(obj) {
|
5182 | try {
|
5183 | return obj + "";
|
5184 | } catch (e) {
|
5185 | return "[no string representation]";
|
5186 | }
|
5187 | }
|
5188 |
|
5189 | function markAsOriginatingFromRejection(e) {
|
5190 | try {
|
5191 | notEnumerableProp(e, "isOperational", true);
|
5192 | }
|
5193 | catch(ignore) {}
|
5194 | }
|
5195 |
|
5196 | function originatesFromRejection(e) {
|
5197 | if (e == null) return false;
|
5198 | return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
|
5199 | e["isOperational"] === true);
|
5200 | }
|
5201 |
|
5202 | function canAttachTrace(obj) {
|
5203 | return obj instanceof Error && es5.propertyIsWritable(obj, "stack");
|
5204 | }
|
5205 |
|
5206 | var ensureErrorObject = (function() {
|
5207 | if (!("stack" in new Error())) {
|
5208 | return function(value) {
|
5209 | if (canAttachTrace(value)) return value;
|
5210 | try {throw new Error(safeToString(value));}
|
5211 | catch(err) {return err;}
|
5212 | };
|
5213 | } else {
|
5214 | return function(value) {
|
5215 | if (canAttachTrace(value)) return value;
|
5216 | return new Error(safeToString(value));
|
5217 | };
|
5218 | }
|
5219 | })();
|
5220 |
|
5221 | function classString(obj) {
|
5222 | return {}.toString.call(obj);
|
5223 | }
|
5224 |
|
5225 | function copyDescriptors(from, to, filter) {
|
5226 | var keys = es5.names(from);
|
5227 | for (var i = 0; i < keys.length; ++i) {
|
5228 | var key = keys[i];
|
5229 | if (filter(key)) {
|
5230 | try {
|
5231 | es5.defineProperty(to, key, es5.getDescriptor(from, key));
|
5232 | } catch (ignore) {}
|
5233 | }
|
5234 | }
|
5235 | }
|
5236 |
|
5237 | var asArray = function(v) {
|
5238 | if (es5.isArray(v)) {
|
5239 | return v;
|
5240 | }
|
5241 | return null;
|
5242 | };
|
5243 |
|
5244 | if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
5245 | var ArrayFrom = typeof Array.from === "function" ? function(v) {
|
5246 | return Array.from(v);
|
5247 | } : function(v) {
|
5248 | var ret = [];
|
5249 | var it = v[Symbol.iterator]();
|
5250 | var itResult;
|
5251 | while (!((itResult = it.next()).done)) {
|
5252 | ret.push(itResult.value);
|
5253 | }
|
5254 | return ret;
|
5255 | };
|
5256 |
|
5257 | asArray = function(v) {
|
5258 | if (es5.isArray(v)) {
|
5259 | return v;
|
5260 | } else if (v != null && typeof v[Symbol.iterator] === "function") {
|
5261 | return ArrayFrom(v);
|
5262 | }
|
5263 | return null;
|
5264 | };
|
5265 | }
|
5266 |
|
5267 | var isNode = typeof process !== "undefined" &&
|
5268 | classString(process).toLowerCase() === "[object process]";
|
5269 |
|
5270 | function env(key, def) {
|
5271 | return isNode ? process.env[key] : def;
|
5272 | }
|
5273 |
|
5274 | var ret = {
|
5275 | isClass: isClass,
|
5276 | isIdentifier: isIdentifier,
|
5277 | inheritedDataKeys: inheritedDataKeys,
|
5278 | getDataPropertyOrDefault: getDataPropertyOrDefault,
|
5279 | thrower: thrower,
|
5280 | isArray: es5.isArray,
|
5281 | asArray: asArray,
|
5282 | notEnumerableProp: notEnumerableProp,
|
5283 | isPrimitive: isPrimitive,
|
5284 | isObject: isObject,
|
5285 | canEvaluate: canEvaluate,
|
5286 | errorObj: errorObj,
|
5287 | tryCatch: tryCatch,
|
5288 | inherits: inherits,
|
5289 | withAppended: withAppended,
|
5290 | maybeWrapAsError: maybeWrapAsError,
|
5291 | toFastProperties: toFastProperties,
|
5292 | filledRange: filledRange,
|
5293 | toString: safeToString,
|
5294 | canAttachTrace: canAttachTrace,
|
5295 | ensureErrorObject: ensureErrorObject,
|
5296 | originatesFromRejection: originatesFromRejection,
|
5297 | markAsOriginatingFromRejection: markAsOriginatingFromRejection,
|
5298 | classString: classString,
|
5299 | copyDescriptors: copyDescriptors,
|
5300 | hasDevTools: typeof chrome !== "undefined" && chrome &&
|
5301 | typeof chrome.loadTimes === "function",
|
5302 | isNode: isNode,
|
5303 | env: env
|
5304 | };
|
5305 | ret.isRecentNode = ret.isNode && (function() {
|
5306 | var version = process.versions.node.split(".").map(Number);
|
5307 | return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
|
5308 | })();
|
5309 |
|
5310 | if (ret.isNode) ret.toFastProperties(process);
|
5311 |
|
5312 | try {throw new Error(); } catch (e) {ret.lastLineError = e;}
|
5313 | module.exports = ret;
|
5314 |
|
5315 | },{"./es5":13}]},{},[4])(4)
|
5316 | }); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; }
|
5317 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
5318 | },{"_process":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/process/browser.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browser-request/index.js":[function(require,module,exports){
|
5319 |
|
5320 |
|
5321 |
|
5322 |
|
5323 |
|
5324 |
|
5325 |
|
5326 |
|
5327 |
|
5328 |
|
5329 |
|
5330 |
|
5331 |
|
5332 |
|
5333 |
|
5334 | (function (root, factory) {
|
5335 | if (typeof define === 'function' && define.amd) {
|
5336 |
|
5337 | define([], factory);
|
5338 | } else if (typeof exports === 'object') {
|
5339 |
|
5340 |
|
5341 |
|
5342 | module.exports = factory();
|
5343 | } else {
|
5344 |
|
5345 | root.returnExports = factory();
|
5346 | }
|
5347 | }(this, function () {
|
5348 |
|
5349 |
|
5350 | var XHR = XMLHttpRequest
|
5351 | if (!XHR) throw new Error('missing XMLHttpRequest')
|
5352 | request.log = {
|
5353 | 'trace': noop, 'debug': noop, 'info': noop, 'warn': noop, 'error': noop
|
5354 | }
|
5355 |
|
5356 | var DEFAULT_TIMEOUT = 3 * 60 * 1000
|
5357 |
|
5358 |
|
5359 |
|
5360 |
|
5361 |
|
5362 | function request(options, callback) {
|
5363 |
|
5364 | if(typeof callback !== 'function')
|
5365 | throw new Error('Bad callback given: ' + callback)
|
5366 |
|
5367 | if(!options)
|
5368 | throw new Error('No options given')
|
5369 |
|
5370 | var options_onResponse = options.onResponse;
|
5371 |
|
5372 | if(typeof options === 'string')
|
5373 | options = {'uri':options};
|
5374 | else
|
5375 | options = JSON.parse(JSON.stringify(options));
|
5376 |
|
5377 | options.onResponse = options_onResponse
|
5378 |
|
5379 | if (options.verbose) request.log = getLogger();
|
5380 |
|
5381 | if(options.url) {
|
5382 | options.uri = options.url;
|
5383 | delete options.url;
|
5384 | }
|
5385 |
|
5386 | if(!options.uri && options.uri !== "")
|
5387 | throw new Error("options.uri is a required argument");
|
5388 |
|
5389 | if(typeof options.uri != "string")
|
5390 | throw new Error("options.uri must be a string");
|
5391 |
|
5392 | var unsupported_options = ['proxy', '_redirectsFollowed', 'maxRedirects', 'followRedirect']
|
5393 | for (var i = 0; i < unsupported_options.length; i++)
|
5394 | if(options[ unsupported_options[i] ])
|
5395 | throw new Error("options." + unsupported_options[i] + " is not supported")
|
5396 |
|
5397 | options.callback = callback
|
5398 | options.method = options.method || 'GET';
|
5399 | options.headers = options.headers || {};
|
5400 | options.body = options.body || null
|
5401 | options.timeout = options.timeout || request.DEFAULT_TIMEOUT
|
5402 |
|
5403 | if(options.headers.host)
|
5404 | throw new Error("Options.headers.host is not supported");
|
5405 |
|
5406 | if(options.json) {
|
5407 | options.headers.accept = options.headers.accept || 'application/json'
|
5408 | if(options.method !== 'GET')
|
5409 | options.headers['content-type'] = 'application/json'
|
5410 |
|
5411 | if(typeof options.json !== 'boolean')
|
5412 | options.body = JSON.stringify(options.json)
|
5413 | else if(typeof options.body !== 'string')
|
5414 | options.body = JSON.stringify(options.body)
|
5415 | }
|
5416 |
|
5417 |
|
5418 | var serialize = function(obj) {
|
5419 | var str = [];
|
5420 | for(var p in obj)
|
5421 | if (obj.hasOwnProperty(p)) {
|
5422 | str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
|
5423 | }
|
5424 | return str.join("&");
|
5425 | }
|
5426 |
|
5427 | if(options.qs){
|
5428 | var qs = (typeof options.qs == 'string')? options.qs : serialize(options.qs);
|
5429 | if(options.uri.indexOf('?') !== -1){
|
5430 | options.uri = options.uri+'&'+qs;
|
5431 | }else{
|
5432 | options.uri = options.uri+'?'+qs;
|
5433 | }
|
5434 | }
|
5435 |
|
5436 |
|
5437 |
|
5438 | var multipart = function(obj) {
|
5439 |
|
5440 | var result = {};
|
5441 | result.boundry = '-------------------------------'+Math.floor(Math.random()*1000000000);
|
5442 | var lines = [];
|
5443 | for(var p in obj){
|
5444 | if (obj.hasOwnProperty(p)) {
|
5445 | lines.push(
|
5446 | '--'+result.boundry+"\n"+
|
5447 | 'Content-Disposition: form-data; name="'+p+'"'+"\n"+
|
5448 | "\n"+
|
5449 | obj[p]+"\n"
|
5450 | );
|
5451 | }
|
5452 | }
|
5453 | lines.push( '--'+result.boundry+'--' );
|
5454 | result.body = lines.join('');
|
5455 | result.length = result.body.length;
|
5456 | result.type = 'multipart/form-data; boundary='+result.boundry;
|
5457 | return result;
|
5458 | }
|
5459 |
|
5460 | if(options.form){
|
5461 | if(typeof options.form == 'string') throw('form name unsupported');
|
5462 | if(options.method === 'POST'){
|
5463 | var encoding = (options.encoding || 'application/x-www-form-urlencoded').toLowerCase();
|
5464 | options.headers['content-type'] = encoding;
|
5465 | switch(encoding){
|
5466 | case 'application/x-www-form-urlencoded':
|
5467 | options.body = serialize(options.form).replace(/%20/g, "+");
|
5468 | break;
|
5469 | case 'multipart/form-data':
|
5470 | var multi = multipart(options.form);
|
5471 |
|
5472 | options.body = multi.body;
|
5473 | options.headers['content-type'] = multi.type;
|
5474 | break;
|
5475 | default : throw new Error('unsupported encoding:'+encoding);
|
5476 | }
|
5477 | }
|
5478 | }
|
5479 |
|
5480 |
|
5481 |
|
5482 |
|
5483 | options.onResponse = options.onResponse || noop
|
5484 | if(options.onResponse === true) {
|
5485 | options.onResponse = callback
|
5486 | options.callback = noop
|
5487 | }
|
5488 |
|
5489 |
|
5490 |
|
5491 |
|
5492 |
|
5493 |
|
5494 | if(!options.headers.authorization && options.auth)
|
5495 | options.headers.authorization = 'Basic ' + b64_enc(options.auth.username + ':' + options.auth.password);
|
5496 |
|
5497 | return run_xhr(options)
|
5498 | }
|
5499 |
|
5500 | var req_seq = 0
|
5501 | function run_xhr(options) {
|
5502 | var xhr = new XHR
|
5503 | , timed_out = false
|
5504 | , is_cors = is_crossDomain(options.uri)
|
5505 | , supports_cors = ('withCredentials' in xhr)
|
5506 |
|
5507 | req_seq += 1
|
5508 | xhr.seq_id = req_seq
|
5509 | xhr.id = req_seq + ': ' + options.method + ' ' + options.uri
|
5510 | xhr._id = xhr.id
|
5511 |
|
5512 | if(is_cors && !supports_cors) {
|
5513 | var cors_err = new Error('Browser does not support cross-origin request: ' + options.uri)
|
5514 | cors_err.cors = 'unsupported'
|
5515 | return options.callback(cors_err, xhr)
|
5516 | }
|
5517 |
|
5518 | xhr.timeoutTimer = setTimeout(too_late, options.timeout)
|
5519 | function too_late() {
|
5520 | timed_out = true
|
5521 | var er = new Error('ETIMEDOUT')
|
5522 | er.code = 'ETIMEDOUT'
|
5523 | er.duration = options.timeout
|
5524 |
|
5525 | request.log.error('Timeout', { 'id':xhr._id, 'milliseconds':options.timeout })
|
5526 | return options.callback(er, xhr)
|
5527 | }
|
5528 |
|
5529 |
|
5530 | var did = {'response':false, 'loading':false, 'end':false}
|
5531 |
|
5532 | xhr.onreadystatechange = on_state_change
|
5533 | xhr.open(options.method, options.uri, true)
|
5534 | if(is_cors)
|
5535 | xhr.withCredentials = !! options.withCredentials
|
5536 | xhr.send(options.body)
|
5537 | return xhr
|
5538 |
|
5539 | function on_state_change(event) {
|
5540 | if(timed_out)
|
5541 | return request.log.debug('Ignoring timed out state change', {'state':xhr.readyState, 'id':xhr.id})
|
5542 |
|
5543 | request.log.debug('State change', {'state':xhr.readyState, 'id':xhr.id, 'timed_out':timed_out})
|
5544 |
|
5545 | if(xhr.readyState === XHR.OPENED) {
|
5546 | request.log.debug('Request started', {'id':xhr.id})
|
5547 | for (var key in options.headers)
|
5548 | xhr.setRequestHeader(key, options.headers[key])
|
5549 | }
|
5550 |
|
5551 | else if(xhr.readyState === XHR.HEADERS_RECEIVED)
|
5552 | on_response()
|
5553 |
|
5554 | else if(xhr.readyState === XHR.LOADING) {
|
5555 | on_response()
|
5556 | on_loading()
|
5557 | }
|
5558 |
|
5559 | else if(xhr.readyState === XHR.DONE) {
|
5560 | on_response()
|
5561 | on_loading()
|
5562 | on_end()
|
5563 | }
|
5564 | }
|
5565 |
|
5566 | function on_response() {
|
5567 | if(did.response)
|
5568 | return
|
5569 |
|
5570 | did.response = true
|
5571 | request.log.debug('Got response', {'id':xhr.id, 'status':xhr.status})
|
5572 | clearTimeout(xhr.timeoutTimer)
|
5573 | xhr.statusCode = xhr.status
|
5574 |
|
5575 |
|
5576 | if(is_cors && xhr.statusCode == 0) {
|
5577 | var cors_err = new Error('CORS request rejected: ' + options.uri)
|
5578 | cors_err.cors = 'rejected'
|
5579 |
|
5580 |
|
5581 | did.loading = true
|
5582 | did.end = true
|
5583 |
|
5584 | return options.callback(cors_err, xhr)
|
5585 | }
|
5586 |
|
5587 | options.onResponse(null, xhr)
|
5588 | }
|
5589 |
|
5590 | function on_loading() {
|
5591 | if(did.loading)
|
5592 | return
|
5593 |
|
5594 | did.loading = true
|
5595 | request.log.debug('Response body loading', {'id':xhr.id})
|
5596 |
|
5597 | }
|
5598 |
|
5599 | function on_end() {
|
5600 | if(did.end)
|
5601 | return
|
5602 |
|
5603 | did.end = true
|
5604 | request.log.debug('Request done', {'id':xhr.id})
|
5605 |
|
5606 | xhr.body = xhr.responseText
|
5607 | if(options.json) {
|
5608 | try { xhr.body = JSON.parse(xhr.responseText) }
|
5609 | catch (er) { return options.callback(er, xhr) }
|
5610 | }
|
5611 |
|
5612 | options.callback(null, xhr, xhr.body)
|
5613 | }
|
5614 |
|
5615 | }
|
5616 |
|
5617 | request.withCredentials = false;
|
5618 | request.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
5619 |
|
5620 |
|
5621 |
|
5622 |
|
5623 |
|
5624 | request.defaults = function(options, requester) {
|
5625 | var def = function (method) {
|
5626 | var d = function (params, callback) {
|
5627 | if(typeof params === 'string')
|
5628 | params = {'uri': params};
|
5629 | else {
|
5630 | params = JSON.parse(JSON.stringify(params));
|
5631 | }
|
5632 | for (var i in options) {
|
5633 | if (params[i] === undefined) params[i] = options[i]
|
5634 | }
|
5635 | return method(params, callback)
|
5636 | }
|
5637 | return d
|
5638 | }
|
5639 | var de = def(request)
|
5640 | de.get = def(request.get)
|
5641 | de.post = def(request.post)
|
5642 | de.put = def(request.put)
|
5643 | de.head = def(request.head)
|
5644 | return de
|
5645 | }
|
5646 |
|
5647 |
|
5648 |
|
5649 |
|
5650 |
|
5651 | var shortcuts = [ 'get', 'put', 'post', 'head' ];
|
5652 | shortcuts.forEach(function(shortcut) {
|
5653 | var method = shortcut.toUpperCase();
|
5654 | var func = shortcut.toLowerCase();
|
5655 |
|
5656 | request[func] = function(opts) {
|
5657 | if(typeof opts === 'string')
|
5658 | opts = {'method':method, 'uri':opts};
|
5659 | else {
|
5660 | opts = JSON.parse(JSON.stringify(opts));
|
5661 | opts.method = method;
|
5662 | }
|
5663 |
|
5664 | var args = [opts].concat(Array.prototype.slice.apply(arguments, [1]));
|
5665 | return request.apply(this, args);
|
5666 | }
|
5667 | })
|
5668 |
|
5669 |
|
5670 |
|
5671 |
|
5672 |
|
5673 | request.couch = function(options, callback) {
|
5674 | if(typeof options === 'string')
|
5675 | options = {'uri':options}
|
5676 |
|
5677 |
|
5678 | options.json = true
|
5679 | if(options.body)
|
5680 | options.json = options.body
|
5681 | delete options.body
|
5682 |
|
5683 | callback = callback || noop
|
5684 |
|
5685 | var xhr = request(options, couch_handler)
|
5686 | return xhr
|
5687 |
|
5688 | function couch_handler(er, resp, body) {
|
5689 | if(er)
|
5690 | return callback(er, resp, body)
|
5691 |
|
5692 | if((resp.statusCode < 200 || resp.statusCode > 299) && body.error) {
|
5693 |
|
5694 | er = new Error('CouchDB error: ' + (body.error.reason || body.error.error))
|
5695 | for (var key in body)
|
5696 | er[key] = body[key]
|
5697 | return callback(er, resp, body);
|
5698 | }
|
5699 |
|
5700 | return callback(er, resp, body);
|
5701 | }
|
5702 | }
|
5703 |
|
5704 |
|
5705 |
|
5706 |
|
5707 |
|
5708 | function noop() {}
|
5709 |
|
5710 | function getLogger() {
|
5711 | var logger = {}
|
5712 | , levels = ['trace', 'debug', 'info', 'warn', 'error']
|
5713 | , level, i
|
5714 |
|
5715 | for(i = 0; i < levels.length; i++) {
|
5716 | level = levels[i]
|
5717 |
|
5718 | logger[level] = noop
|
5719 | if(typeof console !== 'undefined' && console && console[level])
|
5720 | logger[level] = formatted(console, level)
|
5721 | }
|
5722 |
|
5723 | return logger
|
5724 | }
|
5725 |
|
5726 | function formatted(obj, method) {
|
5727 | return formatted_logger
|
5728 |
|
5729 | function formatted_logger(str, context) {
|
5730 | if(typeof context === 'object')
|
5731 | str += ' ' + JSON.stringify(context)
|
5732 |
|
5733 | return obj[method].call(obj, str)
|
5734 | }
|
5735 | }
|
5736 |
|
5737 |
|
5738 | function is_crossDomain(url) {
|
5739 | var rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/
|
5740 |
|
5741 |
|
5742 |
|
5743 | var ajaxLocation
|
5744 | try { ajaxLocation = location.href }
|
5745 | catch (e) {
|
5746 |
|
5747 | ajaxLocation = document.createElement( "a" );
|
5748 | ajaxLocation.href = "";
|
5749 | ajaxLocation = ajaxLocation.href;
|
5750 | }
|
5751 |
|
5752 | var ajaxLocParts = rurl.exec(ajaxLocation.toLowerCase()) || []
|
5753 | , parts = rurl.exec(url.toLowerCase() )
|
5754 |
|
5755 | var result = !!(
|
5756 | parts &&
|
5757 | ( parts[1] != ajaxLocParts[1]
|
5758 | || parts[2] != ajaxLocParts[2]
|
5759 | || (parts[3] || (parts[1] === "http:" ? 80 : 443)) != (ajaxLocParts[3] || (ajaxLocParts[1] === "http:" ? 80 : 443))
|
5760 | )
|
5761 | )
|
5762 |
|
5763 |
|
5764 | return result
|
5765 | }
|
5766 |
|
5767 |
|
5768 | function b64_enc (data) {
|
5769 |
|
5770 | var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
5771 | var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, enc="", tmp_arr = [];
|
5772 |
|
5773 | if (!data) {
|
5774 | return data;
|
5775 | }
|
5776 |
|
5777 |
|
5778 |
|
5779 |
|
5780 | do {
|
5781 | o1 = data.charCodeAt(i++);
|
5782 | o2 = data.charCodeAt(i++);
|
5783 | o3 = data.charCodeAt(i++);
|
5784 |
|
5785 | bits = o1<<16 | o2<<8 | o3;
|
5786 |
|
5787 | h1 = bits>>18 & 0x3f;
|
5788 | h2 = bits>>12 & 0x3f;
|
5789 | h3 = bits>>6 & 0x3f;
|
5790 | h4 = bits & 0x3f;
|
5791 |
|
5792 |
|
5793 | tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
|
5794 | } while (i < data.length);
|
5795 |
|
5796 | enc = tmp_arr.join('');
|
5797 |
|
5798 | switch (data.length % 3) {
|
5799 | case 1:
|
5800 | enc = enc.slice(0, -2) + '==';
|
5801 | break;
|
5802 | case 2:
|
5803 | enc = enc.slice(0, -1) + '=';
|
5804 | break;
|
5805 | }
|
5806 |
|
5807 | return enc;
|
5808 | }
|
5809 | return request;
|
5810 |
|
5811 | }));
|
5812 |
|
5813 |
|
5814 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/index.js":[function(require,module,exports){
|
5815 | (function (global){
|
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 |
|
5821 |
|
5822 |
|
5823 |
|
5824 | 'use strict'
|
5825 |
|
5826 | var base64 = require('base64-js')
|
5827 | var ieee754 = require('ieee754')
|
5828 | var isArray = require('isarray')
|
5829 |
|
5830 | exports.Buffer = Buffer
|
5831 | exports.SlowBuffer = SlowBuffer
|
5832 | exports.INSPECT_MAX_BYTES = 50
|
5833 | Buffer.poolSize = 8192
|
5834 |
|
5835 | var rootParent = {}
|
5836 |
|
5837 |
|
5838 |
|
5839 |
|
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 |
|
5849 |
|
5850 |
|
5851 |
|
5852 |
|
5853 |
|
5854 |
|
5855 |
|
5856 |
|
5857 |
|
5858 |
|
5859 |
|
5860 |
|
5861 |
|
5862 |
|
5863 |
|
5864 | Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
5865 | ? global.TYPED_ARRAY_SUPPORT
|
5866 | : typedArraySupport()
|
5867 |
|
5868 | function typedArraySupport () {
|
5869 | function Bar () {}
|
5870 | try {
|
5871 | var arr = new Uint8Array(1)
|
5872 | arr.foo = function () { return 42 }
|
5873 | arr.constructor = Bar
|
5874 | return arr.foo() === 42 &&
|
5875 | arr.constructor === Bar &&
|
5876 | typeof arr.subarray === 'function' &&
|
5877 | arr.subarray(1, 1).byteLength === 0
|
5878 | } catch (e) {
|
5879 | return false
|
5880 | }
|
5881 | }
|
5882 |
|
5883 | function kMaxLength () {
|
5884 | return Buffer.TYPED_ARRAY_SUPPORT
|
5885 | ? 0x7fffffff
|
5886 | : 0x3fffffff
|
5887 | }
|
5888 |
|
5889 |
|
5890 |
|
5891 |
|
5892 |
|
5893 |
|
5894 |
|
5895 |
|
5896 |
|
5897 |
|
5898 |
|
5899 |
|
5900 |
|
5901 | function Buffer (arg) {
|
5902 | if (!(this instanceof Buffer)) {
|
5903 |
|
5904 | if (arguments.length > 1) return new Buffer(arg, arguments[1])
|
5905 | return new Buffer(arg)
|
5906 | }
|
5907 |
|
5908 | if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
5909 | this.length = 0
|
5910 | this.parent = undefined
|
5911 | }
|
5912 |
|
5913 |
|
5914 | if (typeof arg === 'number') {
|
5915 | return fromNumber(this, arg)
|
5916 | }
|
5917 |
|
5918 |
|
5919 | if (typeof arg === 'string') {
|
5920 | return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
|
5921 | }
|
5922 |
|
5923 |
|
5924 | return fromObject(this, arg)
|
5925 | }
|
5926 |
|
5927 | function fromNumber (that, length) {
|
5928 | that = allocate(that, length < 0 ? 0 : checked(length) | 0)
|
5929 | if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
5930 | for (var i = 0; i < length; i++) {
|
5931 | that[i] = 0
|
5932 | }
|
5933 | }
|
5934 | return that
|
5935 | }
|
5936 |
|
5937 | function fromString (that, string, encoding) {
|
5938 | if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
|
5939 |
|
5940 |
|
5941 | var length = byteLength(string, encoding) | 0
|
5942 | that = allocate(that, length)
|
5943 |
|
5944 | that.write(string, encoding)
|
5945 | return that
|
5946 | }
|
5947 |
|
5948 | function fromObject (that, object) {
|
5949 | if (Buffer.isBuffer(object)) return fromBuffer(that, object)
|
5950 |
|
5951 | if (isArray(object)) return fromArray(that, object)
|
5952 |
|
5953 | if (object == null) {
|
5954 | throw new TypeError('must start with number, buffer, array or string')
|
5955 | }
|
5956 |
|
5957 | if (typeof ArrayBuffer !== 'undefined') {
|
5958 | if (object.buffer instanceof ArrayBuffer) {
|
5959 | return fromTypedArray(that, object)
|
5960 | }
|
5961 | if (object instanceof ArrayBuffer) {
|
5962 | return fromArrayBuffer(that, object)
|
5963 | }
|
5964 | }
|
5965 |
|
5966 | if (object.length) return fromArrayLike(that, object)
|
5967 |
|
5968 | return fromJsonObject(that, object)
|
5969 | }
|
5970 |
|
5971 | function fromBuffer (that, buffer) {
|
5972 | var length = checked(buffer.length) | 0
|
5973 | that = allocate(that, length)
|
5974 | buffer.copy(that, 0, 0, length)
|
5975 | return that
|
5976 | }
|
5977 |
|
5978 | function fromArray (that, array) {
|
5979 | var length = checked(array.length) | 0
|
5980 | that = allocate(that, length)
|
5981 | for (var i = 0; i < length; i += 1) {
|
5982 | that[i] = array[i] & 255
|
5983 | }
|
5984 | return that
|
5985 | }
|
5986 |
|
5987 |
|
5988 | function fromTypedArray (that, array) {
|
5989 | var length = checked(array.length) | 0
|
5990 | that = allocate(that, length)
|
5991 |
|
5992 |
|
5993 |
|
5994 | for (var i = 0; i < length; i += 1) {
|
5995 | that[i] = array[i] & 255
|
5996 | }
|
5997 | return that
|
5998 | }
|
5999 |
|
6000 | function fromArrayBuffer (that, array) {
|
6001 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6002 |
|
6003 | array.byteLength
|
6004 | that = Buffer._augment(new Uint8Array(array))
|
6005 | } else {
|
6006 |
|
6007 | that = fromTypedArray(that, new Uint8Array(array))
|
6008 | }
|
6009 | return that
|
6010 | }
|
6011 |
|
6012 | function fromArrayLike (that, array) {
|
6013 | var length = checked(array.length) | 0
|
6014 | that = allocate(that, length)
|
6015 | for (var i = 0; i < length; i += 1) {
|
6016 | that[i] = array[i] & 255
|
6017 | }
|
6018 | return that
|
6019 | }
|
6020 |
|
6021 |
|
6022 |
|
6023 | function fromJsonObject (that, object) {
|
6024 | var array
|
6025 | var length = 0
|
6026 |
|
6027 | if (object.type === 'Buffer' && isArray(object.data)) {
|
6028 | array = object.data
|
6029 | length = checked(array.length) | 0
|
6030 | }
|
6031 | that = allocate(that, length)
|
6032 |
|
6033 | for (var i = 0; i < length; i += 1) {
|
6034 | that[i] = array[i] & 255
|
6035 | }
|
6036 | return that
|
6037 | }
|
6038 |
|
6039 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6040 | Buffer.prototype.__proto__ = Uint8Array.prototype
|
6041 | Buffer.__proto__ = Uint8Array
|
6042 | } else {
|
6043 |
|
6044 | Buffer.prototype.length = undefined
|
6045 | Buffer.prototype.parent = undefined
|
6046 | }
|
6047 |
|
6048 | function allocate (that, length) {
|
6049 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6050 |
|
6051 | that = Buffer._augment(new Uint8Array(length))
|
6052 | that.__proto__ = Buffer.prototype
|
6053 | } else {
|
6054 |
|
6055 | that.length = length
|
6056 | that._isBuffer = true
|
6057 | }
|
6058 |
|
6059 | var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
|
6060 | if (fromPool) that.parent = rootParent
|
6061 |
|
6062 | return that
|
6063 | }
|
6064 |
|
6065 | function checked (length) {
|
6066 |
|
6067 |
|
6068 | if (length >= kMaxLength()) {
|
6069 | throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
6070 | 'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
6071 | }
|
6072 | return length | 0
|
6073 | }
|
6074 |
|
6075 | function SlowBuffer (subject, encoding) {
|
6076 | if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
|
6077 |
|
6078 | var buf = new Buffer(subject, encoding)
|
6079 | delete buf.parent
|
6080 | return buf
|
6081 | }
|
6082 |
|
6083 | Buffer.isBuffer = function isBuffer (b) {
|
6084 | return !!(b != null && b._isBuffer)
|
6085 | }
|
6086 |
|
6087 | Buffer.compare = function compare (a, b) {
|
6088 | if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
6089 | throw new TypeError('Arguments must be Buffers')
|
6090 | }
|
6091 |
|
6092 | if (a === b) return 0
|
6093 |
|
6094 | var x = a.length
|
6095 | var y = b.length
|
6096 |
|
6097 | var i = 0
|
6098 | var len = Math.min(x, y)
|
6099 | while (i < len) {
|
6100 | if (a[i] !== b[i]) break
|
6101 |
|
6102 | ++i
|
6103 | }
|
6104 |
|
6105 | if (i !== len) {
|
6106 | x = a[i]
|
6107 | y = b[i]
|
6108 | }
|
6109 |
|
6110 | if (x < y) return -1
|
6111 | if (y < x) return 1
|
6112 | return 0
|
6113 | }
|
6114 |
|
6115 | Buffer.isEncoding = function isEncoding (encoding) {
|
6116 | switch (String(encoding).toLowerCase()) {
|
6117 | case 'hex':
|
6118 | case 'utf8':
|
6119 | case 'utf-8':
|
6120 | case 'ascii':
|
6121 | case 'binary':
|
6122 | case 'base64':
|
6123 | case 'raw':
|
6124 | case 'ucs2':
|
6125 | case 'ucs-2':
|
6126 | case 'utf16le':
|
6127 | case 'utf-16le':
|
6128 | return true
|
6129 | default:
|
6130 | return false
|
6131 | }
|
6132 | }
|
6133 |
|
6134 | Buffer.concat = function concat (list, length) {
|
6135 | if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
|
6136 |
|
6137 | if (list.length === 0) {
|
6138 | return new Buffer(0)
|
6139 | }
|
6140 |
|
6141 | var i
|
6142 | if (length === undefined) {
|
6143 | length = 0
|
6144 | for (i = 0; i < list.length; i++) {
|
6145 | length += list[i].length
|
6146 | }
|
6147 | }
|
6148 |
|
6149 | var buf = new Buffer(length)
|
6150 | var pos = 0
|
6151 | for (i = 0; i < list.length; i++) {
|
6152 | var item = list[i]
|
6153 | item.copy(buf, pos)
|
6154 | pos += item.length
|
6155 | }
|
6156 | return buf
|
6157 | }
|
6158 |
|
6159 | function byteLength (string, encoding) {
|
6160 | if (typeof string !== 'string') string = '' + string
|
6161 |
|
6162 | var len = string.length
|
6163 | if (len === 0) return 0
|
6164 |
|
6165 |
|
6166 | var loweredCase = false
|
6167 | for (;;) {
|
6168 | switch (encoding) {
|
6169 | case 'ascii':
|
6170 | case 'binary':
|
6171 |
|
6172 | case 'raw':
|
6173 | case 'raws':
|
6174 | return len
|
6175 | case 'utf8':
|
6176 | case 'utf-8':
|
6177 | return utf8ToBytes(string).length
|
6178 | case 'ucs2':
|
6179 | case 'ucs-2':
|
6180 | case 'utf16le':
|
6181 | case 'utf-16le':
|
6182 | return len * 2
|
6183 | case 'hex':
|
6184 | return len >>> 1
|
6185 | case 'base64':
|
6186 | return base64ToBytes(string).length
|
6187 | default:
|
6188 | if (loweredCase) return utf8ToBytes(string).length
|
6189 | encoding = ('' + encoding).toLowerCase()
|
6190 | loweredCase = true
|
6191 | }
|
6192 | }
|
6193 | }
|
6194 | Buffer.byteLength = byteLength
|
6195 |
|
6196 | function slowToString (encoding, start, end) {
|
6197 | var loweredCase = false
|
6198 |
|
6199 | start = start | 0
|
6200 | end = end === undefined || end === Infinity ? this.length : end | 0
|
6201 |
|
6202 | if (!encoding) encoding = 'utf8'
|
6203 | if (start < 0) start = 0
|
6204 | if (end > this.length) end = this.length
|
6205 | if (end <= start) return ''
|
6206 |
|
6207 | while (true) {
|
6208 | switch (encoding) {
|
6209 | case 'hex':
|
6210 | return hexSlice(this, start, end)
|
6211 |
|
6212 | case 'utf8':
|
6213 | case 'utf-8':
|
6214 | return utf8Slice(this, start, end)
|
6215 |
|
6216 | case 'ascii':
|
6217 | return asciiSlice(this, start, end)
|
6218 |
|
6219 | case 'binary':
|
6220 | return binarySlice(this, start, end)
|
6221 |
|
6222 | case 'base64':
|
6223 | return base64Slice(this, start, end)
|
6224 |
|
6225 | case 'ucs2':
|
6226 | case 'ucs-2':
|
6227 | case 'utf16le':
|
6228 | case 'utf-16le':
|
6229 | return utf16leSlice(this, start, end)
|
6230 |
|
6231 | default:
|
6232 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
6233 | encoding = (encoding + '').toLowerCase()
|
6234 | loweredCase = true
|
6235 | }
|
6236 | }
|
6237 | }
|
6238 |
|
6239 | Buffer.prototype.toString = function toString () {
|
6240 | var length = this.length | 0
|
6241 | if (length === 0) return ''
|
6242 | if (arguments.length === 0) return utf8Slice(this, 0, length)
|
6243 | return slowToString.apply(this, arguments)
|
6244 | }
|
6245 |
|
6246 | Buffer.prototype.equals = function equals (b) {
|
6247 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
6248 | if (this === b) return true
|
6249 | return Buffer.compare(this, b) === 0
|
6250 | }
|
6251 |
|
6252 | Buffer.prototype.inspect = function inspect () {
|
6253 | var str = ''
|
6254 | var max = exports.INSPECT_MAX_BYTES
|
6255 | if (this.length > 0) {
|
6256 | str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
6257 | if (this.length > max) str += ' ... '
|
6258 | }
|
6259 | return '<Buffer ' + str + '>'
|
6260 | }
|
6261 |
|
6262 | Buffer.prototype.compare = function compare (b) {
|
6263 | if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
6264 | if (this === b) return 0
|
6265 | return Buffer.compare(this, b)
|
6266 | }
|
6267 |
|
6268 | Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
|
6269 | if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
|
6270 | else if (byteOffset < -0x80000000) byteOffset = -0x80000000
|
6271 | byteOffset >>= 0
|
6272 |
|
6273 | if (this.length === 0) return -1
|
6274 | if (byteOffset >= this.length) return -1
|
6275 |
|
6276 |
|
6277 | if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
|
6278 |
|
6279 | if (typeof val === 'string') {
|
6280 | if (val.length === 0) return -1
|
6281 | return String.prototype.indexOf.call(this, val, byteOffset)
|
6282 | }
|
6283 | if (Buffer.isBuffer(val)) {
|
6284 | return arrayIndexOf(this, val, byteOffset)
|
6285 | }
|
6286 | if (typeof val === 'number') {
|
6287 | if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
|
6288 | return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
|
6289 | }
|
6290 | return arrayIndexOf(this, [ val ], byteOffset)
|
6291 | }
|
6292 |
|
6293 | function arrayIndexOf (arr, val, byteOffset) {
|
6294 | var foundIndex = -1
|
6295 | for (var i = 0; byteOffset + i < arr.length; i++) {
|
6296 | if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
|
6297 | if (foundIndex === -1) foundIndex = i
|
6298 | if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
|
6299 | } else {
|
6300 | foundIndex = -1
|
6301 | }
|
6302 | }
|
6303 | return -1
|
6304 | }
|
6305 |
|
6306 | throw new TypeError('val must be string, number or Buffer')
|
6307 | }
|
6308 |
|
6309 |
|
6310 | Buffer.prototype.get = function get (offset) {
|
6311 | console.log('.get() is deprecated. Access using array indexes instead.')
|
6312 | return this.readUInt8(offset)
|
6313 | }
|
6314 |
|
6315 |
|
6316 | Buffer.prototype.set = function set (v, offset) {
|
6317 | console.log('.set() is deprecated. Access using array indexes instead.')
|
6318 | return this.writeUInt8(v, offset)
|
6319 | }
|
6320 |
|
6321 | function hexWrite (buf, string, offset, length) {
|
6322 | offset = Number(offset) || 0
|
6323 | var remaining = buf.length - offset
|
6324 | if (!length) {
|
6325 | length = remaining
|
6326 | } else {
|
6327 | length = Number(length)
|
6328 | if (length > remaining) {
|
6329 | length = remaining
|
6330 | }
|
6331 | }
|
6332 |
|
6333 |
|
6334 | var strLen = string.length
|
6335 | if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
6336 |
|
6337 | if (length > strLen / 2) {
|
6338 | length = strLen / 2
|
6339 | }
|
6340 | for (var i = 0; i < length; i++) {
|
6341 | var parsed = parseInt(string.substr(i * 2, 2), 16)
|
6342 | if (isNaN(parsed)) throw new Error('Invalid hex string')
|
6343 | buf[offset + i] = parsed
|
6344 | }
|
6345 | return i
|
6346 | }
|
6347 |
|
6348 | function utf8Write (buf, string, offset, length) {
|
6349 | return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
6350 | }
|
6351 |
|
6352 | function asciiWrite (buf, string, offset, length) {
|
6353 | return blitBuffer(asciiToBytes(string), buf, offset, length)
|
6354 | }
|
6355 |
|
6356 | function binaryWrite (buf, string, offset, length) {
|
6357 | return asciiWrite(buf, string, offset, length)
|
6358 | }
|
6359 |
|
6360 | function base64Write (buf, string, offset, length) {
|
6361 | return blitBuffer(base64ToBytes(string), buf, offset, length)
|
6362 | }
|
6363 |
|
6364 | function ucs2Write (buf, string, offset, length) {
|
6365 | return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
6366 | }
|
6367 |
|
6368 | Buffer.prototype.write = function write (string, offset, length, encoding) {
|
6369 |
|
6370 | if (offset === undefined) {
|
6371 | encoding = 'utf8'
|
6372 | length = this.length
|
6373 | offset = 0
|
6374 |
|
6375 | } else if (length === undefined && typeof offset === 'string') {
|
6376 | encoding = offset
|
6377 | length = this.length
|
6378 | offset = 0
|
6379 |
|
6380 | } else if (isFinite(offset)) {
|
6381 | offset = offset | 0
|
6382 | if (isFinite(length)) {
|
6383 | length = length | 0
|
6384 | if (encoding === undefined) encoding = 'utf8'
|
6385 | } else {
|
6386 | encoding = length
|
6387 | length = undefined
|
6388 | }
|
6389 |
|
6390 | } else {
|
6391 | var swap = encoding
|
6392 | encoding = offset
|
6393 | offset = length | 0
|
6394 | length = swap
|
6395 | }
|
6396 |
|
6397 | var remaining = this.length - offset
|
6398 | if (length === undefined || length > remaining) length = remaining
|
6399 |
|
6400 | if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
6401 | throw new RangeError('attempt to write outside buffer bounds')
|
6402 | }
|
6403 |
|
6404 | if (!encoding) encoding = 'utf8'
|
6405 |
|
6406 | var loweredCase = false
|
6407 | for (;;) {
|
6408 | switch (encoding) {
|
6409 | case 'hex':
|
6410 | return hexWrite(this, string, offset, length)
|
6411 |
|
6412 | case 'utf8':
|
6413 | case 'utf-8':
|
6414 | return utf8Write(this, string, offset, length)
|
6415 |
|
6416 | case 'ascii':
|
6417 | return asciiWrite(this, string, offset, length)
|
6418 |
|
6419 | case 'binary':
|
6420 | return binaryWrite(this, string, offset, length)
|
6421 |
|
6422 | case 'base64':
|
6423 |
|
6424 | return base64Write(this, string, offset, length)
|
6425 |
|
6426 | case 'ucs2':
|
6427 | case 'ucs-2':
|
6428 | case 'utf16le':
|
6429 | case 'utf-16le':
|
6430 | return ucs2Write(this, string, offset, length)
|
6431 |
|
6432 | default:
|
6433 | if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
6434 | encoding = ('' + encoding).toLowerCase()
|
6435 | loweredCase = true
|
6436 | }
|
6437 | }
|
6438 | }
|
6439 |
|
6440 | Buffer.prototype.toJSON = function toJSON () {
|
6441 | return {
|
6442 | type: 'Buffer',
|
6443 | data: Array.prototype.slice.call(this._arr || this, 0)
|
6444 | }
|
6445 | }
|
6446 |
|
6447 | function base64Slice (buf, start, end) {
|
6448 | if (start === 0 && end === buf.length) {
|
6449 | return base64.fromByteArray(buf)
|
6450 | } else {
|
6451 | return base64.fromByteArray(buf.slice(start, end))
|
6452 | }
|
6453 | }
|
6454 |
|
6455 | function utf8Slice (buf, start, end) {
|
6456 | end = Math.min(buf.length, end)
|
6457 | var res = []
|
6458 |
|
6459 | var i = start
|
6460 | while (i < end) {
|
6461 | var firstByte = buf[i]
|
6462 | var codePoint = null
|
6463 | var bytesPerSequence = (firstByte > 0xEF) ? 4
|
6464 | : (firstByte > 0xDF) ? 3
|
6465 | : (firstByte > 0xBF) ? 2
|
6466 | : 1
|
6467 |
|
6468 | if (i + bytesPerSequence <= end) {
|
6469 | var secondByte, thirdByte, fourthByte, tempCodePoint
|
6470 |
|
6471 | switch (bytesPerSequence) {
|
6472 | case 1:
|
6473 | if (firstByte < 0x80) {
|
6474 | codePoint = firstByte
|
6475 | }
|
6476 | break
|
6477 | case 2:
|
6478 | secondByte = buf[i + 1]
|
6479 | if ((secondByte & 0xC0) === 0x80) {
|
6480 | tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
6481 | if (tempCodePoint > 0x7F) {
|
6482 | codePoint = tempCodePoint
|
6483 | }
|
6484 | }
|
6485 | break
|
6486 | case 3:
|
6487 | secondByte = buf[i + 1]
|
6488 | thirdByte = buf[i + 2]
|
6489 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
6490 | tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
6491 | if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
6492 | codePoint = tempCodePoint
|
6493 | }
|
6494 | }
|
6495 | break
|
6496 | case 4:
|
6497 | secondByte = buf[i + 1]
|
6498 | thirdByte = buf[i + 2]
|
6499 | fourthByte = buf[i + 3]
|
6500 | if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
6501 | tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
6502 | if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
6503 | codePoint = tempCodePoint
|
6504 | }
|
6505 | }
|
6506 | }
|
6507 | }
|
6508 |
|
6509 | if (codePoint === null) {
|
6510 |
|
6511 |
|
6512 | codePoint = 0xFFFD
|
6513 | bytesPerSequence = 1
|
6514 | } else if (codePoint > 0xFFFF) {
|
6515 |
|
6516 | codePoint -= 0x10000
|
6517 | res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
6518 | codePoint = 0xDC00 | codePoint & 0x3FF
|
6519 | }
|
6520 |
|
6521 | res.push(codePoint)
|
6522 | i += bytesPerSequence
|
6523 | }
|
6524 |
|
6525 | return decodeCodePointsArray(res)
|
6526 | }
|
6527 |
|
6528 |
|
6529 |
|
6530 |
|
6531 | var MAX_ARGUMENTS_LENGTH = 0x1000
|
6532 |
|
6533 | function decodeCodePointsArray (codePoints) {
|
6534 | var len = codePoints.length
|
6535 | if (len <= MAX_ARGUMENTS_LENGTH) {
|
6536 | return String.fromCharCode.apply(String, codePoints)
|
6537 | }
|
6538 |
|
6539 |
|
6540 | var res = ''
|
6541 | var i = 0
|
6542 | while (i < len) {
|
6543 | res += String.fromCharCode.apply(
|
6544 | String,
|
6545 | codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
6546 | )
|
6547 | }
|
6548 | return res
|
6549 | }
|
6550 |
|
6551 | function asciiSlice (buf, start, end) {
|
6552 | var ret = ''
|
6553 | end = Math.min(buf.length, end)
|
6554 |
|
6555 | for (var i = start; i < end; i++) {
|
6556 | ret += String.fromCharCode(buf[i] & 0x7F)
|
6557 | }
|
6558 | return ret
|
6559 | }
|
6560 |
|
6561 | function binarySlice (buf, start, end) {
|
6562 | var ret = ''
|
6563 | end = Math.min(buf.length, end)
|
6564 |
|
6565 | for (var i = start; i < end; i++) {
|
6566 | ret += String.fromCharCode(buf[i])
|
6567 | }
|
6568 | return ret
|
6569 | }
|
6570 |
|
6571 | function hexSlice (buf, start, end) {
|
6572 | var len = buf.length
|
6573 |
|
6574 | if (!start || start < 0) start = 0
|
6575 | if (!end || end < 0 || end > len) end = len
|
6576 |
|
6577 | var out = ''
|
6578 | for (var i = start; i < end; i++) {
|
6579 | out += toHex(buf[i])
|
6580 | }
|
6581 | return out
|
6582 | }
|
6583 |
|
6584 | function utf16leSlice (buf, start, end) {
|
6585 | var bytes = buf.slice(start, end)
|
6586 | var res = ''
|
6587 | for (var i = 0; i < bytes.length; i += 2) {
|
6588 | res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
6589 | }
|
6590 | return res
|
6591 | }
|
6592 |
|
6593 | Buffer.prototype.slice = function slice (start, end) {
|
6594 | var len = this.length
|
6595 | start = ~~start
|
6596 | end = end === undefined ? len : ~~end
|
6597 |
|
6598 | if (start < 0) {
|
6599 | start += len
|
6600 | if (start < 0) start = 0
|
6601 | } else if (start > len) {
|
6602 | start = len
|
6603 | }
|
6604 |
|
6605 | if (end < 0) {
|
6606 | end += len
|
6607 | if (end < 0) end = 0
|
6608 | } else if (end > len) {
|
6609 | end = len
|
6610 | }
|
6611 |
|
6612 | if (end < start) end = start
|
6613 |
|
6614 | var newBuf
|
6615 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6616 | newBuf = Buffer._augment(this.subarray(start, end))
|
6617 | } else {
|
6618 | var sliceLen = end - start
|
6619 | newBuf = new Buffer(sliceLen, undefined)
|
6620 | for (var i = 0; i < sliceLen; i++) {
|
6621 | newBuf[i] = this[i + start]
|
6622 | }
|
6623 | }
|
6624 |
|
6625 | if (newBuf.length) newBuf.parent = this.parent || this
|
6626 |
|
6627 | return newBuf
|
6628 | }
|
6629 |
|
6630 |
|
6631 |
|
6632 |
|
6633 | function checkOffset (offset, ext, length) {
|
6634 | if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
6635 | if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
6636 | }
|
6637 |
|
6638 | Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
6639 | offset = offset | 0
|
6640 | byteLength = byteLength | 0
|
6641 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
6642 |
|
6643 | var val = this[offset]
|
6644 | var mul = 1
|
6645 | var i = 0
|
6646 | while (++i < byteLength && (mul *= 0x100)) {
|
6647 | val += this[offset + i] * mul
|
6648 | }
|
6649 |
|
6650 | return val
|
6651 | }
|
6652 |
|
6653 | Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
6654 | offset = offset | 0
|
6655 | byteLength = byteLength | 0
|
6656 | if (!noAssert) {
|
6657 | checkOffset(offset, byteLength, this.length)
|
6658 | }
|
6659 |
|
6660 | var val = this[offset + --byteLength]
|
6661 | var mul = 1
|
6662 | while (byteLength > 0 && (mul *= 0x100)) {
|
6663 | val += this[offset + --byteLength] * mul
|
6664 | }
|
6665 |
|
6666 | return val
|
6667 | }
|
6668 |
|
6669 | Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
6670 | if (!noAssert) checkOffset(offset, 1, this.length)
|
6671 | return this[offset]
|
6672 | }
|
6673 |
|
6674 | Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
6675 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6676 | return this[offset] | (this[offset + 1] << 8)
|
6677 | }
|
6678 |
|
6679 | Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
6680 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6681 | return (this[offset] << 8) | this[offset + 1]
|
6682 | }
|
6683 |
|
6684 | Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
6685 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6686 |
|
6687 | return ((this[offset]) |
|
6688 | (this[offset + 1] << 8) |
|
6689 | (this[offset + 2] << 16)) +
|
6690 | (this[offset + 3] * 0x1000000)
|
6691 | }
|
6692 |
|
6693 | Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
6694 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6695 |
|
6696 | return (this[offset] * 0x1000000) +
|
6697 | ((this[offset + 1] << 16) |
|
6698 | (this[offset + 2] << 8) |
|
6699 | this[offset + 3])
|
6700 | }
|
6701 |
|
6702 | Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
6703 | offset = offset | 0
|
6704 | byteLength = byteLength | 0
|
6705 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
6706 |
|
6707 | var val = this[offset]
|
6708 | var mul = 1
|
6709 | var i = 0
|
6710 | while (++i < byteLength && (mul *= 0x100)) {
|
6711 | val += this[offset + i] * mul
|
6712 | }
|
6713 | mul *= 0x80
|
6714 |
|
6715 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
6716 |
|
6717 | return val
|
6718 | }
|
6719 |
|
6720 | Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
6721 | offset = offset | 0
|
6722 | byteLength = byteLength | 0
|
6723 | if (!noAssert) checkOffset(offset, byteLength, this.length)
|
6724 |
|
6725 | var i = byteLength
|
6726 | var mul = 1
|
6727 | var val = this[offset + --i]
|
6728 | while (i > 0 && (mul *= 0x100)) {
|
6729 | val += this[offset + --i] * mul
|
6730 | }
|
6731 | mul *= 0x80
|
6732 |
|
6733 | if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
6734 |
|
6735 | return val
|
6736 | }
|
6737 |
|
6738 | Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
6739 | if (!noAssert) checkOffset(offset, 1, this.length)
|
6740 | if (!(this[offset] & 0x80)) return (this[offset])
|
6741 | return ((0xff - this[offset] + 1) * -1)
|
6742 | }
|
6743 |
|
6744 | Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
6745 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6746 | var val = this[offset] | (this[offset + 1] << 8)
|
6747 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
6748 | }
|
6749 |
|
6750 | Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
6751 | if (!noAssert) checkOffset(offset, 2, this.length)
|
6752 | var val = this[offset + 1] | (this[offset] << 8)
|
6753 | return (val & 0x8000) ? val | 0xFFFF0000 : val
|
6754 | }
|
6755 |
|
6756 | Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
6757 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6758 |
|
6759 | return (this[offset]) |
|
6760 | (this[offset + 1] << 8) |
|
6761 | (this[offset + 2] << 16) |
|
6762 | (this[offset + 3] << 24)
|
6763 | }
|
6764 |
|
6765 | Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
6766 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6767 |
|
6768 | return (this[offset] << 24) |
|
6769 | (this[offset + 1] << 16) |
|
6770 | (this[offset + 2] << 8) |
|
6771 | (this[offset + 3])
|
6772 | }
|
6773 |
|
6774 | Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
6775 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6776 | return ieee754.read(this, offset, true, 23, 4)
|
6777 | }
|
6778 |
|
6779 | Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
6780 | if (!noAssert) checkOffset(offset, 4, this.length)
|
6781 | return ieee754.read(this, offset, false, 23, 4)
|
6782 | }
|
6783 |
|
6784 | Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
6785 | if (!noAssert) checkOffset(offset, 8, this.length)
|
6786 | return ieee754.read(this, offset, true, 52, 8)
|
6787 | }
|
6788 |
|
6789 | Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
6790 | if (!noAssert) checkOffset(offset, 8, this.length)
|
6791 | return ieee754.read(this, offset, false, 52, 8)
|
6792 | }
|
6793 |
|
6794 | function checkInt (buf, value, offset, ext, max, min) {
|
6795 | if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
|
6796 | if (value > max || value < min) throw new RangeError('value is out of bounds')
|
6797 | if (offset + ext > buf.length) throw new RangeError('index out of range')
|
6798 | }
|
6799 |
|
6800 | Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
6801 | value = +value
|
6802 | offset = offset | 0
|
6803 | byteLength = byteLength | 0
|
6804 | if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
6805 |
|
6806 | var mul = 1
|
6807 | var i = 0
|
6808 | this[offset] = value & 0xFF
|
6809 | while (++i < byteLength && (mul *= 0x100)) {
|
6810 | this[offset + i] = (value / mul) & 0xFF
|
6811 | }
|
6812 |
|
6813 | return offset + byteLength
|
6814 | }
|
6815 |
|
6816 | Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
6817 | value = +value
|
6818 | offset = offset | 0
|
6819 | byteLength = byteLength | 0
|
6820 | if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
6821 |
|
6822 | var i = byteLength - 1
|
6823 | var mul = 1
|
6824 | this[offset + i] = value & 0xFF
|
6825 | while (--i >= 0 && (mul *= 0x100)) {
|
6826 | this[offset + i] = (value / mul) & 0xFF
|
6827 | }
|
6828 |
|
6829 | return offset + byteLength
|
6830 | }
|
6831 |
|
6832 | Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
6833 | value = +value
|
6834 | offset = offset | 0
|
6835 | if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
6836 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
6837 | this[offset] = (value & 0xff)
|
6838 | return offset + 1
|
6839 | }
|
6840 |
|
6841 | function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
6842 | if (value < 0) value = 0xffff + value + 1
|
6843 | for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
|
6844 | buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
6845 | (littleEndian ? i : 1 - i) * 8
|
6846 | }
|
6847 | }
|
6848 |
|
6849 | Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
6850 | value = +value
|
6851 | offset = offset | 0
|
6852 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
6853 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6854 | this[offset] = (value & 0xff)
|
6855 | this[offset + 1] = (value >>> 8)
|
6856 | } else {
|
6857 | objectWriteUInt16(this, value, offset, true)
|
6858 | }
|
6859 | return offset + 2
|
6860 | }
|
6861 |
|
6862 | Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
6863 | value = +value
|
6864 | offset = offset | 0
|
6865 | if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
6866 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6867 | this[offset] = (value >>> 8)
|
6868 | this[offset + 1] = (value & 0xff)
|
6869 | } else {
|
6870 | objectWriteUInt16(this, value, offset, false)
|
6871 | }
|
6872 | return offset + 2
|
6873 | }
|
6874 |
|
6875 | function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
6876 | if (value < 0) value = 0xffffffff + value + 1
|
6877 | for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
|
6878 | buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
6879 | }
|
6880 | }
|
6881 |
|
6882 | Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
6883 | value = +value
|
6884 | offset = offset | 0
|
6885 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
6886 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6887 | this[offset + 3] = (value >>> 24)
|
6888 | this[offset + 2] = (value >>> 16)
|
6889 | this[offset + 1] = (value >>> 8)
|
6890 | this[offset] = (value & 0xff)
|
6891 | } else {
|
6892 | objectWriteUInt32(this, value, offset, true)
|
6893 | }
|
6894 | return offset + 4
|
6895 | }
|
6896 |
|
6897 | Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
6898 | value = +value
|
6899 | offset = offset | 0
|
6900 | if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
6901 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6902 | this[offset] = (value >>> 24)
|
6903 | this[offset + 1] = (value >>> 16)
|
6904 | this[offset + 2] = (value >>> 8)
|
6905 | this[offset + 3] = (value & 0xff)
|
6906 | } else {
|
6907 | objectWriteUInt32(this, value, offset, false)
|
6908 | }
|
6909 | return offset + 4
|
6910 | }
|
6911 |
|
6912 | Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
6913 | value = +value
|
6914 | offset = offset | 0
|
6915 | if (!noAssert) {
|
6916 | var limit = Math.pow(2, 8 * byteLength - 1)
|
6917 |
|
6918 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
6919 | }
|
6920 |
|
6921 | var i = 0
|
6922 | var mul = 1
|
6923 | var sub = value < 0 ? 1 : 0
|
6924 | this[offset] = value & 0xFF
|
6925 | while (++i < byteLength && (mul *= 0x100)) {
|
6926 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
6927 | }
|
6928 |
|
6929 | return offset + byteLength
|
6930 | }
|
6931 |
|
6932 | Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
6933 | value = +value
|
6934 | offset = offset | 0
|
6935 | if (!noAssert) {
|
6936 | var limit = Math.pow(2, 8 * byteLength - 1)
|
6937 |
|
6938 | checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
6939 | }
|
6940 |
|
6941 | var i = byteLength - 1
|
6942 | var mul = 1
|
6943 | var sub = value < 0 ? 1 : 0
|
6944 | this[offset + i] = value & 0xFF
|
6945 | while (--i >= 0 && (mul *= 0x100)) {
|
6946 | this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
6947 | }
|
6948 |
|
6949 | return offset + byteLength
|
6950 | }
|
6951 |
|
6952 | Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
6953 | value = +value
|
6954 | offset = offset | 0
|
6955 | if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
6956 | if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
6957 | if (value < 0) value = 0xff + value + 1
|
6958 | this[offset] = (value & 0xff)
|
6959 | return offset + 1
|
6960 | }
|
6961 |
|
6962 | Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
6963 | value = +value
|
6964 | offset = offset | 0
|
6965 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
6966 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6967 | this[offset] = (value & 0xff)
|
6968 | this[offset + 1] = (value >>> 8)
|
6969 | } else {
|
6970 | objectWriteUInt16(this, value, offset, true)
|
6971 | }
|
6972 | return offset + 2
|
6973 | }
|
6974 |
|
6975 | Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
6976 | value = +value
|
6977 | offset = offset | 0
|
6978 | if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
6979 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6980 | this[offset] = (value >>> 8)
|
6981 | this[offset + 1] = (value & 0xff)
|
6982 | } else {
|
6983 | objectWriteUInt16(this, value, offset, false)
|
6984 | }
|
6985 | return offset + 2
|
6986 | }
|
6987 |
|
6988 | Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
6989 | value = +value
|
6990 | offset = offset | 0
|
6991 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
6992 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
6993 | this[offset] = (value & 0xff)
|
6994 | this[offset + 1] = (value >>> 8)
|
6995 | this[offset + 2] = (value >>> 16)
|
6996 | this[offset + 3] = (value >>> 24)
|
6997 | } else {
|
6998 | objectWriteUInt32(this, value, offset, true)
|
6999 | }
|
7000 | return offset + 4
|
7001 | }
|
7002 |
|
7003 | Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
7004 | value = +value
|
7005 | offset = offset | 0
|
7006 | if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
7007 | if (value < 0) value = 0xffffffff + value + 1
|
7008 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7009 | this[offset] = (value >>> 24)
|
7010 | this[offset + 1] = (value >>> 16)
|
7011 | this[offset + 2] = (value >>> 8)
|
7012 | this[offset + 3] = (value & 0xff)
|
7013 | } else {
|
7014 | objectWriteUInt32(this, value, offset, false)
|
7015 | }
|
7016 | return offset + 4
|
7017 | }
|
7018 |
|
7019 | function checkIEEE754 (buf, value, offset, ext, max, min) {
|
7020 | if (value > max || value < min) throw new RangeError('value is out of bounds')
|
7021 | if (offset + ext > buf.length) throw new RangeError('index out of range')
|
7022 | if (offset < 0) throw new RangeError('index out of range')
|
7023 | }
|
7024 |
|
7025 | function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
7026 | if (!noAssert) {
|
7027 | checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
7028 | }
|
7029 | ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
7030 | return offset + 4
|
7031 | }
|
7032 |
|
7033 | Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
7034 | return writeFloat(this, value, offset, true, noAssert)
|
7035 | }
|
7036 |
|
7037 | Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
7038 | return writeFloat(this, value, offset, false, noAssert)
|
7039 | }
|
7040 |
|
7041 | function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
7042 | if (!noAssert) {
|
7043 | checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
7044 | }
|
7045 | ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
7046 | return offset + 8
|
7047 | }
|
7048 |
|
7049 | Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
7050 | return writeDouble(this, value, offset, true, noAssert)
|
7051 | }
|
7052 |
|
7053 | Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
7054 | return writeDouble(this, value, offset, false, noAssert)
|
7055 | }
|
7056 |
|
7057 |
|
7058 | Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
7059 | if (!start) start = 0
|
7060 | if (!end && end !== 0) end = this.length
|
7061 | if (targetStart >= target.length) targetStart = target.length
|
7062 | if (!targetStart) targetStart = 0
|
7063 | if (end > 0 && end < start) end = start
|
7064 |
|
7065 |
|
7066 | if (end === start) return 0
|
7067 | if (target.length === 0 || this.length === 0) return 0
|
7068 |
|
7069 |
|
7070 | if (targetStart < 0) {
|
7071 | throw new RangeError('targetStart out of bounds')
|
7072 | }
|
7073 | if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
7074 | if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
7075 |
|
7076 |
|
7077 | if (end > this.length) end = this.length
|
7078 | if (target.length - targetStart < end - start) {
|
7079 | end = target.length - targetStart + start
|
7080 | }
|
7081 |
|
7082 | var len = end - start
|
7083 | var i
|
7084 |
|
7085 | if (this === target && start < targetStart && targetStart < end) {
|
7086 |
|
7087 | for (i = len - 1; i >= 0; i--) {
|
7088 | target[i + targetStart] = this[i + start]
|
7089 | }
|
7090 | } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
7091 |
|
7092 | for (i = 0; i < len; i++) {
|
7093 | target[i + targetStart] = this[i + start]
|
7094 | }
|
7095 | } else {
|
7096 | target._set(this.subarray(start, start + len), targetStart)
|
7097 | }
|
7098 |
|
7099 | return len
|
7100 | }
|
7101 |
|
7102 |
|
7103 | Buffer.prototype.fill = function fill (value, start, end) {
|
7104 | if (!value) value = 0
|
7105 | if (!start) start = 0
|
7106 | if (!end) end = this.length
|
7107 |
|
7108 | if (end < start) throw new RangeError('end < start')
|
7109 |
|
7110 |
|
7111 | if (end === start) return
|
7112 | if (this.length === 0) return
|
7113 |
|
7114 | if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
|
7115 | if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
|
7116 |
|
7117 | var i
|
7118 | if (typeof value === 'number') {
|
7119 | for (i = start; i < end; i++) {
|
7120 | this[i] = value
|
7121 | }
|
7122 | } else {
|
7123 | var bytes = utf8ToBytes(value.toString())
|
7124 | var len = bytes.length
|
7125 | for (i = start; i < end; i++) {
|
7126 | this[i] = bytes[i % len]
|
7127 | }
|
7128 | }
|
7129 |
|
7130 | return this
|
7131 | }
|
7132 |
|
7133 |
|
7134 |
|
7135 |
|
7136 |
|
7137 | Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
|
7138 | if (typeof Uint8Array !== 'undefined') {
|
7139 | if (Buffer.TYPED_ARRAY_SUPPORT) {
|
7140 | return (new Buffer(this)).buffer
|
7141 | } else {
|
7142 | var buf = new Uint8Array(this.length)
|
7143 | for (var i = 0, len = buf.length; i < len; i += 1) {
|
7144 | buf[i] = this[i]
|
7145 | }
|
7146 | return buf.buffer
|
7147 | }
|
7148 | } else {
|
7149 | throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
|
7150 | }
|
7151 | }
|
7152 |
|
7153 |
|
7154 |
|
7155 |
|
7156 | var BP = Buffer.prototype
|
7157 |
|
7158 |
|
7159 |
|
7160 |
|
7161 | Buffer._augment = function _augment (arr) {
|
7162 | arr.constructor = Buffer
|
7163 | arr._isBuffer = true
|
7164 |
|
7165 |
|
7166 | arr._set = arr.set
|
7167 |
|
7168 |
|
7169 | arr.get = BP.get
|
7170 | arr.set = BP.set
|
7171 |
|
7172 | arr.write = BP.write
|
7173 | arr.toString = BP.toString
|
7174 | arr.toLocaleString = BP.toString
|
7175 | arr.toJSON = BP.toJSON
|
7176 | arr.equals = BP.equals
|
7177 | arr.compare = BP.compare
|
7178 | arr.indexOf = BP.indexOf
|
7179 | arr.copy = BP.copy
|
7180 | arr.slice = BP.slice
|
7181 | arr.readUIntLE = BP.readUIntLE
|
7182 | arr.readUIntBE = BP.readUIntBE
|
7183 | arr.readUInt8 = BP.readUInt8
|
7184 | arr.readUInt16LE = BP.readUInt16LE
|
7185 | arr.readUInt16BE = BP.readUInt16BE
|
7186 | arr.readUInt32LE = BP.readUInt32LE
|
7187 | arr.readUInt32BE = BP.readUInt32BE
|
7188 | arr.readIntLE = BP.readIntLE
|
7189 | arr.readIntBE = BP.readIntBE
|
7190 | arr.readInt8 = BP.readInt8
|
7191 | arr.readInt16LE = BP.readInt16LE
|
7192 | arr.readInt16BE = BP.readInt16BE
|
7193 | arr.readInt32LE = BP.readInt32LE
|
7194 | arr.readInt32BE = BP.readInt32BE
|
7195 | arr.readFloatLE = BP.readFloatLE
|
7196 | arr.readFloatBE = BP.readFloatBE
|
7197 | arr.readDoubleLE = BP.readDoubleLE
|
7198 | arr.readDoubleBE = BP.readDoubleBE
|
7199 | arr.writeUInt8 = BP.writeUInt8
|
7200 | arr.writeUIntLE = BP.writeUIntLE
|
7201 | arr.writeUIntBE = BP.writeUIntBE
|
7202 | arr.writeUInt16LE = BP.writeUInt16LE
|
7203 | arr.writeUInt16BE = BP.writeUInt16BE
|
7204 | arr.writeUInt32LE = BP.writeUInt32LE
|
7205 | arr.writeUInt32BE = BP.writeUInt32BE
|
7206 | arr.writeIntLE = BP.writeIntLE
|
7207 | arr.writeIntBE = BP.writeIntBE
|
7208 | arr.writeInt8 = BP.writeInt8
|
7209 | arr.writeInt16LE = BP.writeInt16LE
|
7210 | arr.writeInt16BE = BP.writeInt16BE
|
7211 | arr.writeInt32LE = BP.writeInt32LE
|
7212 | arr.writeInt32BE = BP.writeInt32BE
|
7213 | arr.writeFloatLE = BP.writeFloatLE
|
7214 | arr.writeFloatBE = BP.writeFloatBE
|
7215 | arr.writeDoubleLE = BP.writeDoubleLE
|
7216 | arr.writeDoubleBE = BP.writeDoubleBE
|
7217 | arr.fill = BP.fill
|
7218 | arr.inspect = BP.inspect
|
7219 | arr.toArrayBuffer = BP.toArrayBuffer
|
7220 |
|
7221 | return arr
|
7222 | }
|
7223 |
|
7224 | var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
7225 |
|
7226 | function base64clean (str) {
|
7227 |
|
7228 | str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
7229 |
|
7230 | if (str.length < 2) return ''
|
7231 |
|
7232 | while (str.length % 4 !== 0) {
|
7233 | str = str + '='
|
7234 | }
|
7235 | return str
|
7236 | }
|
7237 |
|
7238 | function stringtrim (str) {
|
7239 | if (str.trim) return str.trim()
|
7240 | return str.replace(/^\s+|\s+$/g, '')
|
7241 | }
|
7242 |
|
7243 | function toHex (n) {
|
7244 | if (n < 16) return '0' + n.toString(16)
|
7245 | return n.toString(16)
|
7246 | }
|
7247 |
|
7248 | function utf8ToBytes (string, units) {
|
7249 | units = units || Infinity
|
7250 | var codePoint
|
7251 | var length = string.length
|
7252 | var leadSurrogate = null
|
7253 | var bytes = []
|
7254 |
|
7255 | for (var i = 0; i < length; i++) {
|
7256 | codePoint = string.charCodeAt(i)
|
7257 |
|
7258 |
|
7259 | if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
7260 |
|
7261 | if (!leadSurrogate) {
|
7262 |
|
7263 | if (codePoint > 0xDBFF) {
|
7264 |
|
7265 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7266 | continue
|
7267 | } else if (i + 1 === length) {
|
7268 |
|
7269 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7270 | continue
|
7271 | }
|
7272 |
|
7273 |
|
7274 | leadSurrogate = codePoint
|
7275 |
|
7276 | continue
|
7277 | }
|
7278 |
|
7279 |
|
7280 | if (codePoint < 0xDC00) {
|
7281 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7282 | leadSurrogate = codePoint
|
7283 | continue
|
7284 | }
|
7285 |
|
7286 |
|
7287 | codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
7288 | } else if (leadSurrogate) {
|
7289 |
|
7290 | if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
7291 | }
|
7292 |
|
7293 | leadSurrogate = null
|
7294 |
|
7295 |
|
7296 | if (codePoint < 0x80) {
|
7297 | if ((units -= 1) < 0) break
|
7298 | bytes.push(codePoint)
|
7299 | } else if (codePoint < 0x800) {
|
7300 | if ((units -= 2) < 0) break
|
7301 | bytes.push(
|
7302 | codePoint >> 0x6 | 0xC0,
|
7303 | codePoint & 0x3F | 0x80
|
7304 | )
|
7305 | } else if (codePoint < 0x10000) {
|
7306 | if ((units -= 3) < 0) break
|
7307 | bytes.push(
|
7308 | codePoint >> 0xC | 0xE0,
|
7309 | codePoint >> 0x6 & 0x3F | 0x80,
|
7310 | codePoint & 0x3F | 0x80
|
7311 | )
|
7312 | } else if (codePoint < 0x110000) {
|
7313 | if ((units -= 4) < 0) break
|
7314 | bytes.push(
|
7315 | codePoint >> 0x12 | 0xF0,
|
7316 | codePoint >> 0xC & 0x3F | 0x80,
|
7317 | codePoint >> 0x6 & 0x3F | 0x80,
|
7318 | codePoint & 0x3F | 0x80
|
7319 | )
|
7320 | } else {
|
7321 | throw new Error('Invalid code point')
|
7322 | }
|
7323 | }
|
7324 |
|
7325 | return bytes
|
7326 | }
|
7327 |
|
7328 | function asciiToBytes (str) {
|
7329 | var byteArray = []
|
7330 | for (var i = 0; i < str.length; i++) {
|
7331 |
|
7332 | byteArray.push(str.charCodeAt(i) & 0xFF)
|
7333 | }
|
7334 | return byteArray
|
7335 | }
|
7336 |
|
7337 | function utf16leToBytes (str, units) {
|
7338 | var c, hi, lo
|
7339 | var byteArray = []
|
7340 | for (var i = 0; i < str.length; i++) {
|
7341 | if ((units -= 2) < 0) break
|
7342 |
|
7343 | c = str.charCodeAt(i)
|
7344 | hi = c >> 8
|
7345 | lo = c % 256
|
7346 | byteArray.push(lo)
|
7347 | byteArray.push(hi)
|
7348 | }
|
7349 |
|
7350 | return byteArray
|
7351 | }
|
7352 |
|
7353 | function base64ToBytes (str) {
|
7354 | return base64.toByteArray(base64clean(str))
|
7355 | }
|
7356 |
|
7357 | function blitBuffer (src, dst, offset, length) {
|
7358 | for (var i = 0; i < length; i++) {
|
7359 | if ((i + offset >= dst.length) || (i >= src.length)) break
|
7360 | dst[i + offset] = src[i]
|
7361 | }
|
7362 | return i
|
7363 | }
|
7364 |
|
7365 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
7366 | },{"base64-js":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js","ieee754":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js","isarray":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/node_modules/isarray/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/node_modules/base64-js/lib/b64.js":[function(require,module,exports){
|
7367 | var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
7368 |
|
7369 | ;(function (exports) {
|
7370 | 'use strict';
|
7371 |
|
7372 | var Arr = (typeof Uint8Array !== 'undefined')
|
7373 | ? Uint8Array
|
7374 | : Array
|
7375 |
|
7376 | var PLUS = '+'.charCodeAt(0)
|
7377 | var SLASH = '/'.charCodeAt(0)
|
7378 | var NUMBER = '0'.charCodeAt(0)
|
7379 | var LOWER = 'a'.charCodeAt(0)
|
7380 | var UPPER = 'A'.charCodeAt(0)
|
7381 | var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
7382 | var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
7383 |
|
7384 | function decode (elt) {
|
7385 | var code = elt.charCodeAt(0)
|
7386 | if (code === PLUS ||
|
7387 | code === PLUS_URL_SAFE)
|
7388 | return 62
|
7389 | if (code === SLASH ||
|
7390 | code === SLASH_URL_SAFE)
|
7391 | return 63
|
7392 | if (code < NUMBER)
|
7393 | return -1
|
7394 | if (code < NUMBER + 10)
|
7395 | return code - NUMBER + 26 + 26
|
7396 | if (code < UPPER + 26)
|
7397 | return code - UPPER
|
7398 | if (code < LOWER + 26)
|
7399 | return code - LOWER + 26
|
7400 | }
|
7401 |
|
7402 | function b64ToByteArray (b64) {
|
7403 | var i, j, l, tmp, placeHolders, arr
|
7404 |
|
7405 | if (b64.length % 4 > 0) {
|
7406 | throw new Error('Invalid string. Length must be a multiple of 4')
|
7407 | }
|
7408 |
|
7409 |
|
7410 |
|
7411 |
|
7412 |
|
7413 |
|
7414 | var len = b64.length
|
7415 | placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
7416 |
|
7417 |
|
7418 | arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
7419 |
|
7420 |
|
7421 | l = placeHolders > 0 ? b64.length - 4 : b64.length
|
7422 |
|
7423 | var L = 0
|
7424 |
|
7425 | function push (v) {
|
7426 | arr[L++] = v
|
7427 | }
|
7428 |
|
7429 | for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
7430 | tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
7431 | push((tmp & 0xFF0000) >> 16)
|
7432 | push((tmp & 0xFF00) >> 8)
|
7433 | push(tmp & 0xFF)
|
7434 | }
|
7435 |
|
7436 | if (placeHolders === 2) {
|
7437 | tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
7438 | push(tmp & 0xFF)
|
7439 | } else if (placeHolders === 1) {
|
7440 | tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
7441 | push((tmp >> 8) & 0xFF)
|
7442 | push(tmp & 0xFF)
|
7443 | }
|
7444 |
|
7445 | return arr
|
7446 | }
|
7447 |
|
7448 | function uint8ToBase64 (uint8) {
|
7449 | var i,
|
7450 | extraBytes = uint8.length % 3,
|
7451 | output = "",
|
7452 | temp, length
|
7453 |
|
7454 | function encode (num) {
|
7455 | return lookup.charAt(num)
|
7456 | }
|
7457 |
|
7458 | function tripletToBase64 (num) {
|
7459 | return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
7460 | }
|
7461 |
|
7462 |
|
7463 | for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
7464 | temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
7465 | output += tripletToBase64(temp)
|
7466 | }
|
7467 |
|
7468 |
|
7469 | switch (extraBytes) {
|
7470 | case 1:
|
7471 | temp = uint8[uint8.length - 1]
|
7472 | output += encode(temp >> 2)
|
7473 | output += encode((temp << 4) & 0x3F)
|
7474 | output += '=='
|
7475 | break
|
7476 | case 2:
|
7477 | temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
7478 | output += encode(temp >> 10)
|
7479 | output += encode((temp >> 4) & 0x3F)
|
7480 | output += encode((temp << 2) & 0x3F)
|
7481 | output += '='
|
7482 | break
|
7483 | }
|
7484 |
|
7485 | return output
|
7486 | }
|
7487 |
|
7488 | exports.toByteArray = b64ToByteArray
|
7489 | exports.fromByteArray = uint8ToBase64
|
7490 | }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
7491 |
|
7492 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/node_modules/ieee754/index.js":[function(require,module,exports){
|
7493 | exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
7494 | var e, m
|
7495 | var eLen = nBytes * 8 - mLen - 1
|
7496 | var eMax = (1 << eLen) - 1
|
7497 | var eBias = eMax >> 1
|
7498 | var nBits = -7
|
7499 | var i = isLE ? (nBytes - 1) : 0
|
7500 | var d = isLE ? -1 : 1
|
7501 | var s = buffer[offset + i]
|
7502 |
|
7503 | i += d
|
7504 |
|
7505 | e = s & ((1 << (-nBits)) - 1)
|
7506 | s >>= (-nBits)
|
7507 | nBits += eLen
|
7508 | for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
7509 |
|
7510 | m = e & ((1 << (-nBits)) - 1)
|
7511 | e >>= (-nBits)
|
7512 | nBits += mLen
|
7513 | for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
7514 |
|
7515 | if (e === 0) {
|
7516 | e = 1 - eBias
|
7517 | } else if (e === eMax) {
|
7518 | return m ? NaN : ((s ? -1 : 1) * Infinity)
|
7519 | } else {
|
7520 | m = m + Math.pow(2, mLen)
|
7521 | e = e - eBias
|
7522 | }
|
7523 | return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
7524 | }
|
7525 |
|
7526 | exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
7527 | var e, m, c
|
7528 | var eLen = nBytes * 8 - mLen - 1
|
7529 | var eMax = (1 << eLen) - 1
|
7530 | var eBias = eMax >> 1
|
7531 | var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
7532 | var i = isLE ? 0 : (nBytes - 1)
|
7533 | var d = isLE ? 1 : -1
|
7534 | var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
7535 |
|
7536 | value = Math.abs(value)
|
7537 |
|
7538 | if (isNaN(value) || value === Infinity) {
|
7539 | m = isNaN(value) ? 1 : 0
|
7540 | e = eMax
|
7541 | } else {
|
7542 | e = Math.floor(Math.log(value) / Math.LN2)
|
7543 | if (value * (c = Math.pow(2, -e)) < 1) {
|
7544 | e--
|
7545 | c *= 2
|
7546 | }
|
7547 | if (e + eBias >= 1) {
|
7548 | value += rt / c
|
7549 | } else {
|
7550 | value += rt * Math.pow(2, 1 - eBias)
|
7551 | }
|
7552 | if (value * c >= 2) {
|
7553 | e++
|
7554 | c /= 2
|
7555 | }
|
7556 |
|
7557 | if (e + eBias >= eMax) {
|
7558 | m = 0
|
7559 | e = eMax
|
7560 | } else if (e + eBias >= 1) {
|
7561 | m = (value * c - 1) * Math.pow(2, mLen)
|
7562 | e = e + eBias
|
7563 | } else {
|
7564 | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
7565 | e = 0
|
7566 | }
|
7567 | }
|
7568 |
|
7569 | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
7570 |
|
7571 | e = (e << mLen) | m
|
7572 | eLen += mLen
|
7573 | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
7574 |
|
7575 | buffer[offset + i - d] |= s * 128
|
7576 | }
|
7577 |
|
7578 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/node_modules/isarray/index.js":[function(require,module,exports){
|
7579 | var toString = {}.toString;
|
7580 |
|
7581 | module.exports = Array.isArray || function (arr) {
|
7582 | return toString.call(arr) == '[object Array]';
|
7583 | };
|
7584 |
|
7585 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/events/events.js":[function(require,module,exports){
|
7586 |
|
7587 |
|
7588 |
|
7589 |
|
7590 |
|
7591 |
|
7592 |
|
7593 |
|
7594 |
|
7595 |
|
7596 |
|
7597 |
|
7598 |
|
7599 |
|
7600 |
|
7601 |
|
7602 |
|
7603 |
|
7604 |
|
7605 |
|
7606 |
|
7607 | function EventEmitter() {
|
7608 | this._events = this._events || {};
|
7609 | this._maxListeners = this._maxListeners || undefined;
|
7610 | }
|
7611 | module.exports = EventEmitter;
|
7612 |
|
7613 |
|
7614 | EventEmitter.EventEmitter = EventEmitter;
|
7615 |
|
7616 | EventEmitter.prototype._events = undefined;
|
7617 | EventEmitter.prototype._maxListeners = undefined;
|
7618 |
|
7619 |
|
7620 |
|
7621 | EventEmitter.defaultMaxListeners = 10;
|
7622 |
|
7623 |
|
7624 |
|
7625 | EventEmitter.prototype.setMaxListeners = function(n) {
|
7626 | if (!isNumber(n) || n < 0 || isNaN(n))
|
7627 | throw TypeError('n must be a positive number');
|
7628 | this._maxListeners = n;
|
7629 | return this;
|
7630 | };
|
7631 |
|
7632 | EventEmitter.prototype.emit = function(type) {
|
7633 | var er, handler, len, args, i, listeners;
|
7634 |
|
7635 | if (!this._events)
|
7636 | this._events = {};
|
7637 |
|
7638 |
|
7639 | if (type === 'error') {
|
7640 | if (!this._events.error ||
|
7641 | (isObject(this._events.error) && !this._events.error.length)) {
|
7642 | er = arguments[1];
|
7643 | if (er instanceof Error) {
|
7644 | throw er;
|
7645 | }
|
7646 | throw TypeError('Uncaught, unspecified "error" event.');
|
7647 | }
|
7648 | }
|
7649 |
|
7650 | handler = this._events[type];
|
7651 |
|
7652 | if (isUndefined(handler))
|
7653 | return false;
|
7654 |
|
7655 | if (isFunction(handler)) {
|
7656 | switch (arguments.length) {
|
7657 |
|
7658 | case 1:
|
7659 | handler.call(this);
|
7660 | break;
|
7661 | case 2:
|
7662 | handler.call(this, arguments[1]);
|
7663 | break;
|
7664 | case 3:
|
7665 | handler.call(this, arguments[1], arguments[2]);
|
7666 | break;
|
7667 |
|
7668 | default:
|
7669 | len = arguments.length;
|
7670 | args = new Array(len - 1);
|
7671 | for (i = 1; i < len; i++)
|
7672 | args[i - 1] = arguments[i];
|
7673 | handler.apply(this, args);
|
7674 | }
|
7675 | } else if (isObject(handler)) {
|
7676 | len = arguments.length;
|
7677 | args = new Array(len - 1);
|
7678 | for (i = 1; i < len; i++)
|
7679 | args[i - 1] = arguments[i];
|
7680 |
|
7681 | listeners = handler.slice();
|
7682 | len = listeners.length;
|
7683 | for (i = 0; i < len; i++)
|
7684 | listeners[i].apply(this, args);
|
7685 | }
|
7686 |
|
7687 | return true;
|
7688 | };
|
7689 |
|
7690 | EventEmitter.prototype.addListener = function(type, listener) {
|
7691 | var m;
|
7692 |
|
7693 | if (!isFunction(listener))
|
7694 | throw TypeError('listener must be a function');
|
7695 |
|
7696 | if (!this._events)
|
7697 | this._events = {};
|
7698 |
|
7699 |
|
7700 |
|
7701 | if (this._events.newListener)
|
7702 | this.emit('newListener', type,
|
7703 | isFunction(listener.listener) ?
|
7704 | listener.listener : listener);
|
7705 |
|
7706 | if (!this._events[type])
|
7707 |
|
7708 | this._events[type] = listener;
|
7709 | else if (isObject(this._events[type]))
|
7710 |
|
7711 | this._events[type].push(listener);
|
7712 | else
|
7713 |
|
7714 | this._events[type] = [this._events[type], listener];
|
7715 |
|
7716 |
|
7717 | if (isObject(this._events[type]) && !this._events[type].warned) {
|
7718 | var m;
|
7719 | if (!isUndefined(this._maxListeners)) {
|
7720 | m = this._maxListeners;
|
7721 | } else {
|
7722 | m = EventEmitter.defaultMaxListeners;
|
7723 | }
|
7724 |
|
7725 | if (m && m > 0 && this._events[type].length > m) {
|
7726 | this._events[type].warned = true;
|
7727 | console.error('(node) warning: possible EventEmitter memory ' +
|
7728 | 'leak detected. %d listeners added. ' +
|
7729 | 'Use emitter.setMaxListeners() to increase limit.',
|
7730 | this._events[type].length);
|
7731 | if (typeof console.trace === 'function') {
|
7732 |
|
7733 | console.trace();
|
7734 | }
|
7735 | }
|
7736 | }
|
7737 |
|
7738 | return this;
|
7739 | };
|
7740 |
|
7741 | EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
7742 |
|
7743 | EventEmitter.prototype.once = function(type, listener) {
|
7744 | if (!isFunction(listener))
|
7745 | throw TypeError('listener must be a function');
|
7746 |
|
7747 | var fired = false;
|
7748 |
|
7749 | function g() {
|
7750 | this.removeListener(type, g);
|
7751 |
|
7752 | if (!fired) {
|
7753 | fired = true;
|
7754 | listener.apply(this, arguments);
|
7755 | }
|
7756 | }
|
7757 |
|
7758 | g.listener = listener;
|
7759 | this.on(type, g);
|
7760 |
|
7761 | return this;
|
7762 | };
|
7763 |
|
7764 |
|
7765 | EventEmitter.prototype.removeListener = function(type, listener) {
|
7766 | var list, position, length, i;
|
7767 |
|
7768 | if (!isFunction(listener))
|
7769 | throw TypeError('listener must be a function');
|
7770 |
|
7771 | if (!this._events || !this._events[type])
|
7772 | return this;
|
7773 |
|
7774 | list = this._events[type];
|
7775 | length = list.length;
|
7776 | position = -1;
|
7777 |
|
7778 | if (list === listener ||
|
7779 | (isFunction(list.listener) && list.listener === listener)) {
|
7780 | delete this._events[type];
|
7781 | if (this._events.removeListener)
|
7782 | this.emit('removeListener', type, listener);
|
7783 |
|
7784 | } else if (isObject(list)) {
|
7785 | for (i = length; i-- > 0;) {
|
7786 | if (list[i] === listener ||
|
7787 | (list[i].listener && list[i].listener === listener)) {
|
7788 | position = i;
|
7789 | break;
|
7790 | }
|
7791 | }
|
7792 |
|
7793 | if (position < 0)
|
7794 | return this;
|
7795 |
|
7796 | if (list.length === 1) {
|
7797 | list.length = 0;
|
7798 | delete this._events[type];
|
7799 | } else {
|
7800 | list.splice(position, 1);
|
7801 | }
|
7802 |
|
7803 | if (this._events.removeListener)
|
7804 | this.emit('removeListener', type, listener);
|
7805 | }
|
7806 |
|
7807 | return this;
|
7808 | };
|
7809 |
|
7810 | EventEmitter.prototype.removeAllListeners = function(type) {
|
7811 | var key, listeners;
|
7812 |
|
7813 | if (!this._events)
|
7814 | return this;
|
7815 |
|
7816 |
|
7817 | if (!this._events.removeListener) {
|
7818 | if (arguments.length === 0)
|
7819 | this._events = {};
|
7820 | else if (this._events[type])
|
7821 | delete this._events[type];
|
7822 | return this;
|
7823 | }
|
7824 |
|
7825 |
|
7826 | if (arguments.length === 0) {
|
7827 | for (key in this._events) {
|
7828 | if (key === 'removeListener') continue;
|
7829 | this.removeAllListeners(key);
|
7830 | }
|
7831 | this.removeAllListeners('removeListener');
|
7832 | this._events = {};
|
7833 | return this;
|
7834 | }
|
7835 |
|
7836 | listeners = this._events[type];
|
7837 |
|
7838 | if (isFunction(listeners)) {
|
7839 | this.removeListener(type, listeners);
|
7840 | } else {
|
7841 |
|
7842 | while (listeners.length)
|
7843 | this.removeListener(type, listeners[listeners.length - 1]);
|
7844 | }
|
7845 | delete this._events[type];
|
7846 |
|
7847 | return this;
|
7848 | };
|
7849 |
|
7850 | EventEmitter.prototype.listeners = function(type) {
|
7851 | var ret;
|
7852 | if (!this._events || !this._events[type])
|
7853 | ret = [];
|
7854 | else if (isFunction(this._events[type]))
|
7855 | ret = [this._events[type]];
|
7856 | else
|
7857 | ret = this._events[type].slice();
|
7858 | return ret;
|
7859 | };
|
7860 |
|
7861 | EventEmitter.listenerCount = function(emitter, type) {
|
7862 | var ret;
|
7863 | if (!emitter._events || !emitter._events[type])
|
7864 | ret = 0;
|
7865 | else if (isFunction(emitter._events[type]))
|
7866 | ret = 1;
|
7867 | else
|
7868 | ret = emitter._events[type].length;
|
7869 | return ret;
|
7870 | };
|
7871 |
|
7872 | function isFunction(arg) {
|
7873 | return typeof arg === 'function';
|
7874 | }
|
7875 |
|
7876 | function isNumber(arg) {
|
7877 | return typeof arg === 'number';
|
7878 | }
|
7879 |
|
7880 | function isObject(arg) {
|
7881 | return typeof arg === 'object' && arg !== null;
|
7882 | }
|
7883 |
|
7884 | function isUndefined(arg) {
|
7885 | return arg === void 0;
|
7886 | }
|
7887 |
|
7888 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/process/browser.js":[function(require,module,exports){
|
7889 |
|
7890 |
|
7891 | var process = module.exports = {};
|
7892 | var queue = [];
|
7893 | var draining = false;
|
7894 | var currentQueue;
|
7895 | var queueIndex = -1;
|
7896 |
|
7897 | function cleanUpNextTick() {
|
7898 | draining = false;
|
7899 | if (currentQueue.length) {
|
7900 | queue = currentQueue.concat(queue);
|
7901 | } else {
|
7902 | queueIndex = -1;
|
7903 | }
|
7904 | if (queue.length) {
|
7905 | drainQueue();
|
7906 | }
|
7907 | }
|
7908 |
|
7909 | function drainQueue() {
|
7910 | if (draining) {
|
7911 | return;
|
7912 | }
|
7913 | var timeout = setTimeout(cleanUpNextTick);
|
7914 | draining = true;
|
7915 |
|
7916 | var len = queue.length;
|
7917 | while(len) {
|
7918 | currentQueue = queue;
|
7919 | queue = [];
|
7920 | while (++queueIndex < len) {
|
7921 | if (currentQueue) {
|
7922 | currentQueue[queueIndex].run();
|
7923 | }
|
7924 | }
|
7925 | queueIndex = -1;
|
7926 | len = queue.length;
|
7927 | }
|
7928 | currentQueue = null;
|
7929 | draining = false;
|
7930 | clearTimeout(timeout);
|
7931 | }
|
7932 |
|
7933 | process.nextTick = function (fun) {
|
7934 | var args = new Array(arguments.length - 1);
|
7935 | if (arguments.length > 1) {
|
7936 | for (var i = 1; i < arguments.length; i++) {
|
7937 | args[i - 1] = arguments[i];
|
7938 | }
|
7939 | }
|
7940 | queue.push(new Item(fun, args));
|
7941 | if (queue.length === 1 && !draining) {
|
7942 | setTimeout(drainQueue, 0);
|
7943 | }
|
7944 | };
|
7945 |
|
7946 |
|
7947 | function Item(fun, array) {
|
7948 | this.fun = fun;
|
7949 | this.array = array;
|
7950 | }
|
7951 | Item.prototype.run = function () {
|
7952 | this.fun.apply(null, this.array);
|
7953 | };
|
7954 | process.title = 'browser';
|
7955 | process.browser = true;
|
7956 | process.env = {};
|
7957 | process.argv = [];
|
7958 | process.version = '';
|
7959 | process.versions = {};
|
7960 |
|
7961 | function noop() {}
|
7962 |
|
7963 | process.on = noop;
|
7964 | process.addListener = noop;
|
7965 | process.once = noop;
|
7966 | process.off = noop;
|
7967 | process.removeListener = noop;
|
7968 | process.removeAllListeners = noop;
|
7969 | process.emit = noop;
|
7970 |
|
7971 | process.binding = function (name) {
|
7972 | throw new Error('process.binding is not supported');
|
7973 | };
|
7974 |
|
7975 | process.cwd = function () { return '/' };
|
7976 | process.chdir = function (dir) {
|
7977 | throw new Error('process.chdir is not supported');
|
7978 | };
|
7979 | process.umask = function() { return 0; };
|
7980 |
|
7981 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/inherits/inherits_browser.js":[function(require,module,exports){
|
7982 | if (typeof Object.create === 'function') {
|
7983 |
|
7984 | module.exports = function inherits(ctor, superCtor) {
|
7985 | ctor.super_ = superCtor
|
7986 | ctor.prototype = Object.create(superCtor.prototype, {
|
7987 | constructor: {
|
7988 | value: ctor,
|
7989 | enumerable: false,
|
7990 | writable: true,
|
7991 | configurable: true
|
7992 | }
|
7993 | });
|
7994 | };
|
7995 | } else {
|
7996 |
|
7997 | module.exports = function inherits(ctor, superCtor) {
|
7998 | ctor.super_ = superCtor
|
7999 | var TempCtor = function () {}
|
8000 | TempCtor.prototype = superCtor.prototype
|
8001 | ctor.prototype = new TempCtor()
|
8002 | ctor.prototype.constructor = ctor
|
8003 | }
|
8004 | }
|
8005 |
|
8006 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/lodash/index.js":[function(require,module,exports){
|
8007 | (function (global){
|
8008 |
|
8009 |
|
8010 |
|
8011 |
|
8012 |
|
8013 |
|
8014 |
|
8015 |
|
8016 |
|
8017 | ;(function() {
|
8018 |
|
8019 |
|
8020 | var undefined;
|
8021 |
|
8022 |
|
8023 | var VERSION = '3.10.1';
|
8024 |
|
8025 |
|
8026 | var BIND_FLAG = 1,
|
8027 | BIND_KEY_FLAG = 2,
|
8028 | CURRY_BOUND_FLAG = 4,
|
8029 | CURRY_FLAG = 8,
|
8030 | CURRY_RIGHT_FLAG = 16,
|
8031 | PARTIAL_FLAG = 32,
|
8032 | PARTIAL_RIGHT_FLAG = 64,
|
8033 | ARY_FLAG = 128,
|
8034 | REARG_FLAG = 256;
|
8035 |
|
8036 |
|
8037 | var DEFAULT_TRUNC_LENGTH = 30,
|
8038 | DEFAULT_TRUNC_OMISSION = '...';
|
8039 |
|
8040 |
|
8041 | var HOT_COUNT = 150,
|
8042 | HOT_SPAN = 16;
|
8043 |
|
8044 |
|
8045 | var LARGE_ARRAY_SIZE = 200;
|
8046 |
|
8047 |
|
8048 | var LAZY_FILTER_FLAG = 1,
|
8049 | LAZY_MAP_FLAG = 2;
|
8050 |
|
8051 |
|
8052 | var FUNC_ERROR_TEXT = 'Expected a function';
|
8053 |
|
8054 |
|
8055 | var PLACEHOLDER = '__lodash_placeholder__';
|
8056 |
|
8057 |
|
8058 | var argsTag = '[object Arguments]',
|
8059 | arrayTag = '[object Array]',
|
8060 | boolTag = '[object Boolean]',
|
8061 | dateTag = '[object Date]',
|
8062 | errorTag = '[object Error]',
|
8063 | funcTag = '[object Function]',
|
8064 | mapTag = '[object Map]',
|
8065 | numberTag = '[object Number]',
|
8066 | objectTag = '[object Object]',
|
8067 | regexpTag = '[object RegExp]',
|
8068 | setTag = '[object Set]',
|
8069 | stringTag = '[object String]',
|
8070 | weakMapTag = '[object WeakMap]';
|
8071 |
|
8072 | var arrayBufferTag = '[object ArrayBuffer]',
|
8073 | float32Tag = '[object Float32Array]',
|
8074 | float64Tag = '[object Float64Array]',
|
8075 | int8Tag = '[object Int8Array]',
|
8076 | int16Tag = '[object Int16Array]',
|
8077 | int32Tag = '[object Int32Array]',
|
8078 | uint8Tag = '[object Uint8Array]',
|
8079 | uint8ClampedTag = '[object Uint8ClampedArray]',
|
8080 | uint16Tag = '[object Uint16Array]',
|
8081 | uint32Tag = '[object Uint32Array]';
|
8082 |
|
8083 |
|
8084 | var reEmptyStringLeading = /\b__p \+= '';/g,
|
8085 | reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
8086 | reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
8087 |
|
8088 |
|
8089 | var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
|
8090 | reUnescapedHtml = /[&<>"'`]/g,
|
8091 | reHasEscapedHtml = RegExp(reEscapedHtml.source),
|
8092 | reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
8093 |
|
8094 |
|
8095 | var reEscape = /<%-([\s\S]+?)%>/g,
|
8096 | reEvaluate = /<%([\s\S]+?)%>/g,
|
8097 | reInterpolate = /<%=([\s\S]+?)%>/g;
|
8098 |
|
8099 |
|
8100 | var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
|
8101 | reIsPlainProp = /^\w*$/,
|
8102 | rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
|
8103 |
|
8104 | |
8105 |
|
8106 |
|
8107 |
|
8108 | var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,
|
8109 | reHasRegExpChars = RegExp(reRegExpChars.source);
|
8110 |
|
8111 |
|
8112 | var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g;
|
8113 |
|
8114 |
|
8115 | var reEscapeChar = /\\(\\)?/g;
|
8116 |
|
8117 |
|
8118 | var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
8119 |
|
8120 |
|
8121 | var reFlags = /\w*$/;
|
8122 |
|
8123 |
|
8124 | var reHasHexPrefix = /^0[xX]/;
|
8125 |
|
8126 |
|
8127 | var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
8128 |
|
8129 |
|
8130 | var reIsUint = /^\d+$/;
|
8131 |
|
8132 |
|
8133 | var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
|
8134 |
|
8135 |
|
8136 | var reNoMatch = /($^)/;
|
8137 |
|
8138 |
|
8139 | var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
8140 |
|
8141 |
|
8142 | var reWords = (function() {
|
8143 | var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]',
|
8144 | lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+';
|
8145 |
|
8146 | return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
|
8147 | }());
|
8148 |
|
8149 |
|
8150 | var contextProps = [
|
8151 | 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array',
|
8152 | 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number',
|
8153 | 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'isFinite',
|
8154 | 'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',
|
8155 | 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap'
|
8156 | ];
|
8157 |
|
8158 |
|
8159 | var templateCounter = -1;
|
8160 |
|
8161 |
|
8162 | var typedArrayTags = {};
|
8163 | typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
8164 | typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
8165 | typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
8166 | typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
8167 | typedArrayTags[uint32Tag] = true;
|
8168 | typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
8169 | typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
8170 | typedArrayTags[dateTag] = typedArrayTags[errorTag] =
|
8171 | typedArrayTags[funcTag] = typedArrayTags[mapTag] =
|
8172 | typedArrayTags[numberTag] = typedArrayTags[objectTag] =
|
8173 | typedArrayTags[regexpTag] = typedArrayTags[setTag] =
|
8174 | typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
|
8175 |
|
8176 |
|
8177 | var cloneableTags = {};
|
8178 | cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
8179 | cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
|
8180 | cloneableTags[dateTag] = cloneableTags[float32Tag] =
|
8181 | cloneableTags[float64Tag] = cloneableTags[int8Tag] =
|
8182 | cloneableTags[int16Tag] = cloneableTags[int32Tag] =
|
8183 | cloneableTags[numberTag] = cloneableTags[objectTag] =
|
8184 | cloneableTags[regexpTag] = cloneableTags[stringTag] =
|
8185 | cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
|
8186 | cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
8187 | cloneableTags[errorTag] = cloneableTags[funcTag] =
|
8188 | cloneableTags[mapTag] = cloneableTags[setTag] =
|
8189 | cloneableTags[weakMapTag] = false;
|
8190 |
|
8191 |
|
8192 | var deburredLetters = {
|
8193 | '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
|
8194 | '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
|
8195 | '\xc7': 'C', '\xe7': 'c',
|
8196 | '\xd0': 'D', '\xf0': 'd',
|
8197 | '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
|
8198 | '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
|
8199 | '\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
|
8200 | '\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
|
8201 | '\xd1': 'N', '\xf1': 'n',
|
8202 | '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
|
8203 | '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
|
8204 | '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
|
8205 | '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
|
8206 | '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
|
8207 | '\xc6': 'Ae', '\xe6': 'ae',
|
8208 | '\xde': 'Th', '\xfe': 'th',
|
8209 | '\xdf': 'ss'
|
8210 | };
|
8211 |
|
8212 |
|
8213 | var htmlEscapes = {
|
8214 | '&': '&',
|
8215 | '<': '<',
|
8216 | '>': '>',
|
8217 | '"': '"',
|
8218 | "'": ''',
|
8219 | '`': '`'
|
8220 | };
|
8221 |
|
8222 |
|
8223 | var htmlUnescapes = {
|
8224 | '&': '&',
|
8225 | '<': '<',
|
8226 | '>': '>',
|
8227 | '"': '"',
|
8228 | ''': "'",
|
8229 | '`': '`'
|
8230 | };
|
8231 |
|
8232 |
|
8233 | var objectTypes = {
|
8234 | 'function': true,
|
8235 | 'object': true
|
8236 | };
|
8237 |
|
8238 |
|
8239 | var regexpEscapes = {
|
8240 | '0': 'x30', '1': 'x31', '2': 'x32', '3': 'x33', '4': 'x34',
|
8241 | '5': 'x35', '6': 'x36', '7': 'x37', '8': 'x38', '9': 'x39',
|
8242 | 'A': 'x41', 'B': 'x42', 'C': 'x43', 'D': 'x44', 'E': 'x45', 'F': 'x46',
|
8243 | 'a': 'x61', 'b': 'x62', 'c': 'x63', 'd': 'x64', 'e': 'x65', 'f': 'x66',
|
8244 | 'n': 'x6e', 'r': 'x72', 't': 'x74', 'u': 'x75', 'v': 'x76', 'x': 'x78'
|
8245 | };
|
8246 |
|
8247 |
|
8248 | var stringEscapes = {
|
8249 | '\\': '\\',
|
8250 | "'": "'",
|
8251 | '\n': 'n',
|
8252 | '\r': 'r',
|
8253 | '\u2028': 'u2028',
|
8254 | '\u2029': 'u2029'
|
8255 | };
|
8256 |
|
8257 |
|
8258 | var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
8259 |
|
8260 |
|
8261 | var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
8262 |
|
8263 |
|
8264 | var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;
|
8265 |
|
8266 |
|
8267 | var freeSelf = objectTypes[typeof self] && self && self.Object && self;
|
8268 |
|
8269 |
|
8270 | var freeWindow = objectTypes[typeof window] && window && window.Object && window;
|
8271 |
|
8272 |
|
8273 | var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
|
8274 |
|
8275 | |
8276 |
|
8277 |
|
8278 |
|
8279 |
|
8280 |
|
8281 | var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
|
8282 |
|
8283 |
|
8284 |
|
8285 | |
8286 |
|
8287 |
|
8288 |
|
8289 |
|
8290 |
|
8291 |
|
8292 |
|
8293 |
|
8294 | function baseCompareAscending(value, other) {
|
8295 | if (value !== other) {
|
8296 | var valIsNull = value === null,
|
8297 | valIsUndef = value === undefined,
|
8298 | valIsReflexive = value === value;
|
8299 |
|
8300 | var othIsNull = other === null,
|
8301 | othIsUndef = other === undefined,
|
8302 | othIsReflexive = other === other;
|
8303 |
|
8304 | if ((value > other && !othIsNull) || !valIsReflexive ||
|
8305 | (valIsNull && !othIsUndef && othIsReflexive) ||
|
8306 | (valIsUndef && othIsReflexive)) {
|
8307 | return 1;
|
8308 | }
|
8309 | if ((value < other && !valIsNull) || !othIsReflexive ||
|
8310 | (othIsNull && !valIsUndef && valIsReflexive) ||
|
8311 | (othIsUndef && valIsReflexive)) {
|
8312 | return -1;
|
8313 | }
|
8314 | }
|
8315 | return 0;
|
8316 | }
|
8317 |
|
8318 | |
8319 |
|
8320 |
|
8321 |
|
8322 |
|
8323 |
|
8324 |
|
8325 |
|
8326 |
|
8327 |
|
8328 | function baseFindIndex(array, predicate, fromRight) {
|
8329 | var length = array.length,
|
8330 | index = fromRight ? length : -1;
|
8331 |
|
8332 | while ((fromRight ? index-- : ++index < length)) {
|
8333 | if (predicate(array[index], index, array)) {
|
8334 | return index;
|
8335 | }
|
8336 | }
|
8337 | return -1;
|
8338 | }
|
8339 |
|
8340 | |
8341 |
|
8342 |
|
8343 |
|
8344 |
|
8345 |
|
8346 |
|
8347 |
|
8348 |
|
8349 | function baseIndexOf(array, value, fromIndex) {
|
8350 | if (value !== value) {
|
8351 | return indexOfNaN(array, fromIndex);
|
8352 | }
|
8353 | var index = fromIndex - 1,
|
8354 | length = array.length;
|
8355 |
|
8356 | while (++index < length) {
|
8357 | if (array[index] === value) {
|
8358 | return index;
|
8359 | }
|
8360 | }
|
8361 | return -1;
|
8362 | }
|
8363 |
|
8364 | |
8365 |
|
8366 |
|
8367 |
|
8368 |
|
8369 |
|
8370 |
|
8371 |
|
8372 | function baseIsFunction(value) {
|
8373 |
|
8374 |
|
8375 | return typeof value == 'function' || false;
|
8376 | }
|
8377 |
|
8378 | |
8379 |
|
8380 |
|
8381 |
|
8382 |
|
8383 |
|
8384 |
|
8385 |
|
8386 | function baseToString(value) {
|
8387 | return value == null ? '' : (value + '');
|
8388 | }
|
8389 |
|
8390 | |
8391 |
|
8392 |
|
8393 |
|
8394 |
|
8395 |
|
8396 |
|
8397 |
|
8398 |
|
8399 | function charsLeftIndex(string, chars) {
|
8400 | var index = -1,
|
8401 | length = string.length;
|
8402 |
|
8403 | while (++index < length && chars.indexOf(string.charAt(index)) > -1) {}
|
8404 | return index;
|
8405 | }
|
8406 |
|
8407 | |
8408 |
|
8409 |
|
8410 |
|
8411 |
|
8412 |
|
8413 |
|
8414 |
|
8415 |
|
8416 | function charsRightIndex(string, chars) {
|
8417 | var index = string.length;
|
8418 |
|
8419 | while (index-- && chars.indexOf(string.charAt(index)) > -1) {}
|
8420 | return index;
|
8421 | }
|
8422 |
|
8423 | |
8424 |
|
8425 |
|
8426 |
|
8427 |
|
8428 |
|
8429 |
|
8430 |
|
8431 |
|
8432 | function compareAscending(object, other) {
|
8433 | return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);
|
8434 | }
|
8435 |
|
8436 | |
8437 |
|
8438 |
|
8439 |
|
8440 |
|
8441 |
|
8442 |
|
8443 |
|
8444 |
|
8445 |
|
8446 |
|
8447 |
|
8448 |
|
8449 |
|
8450 | function compareMultiple(object, other, orders) {
|
8451 | var index = -1,
|
8452 | objCriteria = object.criteria,
|
8453 | othCriteria = other.criteria,
|
8454 | length = objCriteria.length,
|
8455 | ordersLength = orders.length;
|
8456 |
|
8457 | while (++index < length) {
|
8458 | var result = baseCompareAscending(objCriteria[index], othCriteria[index]);
|
8459 | if (result) {
|
8460 | if (index >= ordersLength) {
|
8461 | return result;
|
8462 | }
|
8463 | var order = orders[index];
|
8464 | return result * ((order === 'asc' || order === true) ? 1 : -1);
|
8465 | }
|
8466 | }
|
8467 |
|
8468 |
|
8469 |
|
8470 |
|
8471 |
|
8472 |
|
8473 |
|
8474 | return object.index - other.index;
|
8475 | }
|
8476 |
|
8477 | |
8478 |
|
8479 |
|
8480 |
|
8481 |
|
8482 |
|
8483 |
|
8484 | function deburrLetter(letter) {
|
8485 | return deburredLetters[letter];
|
8486 | }
|
8487 |
|
8488 | |
8489 |
|
8490 |
|
8491 |
|
8492 |
|
8493 |
|
8494 |
|
8495 | function escapeHtmlChar(chr) {
|
8496 | return htmlEscapes[chr];
|
8497 | }
|
8498 |
|
8499 | |
8500 |
|
8501 |
|
8502 |
|
8503 |
|
8504 |
|
8505 |
|
8506 |
|
8507 |
|
8508 | function escapeRegExpChar(chr, leadingChar, whitespaceChar) {
|
8509 | if (leadingChar) {
|
8510 | chr = regexpEscapes[chr];
|
8511 | } else if (whitespaceChar) {
|
8512 | chr = stringEscapes[chr];
|
8513 | }
|
8514 | return '\\' + chr;
|
8515 | }
|
8516 |
|
8517 | |
8518 |
|
8519 |
|
8520 |
|
8521 |
|
8522 |
|
8523 |
|
8524 | function escapeStringChar(chr) {
|
8525 | return '\\' + stringEscapes[chr];
|
8526 | }
|
8527 |
|
8528 | |
8529 |
|
8530 |
|
8531 |
|
8532 |
|
8533 |
|
8534 |
|
8535 |
|
8536 |
|
8537 | function indexOfNaN(array, fromIndex, fromRight) {
|
8538 | var length = array.length,
|
8539 | index = fromIndex + (fromRight ? 0 : -1);
|
8540 |
|
8541 | while ((fromRight ? index-- : ++index < length)) {
|
8542 | var other = array[index];
|
8543 | if (other !== other) {
|
8544 | return index;
|
8545 | }
|
8546 | }
|
8547 | return -1;
|
8548 | }
|
8549 |
|
8550 | |
8551 |
|
8552 |
|
8553 |
|
8554 |
|
8555 |
|
8556 |
|
8557 | function isObjectLike(value) {
|
8558 | return !!value && typeof value == 'object';
|
8559 | }
|
8560 |
|
8561 | |
8562 |
|
8563 |
|
8564 |
|
8565 |
|
8566 |
|
8567 |
|
8568 |
|
8569 | function isSpace(charCode) {
|
8570 | return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 ||
|
8571 | (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279)));
|
8572 | }
|
8573 |
|
8574 | |
8575 |
|
8576 |
|
8577 |
|
8578 |
|
8579 |
|
8580 |
|
8581 |
|
8582 |
|
8583 | function replaceHolders(array, placeholder) {
|
8584 | var index = -1,
|
8585 | length = array.length,
|
8586 | resIndex = -1,
|
8587 | result = [];
|
8588 |
|
8589 | while (++index < length) {
|
8590 | if (array[index] === placeholder) {
|
8591 | array[index] = PLACEHOLDER;
|
8592 | result[++resIndex] = index;
|
8593 | }
|
8594 | }
|
8595 | return result;
|
8596 | }
|
8597 |
|
8598 | |
8599 |
|
8600 |
|
8601 |
|
8602 |
|
8603 |
|
8604 |
|
8605 |
|
8606 |
|
8607 | function sortedUniq(array, iteratee) {
|
8608 | var seen,
|
8609 | index = -1,
|
8610 | length = array.length,
|
8611 | resIndex = -1,
|
8612 | result = [];
|
8613 |
|
8614 | while (++index < length) {
|
8615 | var value = array[index],
|
8616 | computed = iteratee ? iteratee(value, index, array) : value;
|
8617 |
|
8618 | if (!index || seen !== computed) {
|
8619 | seen = computed;
|
8620 | result[++resIndex] = value;
|
8621 | }
|
8622 | }
|
8623 | return result;
|
8624 | }
|
8625 |
|
8626 | |
8627 |
|
8628 |
|
8629 |
|
8630 |
|
8631 |
|
8632 |
|
8633 |
|
8634 | function trimmedLeftIndex(string) {
|
8635 | var index = -1,
|
8636 | length = string.length;
|
8637 |
|
8638 | while (++index < length && isSpace(string.charCodeAt(index))) {}
|
8639 | return index;
|
8640 | }
|
8641 |
|
8642 | |
8643 |
|
8644 |
|
8645 |
|
8646 |
|
8647 |
|
8648 |
|
8649 |
|
8650 | function trimmedRightIndex(string) {
|
8651 | var index = string.length;
|
8652 |
|
8653 | while (index-- && isSpace(string.charCodeAt(index))) {}
|
8654 | return index;
|
8655 | }
|
8656 |
|
8657 | |
8658 |
|
8659 |
|
8660 |
|
8661 |
|
8662 |
|
8663 |
|
8664 | function unescapeHtmlChar(chr) {
|
8665 | return htmlUnescapes[chr];
|
8666 | }
|
8667 |
|
8668 |
|
8669 |
|
8670 | |
8671 |
|
8672 |
|
8673 |
|
8674 |
|
8675 |
|
8676 |
|
8677 |
|
8678 |
|
8679 |
|
8680 |
|
8681 |
|
8682 |
|
8683 |
|
8684 |
|
8685 |
|
8686 |
|
8687 |
|
8688 |
|
8689 |
|
8690 |
|
8691 |
|
8692 |
|
8693 |
|
8694 |
|
8695 |
|
8696 |
|
8697 |
|
8698 |
|
8699 |
|
8700 |
|
8701 |
|
8702 |
|
8703 |
|
8704 |
|
8705 | function runInContext(context) {
|
8706 |
|
8707 |
|
8708 |
|
8709 |
|
8710 | context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
|
8711 |
|
8712 |
|
8713 | var Array = context.Array,
|
8714 | Date = context.Date,
|
8715 | Error = context.Error,
|
8716 | Function = context.Function,
|
8717 | Math = context.Math,
|
8718 | Number = context.Number,
|
8719 | Object = context.Object,
|
8720 | RegExp = context.RegExp,
|
8721 | String = context.String,
|
8722 | TypeError = context.TypeError;
|
8723 |
|
8724 |
|
8725 | var arrayProto = Array.prototype,
|
8726 | objectProto = Object.prototype,
|
8727 | stringProto = String.prototype;
|
8728 |
|
8729 |
|
8730 | var fnToString = Function.prototype.toString;
|
8731 |
|
8732 |
|
8733 | var hasOwnProperty = objectProto.hasOwnProperty;
|
8734 |
|
8735 |
|
8736 | var idCounter = 0;
|
8737 |
|
8738 | |
8739 |
|
8740 |
|
8741 |
|
8742 | var objToString = objectProto.toString;
|
8743 |
|
8744 |
|
8745 | var oldDash = root._;
|
8746 |
|
8747 |
|
8748 | var reIsNative = RegExp('^' +
|
8749 | fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
|
8750 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
8751 | );
|
8752 |
|
8753 |
|
8754 | var ArrayBuffer = context.ArrayBuffer,
|
8755 | clearTimeout = context.clearTimeout,
|
8756 | parseFloat = context.parseFloat,
|
8757 | pow = Math.pow,
|
8758 | propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
8759 | Set = getNative(context, 'Set'),
|
8760 | setTimeout = context.setTimeout,
|
8761 | splice = arrayProto.splice,
|
8762 | Uint8Array = context.Uint8Array,
|
8763 | WeakMap = getNative(context, 'WeakMap');
|
8764 |
|
8765 |
|
8766 | var nativeCeil = Math.ceil,
|
8767 | nativeCreate = getNative(Object, 'create'),
|
8768 | nativeFloor = Math.floor,
|
8769 | nativeIsArray = getNative(Array, 'isArray'),
|
8770 | nativeIsFinite = context.isFinite,
|
8771 | nativeKeys = getNative(Object, 'keys'),
|
8772 | nativeMax = Math.max,
|
8773 | nativeMin = Math.min,
|
8774 | nativeNow = getNative(Date, 'now'),
|
8775 | nativeParseInt = context.parseInt,
|
8776 | nativeRandom = Math.random;
|
8777 |
|
8778 |
|
8779 | var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,
|
8780 | POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
8781 |
|
8782 |
|
8783 | var MAX_ARRAY_LENGTH = 4294967295,
|
8784 | MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
|
8785 | HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
|
8786 |
|
8787 | |
8788 |
|
8789 |
|
8790 |
|
8791 | var MAX_SAFE_INTEGER = 9007199254740991;
|
8792 |
|
8793 |
|
8794 | var metaMap = WeakMap && new WeakMap;
|
8795 |
|
8796 |
|
8797 | var realNames = {};
|
8798 |
|
8799 |
|
8800 |
|
8801 | |
8802 |
|
8803 |
|
8804 |
|
8805 |
|
8806 |
|
8807 |
|
8808 |
|
8809 |
|
8810 |
|
8811 |
|
8812 |
|
8813 |
|
8814 |
|
8815 |
|
8816 |
|
8817 |
|
8818 |
|
8819 |
|
8820 |
|
8821 |
|
8822 |
|
8823 |
|
8824 |
|
8825 |
|
8826 |
|
8827 |
|
8828 |
|
8829 |
|
8830 |
|
8831 |
|
8832 |
|
8833 |
|
8834 |
|
8835 |
|
8836 |
|
8837 |
|
8838 |
|
8839 |
|
8840 |
|
8841 |
|
8842 |
|
8843 |
|
8844 |
|
8845 |
|
8846 |
|
8847 |
|
8848 |
|
8849 |
|
8850 |
|
8851 |
|
8852 |
|
8853 |
|
8854 |
|
8855 |
|
8856 |
|
8857 |
|
8858 |
|
8859 |
|
8860 |
|
8861 |
|
8862 |
|
8863 |
|
8864 |
|
8865 |
|
8866 |
|
8867 |
|
8868 |
|
8869 |
|
8870 |
|
8871 |
|
8872 |
|
8873 |
|
8874 |
|
8875 |
|
8876 |
|
8877 |
|
8878 |
|
8879 |
|
8880 |
|
8881 |
|
8882 |
|
8883 |
|
8884 |
|
8885 |
|
8886 |
|
8887 |
|
8888 |
|
8889 |
|
8890 |
|
8891 |
|
8892 |
|
8893 |
|
8894 |
|
8895 |
|
8896 |
|
8897 | function lodash(value) {
|
8898 | if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
|
8899 | if (value instanceof LodashWrapper) {
|
8900 | return value;
|
8901 | }
|
8902 | if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {
|
8903 | return wrapperClone(value);
|
8904 | }
|
8905 | }
|
8906 | return new LodashWrapper(value);
|
8907 | }
|
8908 |
|
8909 | |
8910 |
|
8911 |
|
8912 |
|
8913 |
|
8914 | function baseLodash() {
|
8915 |
|
8916 | }
|
8917 |
|
8918 | |
8919 |
|
8920 |
|
8921 |
|
8922 |
|
8923 |
|
8924 |
|
8925 |
|
8926 | function LodashWrapper(value, chainAll, actions) {
|
8927 | this.__wrapped__ = value;
|
8928 | this.__actions__ = actions || [];
|
8929 | this.__chain__ = !!chainAll;
|
8930 | }
|
8931 |
|
8932 | |
8933 |
|
8934 |
|
8935 |
|
8936 |
|
8937 |
|
8938 |
|
8939 | var support = lodash.support = {};
|
8940 |
|
8941 | |
8942 |
|
8943 |
|
8944 |
|
8945 |
|
8946 |
|
8947 |
|
8948 |
|
8949 |
|
8950 | lodash.templateSettings = {
|
8951 |
|
8952 | |
8953 |
|
8954 |
|
8955 |
|
8956 |
|
8957 |
|
8958 | 'escape': reEscape,
|
8959 |
|
8960 | |
8961 |
|
8962 |
|
8963 |
|
8964 |
|
8965 |
|
8966 | 'evaluate': reEvaluate,
|
8967 |
|
8968 | |
8969 |
|
8970 |
|
8971 |
|
8972 |
|
8973 |
|
8974 | 'interpolate': reInterpolate,
|
8975 |
|
8976 | |
8977 |
|
8978 |
|
8979 |
|
8980 |
|
8981 |
|
8982 | 'variable': '',
|
8983 |
|
8984 | |
8985 |
|
8986 |
|
8987 |
|
8988 |
|
8989 |
|
8990 | 'imports': {
|
8991 |
|
8992 | |
8993 |
|
8994 |
|
8995 |
|
8996 |
|
8997 |
|
8998 | '_': lodash
|
8999 | }
|
9000 | };
|
9001 |
|
9002 |
|
9003 |
|
9004 | |
9005 |
|
9006 |
|
9007 |
|
9008 |
|
9009 |
|
9010 | function LazyWrapper(value) {
|
9011 | this.__wrapped__ = value;
|
9012 | this.__actions__ = [];
|
9013 | this.__dir__ = 1;
|
9014 | this.__filtered__ = false;
|
9015 | this.__iteratees__ = [];
|
9016 | this.__takeCount__ = POSITIVE_INFINITY;
|
9017 | this.__views__ = [];
|
9018 | }
|
9019 |
|
9020 | |
9021 |
|
9022 |
|
9023 |
|
9024 |
|
9025 |
|
9026 |
|
9027 |
|
9028 | function lazyClone() {
|
9029 | var result = new LazyWrapper(this.__wrapped__);
|
9030 | result.__actions__ = arrayCopy(this.__actions__);
|
9031 | result.__dir__ = this.__dir__;
|
9032 | result.__filtered__ = this.__filtered__;
|
9033 | result.__iteratees__ = arrayCopy(this.__iteratees__);
|
9034 | result.__takeCount__ = this.__takeCount__;
|
9035 | result.__views__ = arrayCopy(this.__views__);
|
9036 | return result;
|
9037 | }
|
9038 |
|
9039 | |
9040 |
|
9041 |
|
9042 |
|
9043 |
|
9044 |
|
9045 |
|
9046 |
|
9047 | function lazyReverse() {
|
9048 | if (this.__filtered__) {
|
9049 | var result = new LazyWrapper(this);
|
9050 | result.__dir__ = -1;
|
9051 | result.__filtered__ = true;
|
9052 | } else {
|
9053 | result = this.clone();
|
9054 | result.__dir__ *= -1;
|
9055 | }
|
9056 | return result;
|
9057 | }
|
9058 |
|
9059 | |
9060 |
|
9061 |
|
9062 |
|
9063 |
|
9064 |
|
9065 |
|
9066 |
|
9067 | function lazyValue() {
|
9068 | var array = this.__wrapped__.value(),
|
9069 | dir = this.__dir__,
|
9070 | isArr = isArray(array),
|
9071 | isRight = dir < 0,
|
9072 | arrLength = isArr ? array.length : 0,
|
9073 | view = getView(0, arrLength, this.__views__),
|
9074 | start = view.start,
|
9075 | end = view.end,
|
9076 | length = end - start,
|
9077 | index = isRight ? end : (start - 1),
|
9078 | iteratees = this.__iteratees__,
|
9079 | iterLength = iteratees.length,
|
9080 | resIndex = 0,
|
9081 | takeCount = nativeMin(length, this.__takeCount__);
|
9082 |
|
9083 | if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
|
9084 | return baseWrapperValue((isRight && isArr) ? array.reverse() : array, this.__actions__);
|
9085 | }
|
9086 | var result = [];
|
9087 |
|
9088 | outer:
|
9089 | while (length-- && resIndex < takeCount) {
|
9090 | index += dir;
|
9091 |
|
9092 | var iterIndex = -1,
|
9093 | value = array[index];
|
9094 |
|
9095 | while (++iterIndex < iterLength) {
|
9096 | var data = iteratees[iterIndex],
|
9097 | iteratee = data.iteratee,
|
9098 | type = data.type,
|
9099 | computed = iteratee(value);
|
9100 |
|
9101 | if (type == LAZY_MAP_FLAG) {
|
9102 | value = computed;
|
9103 | } else if (!computed) {
|
9104 | if (type == LAZY_FILTER_FLAG) {
|
9105 | continue outer;
|
9106 | } else {
|
9107 | break outer;
|
9108 | }
|
9109 | }
|
9110 | }
|
9111 | result[resIndex++] = value;
|
9112 | }
|
9113 | return result;
|
9114 | }
|
9115 |
|
9116 |
|
9117 |
|
9118 | |
9119 |
|
9120 |
|
9121 |
|
9122 |
|
9123 |
|
9124 |
|
9125 |
|
9126 | function MapCache() {
|
9127 | this.__data__ = {};
|
9128 | }
|
9129 |
|
9130 | |
9131 |
|
9132 |
|
9133 |
|
9134 |
|
9135 |
|
9136 |
|
9137 |
|
9138 |
|
9139 | function mapDelete(key) {
|
9140 | return this.has(key) && delete this.__data__[key];
|
9141 | }
|
9142 |
|
9143 | |
9144 |
|
9145 |
|
9146 |
|
9147 |
|
9148 |
|
9149 |
|
9150 |
|
9151 |
|
9152 | function mapGet(key) {
|
9153 | return key == '__proto__' ? undefined : this.__data__[key];
|
9154 | }
|
9155 |
|
9156 | |
9157 |
|
9158 |
|
9159 |
|
9160 |
|
9161 |
|
9162 |
|
9163 |
|
9164 |
|
9165 | function mapHas(key) {
|
9166 | return key != '__proto__' && hasOwnProperty.call(this.__data__, key);
|
9167 | }
|
9168 |
|
9169 | |
9170 |
|
9171 |
|
9172 |
|
9173 |
|
9174 |
|
9175 |
|
9176 |
|
9177 |
|
9178 |
|
9179 | function mapSet(key, value) {
|
9180 | if (key != '__proto__') {
|
9181 | this.__data__[key] = value;
|
9182 | }
|
9183 | return this;
|
9184 | }
|
9185 |
|
9186 |
|
9187 |
|
9188 | |
9189 |
|
9190 |
|
9191 |
|
9192 |
|
9193 |
|
9194 |
|
9195 | function SetCache(values) {
|
9196 | var length = values ? values.length : 0;
|
9197 |
|
9198 | this.data = { 'hash': nativeCreate(null), 'set': new Set };
|
9199 | while (length--) {
|
9200 | this.push(values[length]);
|
9201 | }
|
9202 | }
|
9203 |
|
9204 | |
9205 |
|
9206 |
|
9207 |
|
9208 |
|
9209 |
|
9210 |
|
9211 |
|
9212 |
|
9213 | function cacheIndexOf(cache, value) {
|
9214 | var data = cache.data,
|
9215 | result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
|
9216 |
|
9217 | return result ? 0 : -1;
|
9218 | }
|
9219 |
|
9220 | |
9221 |
|
9222 |
|
9223 |
|
9224 |
|
9225 |
|
9226 |
|
9227 |
|
9228 | function cachePush(value) {
|
9229 | var data = this.data;
|
9230 | if (typeof value == 'string' || isObject(value)) {
|
9231 | data.set.add(value);
|
9232 | } else {
|
9233 | data.hash[value] = true;
|
9234 | }
|
9235 | }
|
9236 |
|
9237 |
|
9238 |
|
9239 | |
9240 |
|
9241 |
|
9242 |
|
9243 |
|
9244 |
|
9245 |
|
9246 |
|
9247 | function arrayConcat(array, other) {
|
9248 | var index = -1,
|
9249 | length = array.length,
|
9250 | othIndex = -1,
|
9251 | othLength = other.length,
|
9252 | result = Array(length + othLength);
|
9253 |
|
9254 | while (++index < length) {
|
9255 | result[index] = array[index];
|
9256 | }
|
9257 | while (++othIndex < othLength) {
|
9258 | result[index++] = other[othIndex];
|
9259 | }
|
9260 | return result;
|
9261 | }
|
9262 |
|
9263 | |
9264 |
|
9265 |
|
9266 |
|
9267 |
|
9268 |
|
9269 |
|
9270 |
|
9271 | function arrayCopy(source, array) {
|
9272 | var index = -1,
|
9273 | length = source.length;
|
9274 |
|
9275 | array || (array = Array(length));
|
9276 | while (++index < length) {
|
9277 | array[index] = source[index];
|
9278 | }
|
9279 | return array;
|
9280 | }
|
9281 |
|
9282 | |
9283 |
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 |
|
9289 |
|
9290 |
|
9291 | function arrayEach(array, iteratee) {
|
9292 | var index = -1,
|
9293 | length = array.length;
|
9294 |
|
9295 | while (++index < length) {
|
9296 | if (iteratee(array[index], index, array) === false) {
|
9297 | break;
|
9298 | }
|
9299 | }
|
9300 | return array;
|
9301 | }
|
9302 |
|
9303 | |
9304 |
|
9305 |
|
9306 |
|
9307 |
|
9308 |
|
9309 |
|
9310 |
|
9311 |
|
9312 | function arrayEachRight(array, iteratee) {
|
9313 | var length = array.length;
|
9314 |
|
9315 | while (length--) {
|
9316 | if (iteratee(array[length], length, array) === false) {
|
9317 | break;
|
9318 | }
|
9319 | }
|
9320 | return array;
|
9321 | }
|
9322 |
|
9323 | |
9324 |
|
9325 |
|
9326 |
|
9327 |
|
9328 |
|
9329 |
|
9330 |
|
9331 |
|
9332 |
|
9333 | function arrayEvery(array, predicate) {
|
9334 | var index = -1,
|
9335 | length = array.length;
|
9336 |
|
9337 | while (++index < length) {
|
9338 | if (!predicate(array[index], index, array)) {
|
9339 | return false;
|
9340 | }
|
9341 | }
|
9342 | return true;
|
9343 | }
|
9344 |
|
9345 | |
9346 |
|
9347 |
|
9348 |
|
9349 |
|
9350 |
|
9351 |
|
9352 |
|
9353 |
|
9354 |
|
9355 |
|
9356 | function arrayExtremum(array, iteratee, comparator, exValue) {
|
9357 | var index = -1,
|
9358 | length = array.length,
|
9359 | computed = exValue,
|
9360 | result = computed;
|
9361 |
|
9362 | while (++index < length) {
|
9363 | var value = array[index],
|
9364 | current = +iteratee(value);
|
9365 |
|
9366 | if (comparator(current, computed)) {
|
9367 | computed = current;
|
9368 | result = value;
|
9369 | }
|
9370 | }
|
9371 | return result;
|
9372 | }
|
9373 |
|
9374 | |
9375 |
|
9376 |
|
9377 |
|
9378 |
|
9379 |
|
9380 |
|
9381 |
|
9382 |
|
9383 | function arrayFilter(array, predicate) {
|
9384 | var index = -1,
|
9385 | length = array.length,
|
9386 | resIndex = -1,
|
9387 | result = [];
|
9388 |
|
9389 | while (++index < length) {
|
9390 | var value = array[index];
|
9391 | if (predicate(value, index, array)) {
|
9392 | result[++resIndex] = value;
|
9393 | }
|
9394 | }
|
9395 | return result;
|
9396 | }
|
9397 |
|
9398 | |
9399 |
|
9400 |
|
9401 |
|
9402 |
|
9403 |
|
9404 |
|
9405 |
|
9406 |
|
9407 | function arrayMap(array, iteratee) {
|
9408 | var index = -1,
|
9409 | length = array.length,
|
9410 | result = Array(length);
|
9411 |
|
9412 | while (++index < length) {
|
9413 | result[index] = iteratee(array[index], index, array);
|
9414 | }
|
9415 | return result;
|
9416 | }
|
9417 |
|
9418 | |
9419 |
|
9420 |
|
9421 |
|
9422 |
|
9423 |
|
9424 |
|
9425 |
|
9426 | function arrayPush(array, values) {
|
9427 | var index = -1,
|
9428 | length = values.length,
|
9429 | offset = array.length;
|
9430 |
|
9431 | while (++index < length) {
|
9432 | array[offset + index] = values[index];
|
9433 | }
|
9434 | return array;
|
9435 | }
|
9436 |
|
9437 | |
9438 |
|
9439 |
|
9440 |
|
9441 |
|
9442 |
|
9443 |
|
9444 |
|
9445 |
|
9446 |
|
9447 |
|
9448 |
|
9449 | function arrayReduce(array, iteratee, accumulator, initFromArray) {
|
9450 | var index = -1,
|
9451 | length = array.length;
|
9452 |
|
9453 | if (initFromArray && length) {
|
9454 | accumulator = array[++index];
|
9455 | }
|
9456 | while (++index < length) {
|
9457 | accumulator = iteratee(accumulator, array[index], index, array);
|
9458 | }
|
9459 | return accumulator;
|
9460 | }
|
9461 |
|
9462 | |
9463 |
|
9464 |
|
9465 |
|
9466 |
|
9467 |
|
9468 |
|
9469 |
|
9470 |
|
9471 |
|
9472 |
|
9473 |
|
9474 | function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
|
9475 | var length = array.length;
|
9476 | if (initFromArray && length) {
|
9477 | accumulator = array[--length];
|
9478 | }
|
9479 | while (length--) {
|
9480 | accumulator = iteratee(accumulator, array[length], length, array);
|
9481 | }
|
9482 | return accumulator;
|
9483 | }
|
9484 |
|
9485 | |
9486 |
|
9487 |
|
9488 |
|
9489 |
|
9490 |
|
9491 |
|
9492 |
|
9493 |
|
9494 |
|
9495 | function arraySome(array, predicate) {
|
9496 | var index = -1,
|
9497 | length = array.length;
|
9498 |
|
9499 | while (++index < length) {
|
9500 | if (predicate(array[index], index, array)) {
|
9501 | return true;
|
9502 | }
|
9503 | }
|
9504 | return false;
|
9505 | }
|
9506 |
|
9507 | |
9508 |
|
9509 |
|
9510 |
|
9511 |
|
9512 |
|
9513 |
|
9514 |
|
9515 |
|
9516 | function arraySum(array, iteratee) {
|
9517 | var length = array.length,
|
9518 | result = 0;
|
9519 |
|
9520 | while (length--) {
|
9521 | result += +iteratee(array[length]) || 0;
|
9522 | }
|
9523 | return result;
|
9524 | }
|
9525 |
|
9526 | |
9527 |
|
9528 |
|
9529 |
|
9530 |
|
9531 |
|
9532 |
|
9533 |
|
9534 | function assignDefaults(objectValue, sourceValue) {
|
9535 | return objectValue === undefined ? sourceValue : objectValue;
|
9536 | }
|
9537 |
|
9538 | |
9539 |
|
9540 |
|
9541 |
|
9542 |
|
9543 |
|
9544 |
|
9545 |
|
9546 |
|
9547 |
|
9548 |
|
9549 |
|
9550 |
|
9551 | function assignOwnDefaults(objectValue, sourceValue, key, object) {
|
9552 | return (objectValue === undefined || !hasOwnProperty.call(object, key))
|
9553 | ? sourceValue
|
9554 | : objectValue;
|
9555 | }
|
9556 |
|
9557 | |
9558 |
|
9559 |
|
9560 |
|
9561 |
|
9562 |
|
9563 |
|
9564 |
|
9565 |
|
9566 |
|
9567 |
|
9568 | function assignWith(object, source, customizer) {
|
9569 | var index = -1,
|
9570 | props = keys(source),
|
9571 | length = props.length;
|
9572 |
|
9573 | while (++index < length) {
|
9574 | var key = props[index],
|
9575 | value = object[key],
|
9576 | result = customizer(value, source[key], key, object, source);
|
9577 |
|
9578 | if ((result === result ? (result !== value) : (value === value)) ||
|
9579 | (value === undefined && !(key in object))) {
|
9580 | object[key] = result;
|
9581 | }
|
9582 | }
|
9583 | return object;
|
9584 | }
|
9585 |
|
9586 | |
9587 |
|
9588 |
|
9589 |
|
9590 |
|
9591 |
|
9592 |
|
9593 |
|
9594 |
|
9595 | function baseAssign(object, source) {
|
9596 | return source == null
|
9597 | ? object
|
9598 | : baseCopy(source, keys(source), object);
|
9599 | }
|
9600 |
|
9601 | |
9602 |
|
9603 |
|
9604 |
|
9605 |
|
9606 |
|
9607 |
|
9608 |
|
9609 |
|
9610 | function baseAt(collection, props) {
|
9611 | var index = -1,
|
9612 | isNil = collection == null,
|
9613 | isArr = !isNil && isArrayLike(collection),
|
9614 | length = isArr ? collection.length : 0,
|
9615 | propsLength = props.length,
|
9616 | result = Array(propsLength);
|
9617 |
|
9618 | while(++index < propsLength) {
|
9619 | var key = props[index];
|
9620 | if (isArr) {
|
9621 | result[index] = isIndex(key, length) ? collection[key] : undefined;
|
9622 | } else {
|
9623 | result[index] = isNil ? undefined : collection[key];
|
9624 | }
|
9625 | }
|
9626 | return result;
|
9627 | }
|
9628 |
|
9629 | |
9630 |
|
9631 |
|
9632 |
|
9633 |
|
9634 |
|
9635 |
|
9636 |
|
9637 |
|
9638 | function baseCopy(source, props, object) {
|
9639 | object || (object = {});
|
9640 |
|
9641 | var index = -1,
|
9642 | length = props.length;
|
9643 |
|
9644 | while (++index < length) {
|
9645 | var key = props[index];
|
9646 | object[key] = source[key];
|
9647 | }
|
9648 | return object;
|
9649 | }
|
9650 |
|
9651 | |
9652 |
|
9653 |
|
9654 |
|
9655 |
|
9656 |
|
9657 |
|
9658 |
|
9659 |
|
9660 |
|
9661 | function baseCallback(func, thisArg, argCount) {
|
9662 | var type = typeof func;
|
9663 | if (type == 'function') {
|
9664 | return thisArg === undefined
|
9665 | ? func
|
9666 | : bindCallback(func, thisArg, argCount);
|
9667 | }
|
9668 | if (func == null) {
|
9669 | return identity;
|
9670 | }
|
9671 | if (type == 'object') {
|
9672 | return baseMatches(func);
|
9673 | }
|
9674 | return thisArg === undefined
|
9675 | ? property(func)
|
9676 | : baseMatchesProperty(func, thisArg);
|
9677 | }
|
9678 |
|
9679 | |
9680 |
|
9681 |
|
9682 |
|
9683 |
|
9684 |
|
9685 |
|
9686 |
|
9687 |
|
9688 |
|
9689 |
|
9690 |
|
9691 |
|
9692 |
|
9693 | function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
|
9694 | var result;
|
9695 | if (customizer) {
|
9696 | result = object ? customizer(value, key, object) : customizer(value);
|
9697 | }
|
9698 | if (result !== undefined) {
|
9699 | return result;
|
9700 | }
|
9701 | if (!isObject(value)) {
|
9702 | return value;
|
9703 | }
|
9704 | var isArr = isArray(value);
|
9705 | if (isArr) {
|
9706 | result = initCloneArray(value);
|
9707 | if (!isDeep) {
|
9708 | return arrayCopy(value, result);
|
9709 | }
|
9710 | } else {
|
9711 | var tag = objToString.call(value),
|
9712 | isFunc = tag == funcTag;
|
9713 |
|
9714 | if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
9715 | result = initCloneObject(isFunc ? {} : value);
|
9716 | if (!isDeep) {
|
9717 | return baseAssign(result, value);
|
9718 | }
|
9719 | } else {
|
9720 | return cloneableTags[tag]
|
9721 | ? initCloneByTag(value, tag, isDeep)
|
9722 | : (object ? value : {});
|
9723 | }
|
9724 | }
|
9725 |
|
9726 | stackA || (stackA = []);
|
9727 | stackB || (stackB = []);
|
9728 |
|
9729 | var length = stackA.length;
|
9730 | while (length--) {
|
9731 | if (stackA[length] == value) {
|
9732 | return stackB[length];
|
9733 | }
|
9734 | }
|
9735 |
|
9736 | stackA.push(value);
|
9737 | stackB.push(result);
|
9738 |
|
9739 |
|
9740 | (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
|
9741 | result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
|
9742 | });
|
9743 | return result;
|
9744 | }
|
9745 |
|
9746 | |
9747 |
|
9748 |
|
9749 |
|
9750 |
|
9751 |
|
9752 |
|
9753 |
|
9754 | var baseCreate = (function() {
|
9755 | function object() {}
|
9756 | return function(prototype) {
|
9757 | if (isObject(prototype)) {
|
9758 | object.prototype = prototype;
|
9759 | var result = new object;
|
9760 | object.prototype = undefined;
|
9761 | }
|
9762 | return result || {};
|
9763 | };
|
9764 | }());
|
9765 |
|
9766 | |
9767 |
|
9768 |
|
9769 |
|
9770 |
|
9771 |
|
9772 |
|
9773 |
|
9774 |
|
9775 |
|
9776 | function baseDelay(func, wait, args) {
|
9777 | if (typeof func != 'function') {
|
9778 | throw new TypeError(FUNC_ERROR_TEXT);
|
9779 | }
|
9780 | return setTimeout(function() { func.apply(undefined, args); }, wait);
|
9781 | }
|
9782 |
|
9783 | |
9784 |
|
9785 |
|
9786 |
|
9787 |
|
9788 |
|
9789 |
|
9790 |
|
9791 |
|
9792 | function baseDifference(array, values) {
|
9793 | var length = array ? array.length : 0,
|
9794 | result = [];
|
9795 |
|
9796 | if (!length) {
|
9797 | return result;
|
9798 | }
|
9799 | var index = -1,
|
9800 | indexOf = getIndexOf(),
|
9801 | isCommon = indexOf == baseIndexOf,
|
9802 | cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
|
9803 | valuesLength = values.length;
|
9804 |
|
9805 | if (cache) {
|
9806 | indexOf = cacheIndexOf;
|
9807 | isCommon = false;
|
9808 | values = cache;
|
9809 | }
|
9810 | outer:
|
9811 | while (++index < length) {
|
9812 | var value = array[index];
|
9813 |
|
9814 | if (isCommon && value === value) {
|
9815 | var valuesIndex = valuesLength;
|
9816 | while (valuesIndex--) {
|
9817 | if (values[valuesIndex] === value) {
|
9818 | continue outer;
|
9819 | }
|
9820 | }
|
9821 | result.push(value);
|
9822 | }
|
9823 | else if (indexOf(values, value, 0) < 0) {
|
9824 | result.push(value);
|
9825 | }
|
9826 | }
|
9827 | return result;
|
9828 | }
|
9829 |
|
9830 | |
9831 |
|
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 |
|
9838 |
|
9839 | var baseEach = createBaseEach(baseForOwn);
|
9840 |
|
9841 | |
9842 |
|
9843 |
|
9844 |
|
9845 |
|
9846 |
|
9847 |
|
9848 |
|
9849 |
|
9850 | var baseEachRight = createBaseEach(baseForOwnRight, true);
|
9851 |
|
9852 | |
9853 |
|
9854 |
|
9855 |
|
9856 |
|
9857 |
|
9858 |
|
9859 |
|
9860 |
|
9861 |
|
9862 | function baseEvery(collection, predicate) {
|
9863 | var result = true;
|
9864 | baseEach(collection, function(value, index, collection) {
|
9865 | result = !!predicate(value, index, collection);
|
9866 | return result;
|
9867 | });
|
9868 | return result;
|
9869 | }
|
9870 |
|
9871 | |
9872 |
|
9873 |
|
9874 |
|
9875 |
|
9876 |
|
9877 |
|
9878 |
|
9879 |
|
9880 |
|
9881 |
|
9882 |
|
9883 | function baseExtremum(collection, iteratee, comparator, exValue) {
|
9884 | var computed = exValue,
|
9885 | result = computed;
|
9886 |
|
9887 | baseEach(collection, function(value, index, collection) {
|
9888 | var current = +iteratee(value, index, collection);
|
9889 | if (comparator(current, computed) || (current === exValue && current === result)) {
|
9890 | computed = current;
|
9891 | result = value;
|
9892 | }
|
9893 | });
|
9894 | return result;
|
9895 | }
|
9896 |
|
9897 | |
9898 |
|
9899 |
|
9900 |
|
9901 |
|
9902 |
|
9903 |
|
9904 |
|
9905 |
|
9906 |
|
9907 | function baseFill(array, value, start, end) {
|
9908 | var length = array.length;
|
9909 |
|
9910 | start = start == null ? 0 : (+start || 0);
|
9911 | if (start < 0) {
|
9912 | start = -start > length ? 0 : (length + start);
|
9913 | }
|
9914 | end = (end === undefined || end > length) ? length : (+end || 0);
|
9915 | if (end < 0) {
|
9916 | end += length;
|
9917 | }
|
9918 | length = start > end ? 0 : (end >>> 0);
|
9919 | start >>>= 0;
|
9920 |
|
9921 | while (start < length) {
|
9922 | array[start++] = value;
|
9923 | }
|
9924 | return array;
|
9925 | }
|
9926 |
|
9927 | |
9928 |
|
9929 |
|
9930 |
|
9931 |
|
9932 |
|
9933 |
|
9934 |
|
9935 |
|
9936 | function baseFilter(collection, predicate) {
|
9937 | var result = [];
|
9938 | baseEach(collection, function(value, index, collection) {
|
9939 | if (predicate(value, index, collection)) {
|
9940 | result.push(value);
|
9941 | }
|
9942 | });
|
9943 | return result;
|
9944 | }
|
9945 |
|
9946 | |
9947 |
|
9948 |
|
9949 |
|
9950 |
|
9951 |
|
9952 |
|
9953 |
|
9954 |
|
9955 |
|
9956 |
|
9957 |
|
9958 |
|
9959 | function baseFind(collection, predicate, eachFunc, retKey) {
|
9960 | var result;
|
9961 | eachFunc(collection, function(value, key, collection) {
|
9962 | if (predicate(value, key, collection)) {
|
9963 | result = retKey ? key : value;
|
9964 | return false;
|
9965 | }
|
9966 | });
|
9967 | return result;
|
9968 | }
|
9969 |
|
9970 | |
9971 |
|
9972 |
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 |
|
9978 |
|
9979 |
|
9980 |
|
9981 | function baseFlatten(array, isDeep, isStrict, result) {
|
9982 | result || (result = []);
|
9983 |
|
9984 | var index = -1,
|
9985 | length = array.length;
|
9986 |
|
9987 | while (++index < length) {
|
9988 | var value = array[index];
|
9989 | if (isObjectLike(value) && isArrayLike(value) &&
|
9990 | (isStrict || isArray(value) || isArguments(value))) {
|
9991 | if (isDeep) {
|
9992 |
|
9993 | baseFlatten(value, isDeep, isStrict, result);
|
9994 | } else {
|
9995 | arrayPush(result, value);
|
9996 | }
|
9997 | } else if (!isStrict) {
|
9998 | result[result.length] = value;
|
9999 | }
|
10000 | }
|
10001 | return result;
|
10002 | }
|
10003 |
|
10004 | |
10005 |
|
10006 |
|
10007 |
|
10008 |
|
10009 |
|
10010 |
|
10011 |
|
10012 |
|
10013 |
|
10014 |
|
10015 |
|
10016 | var baseFor = createBaseFor();
|
10017 |
|
10018 | |
10019 |
|
10020 |
|
10021 |
|
10022 |
|
10023 |
|
10024 |
|
10025 |
|
10026 |
|
10027 |
|
10028 | var baseForRight = createBaseFor(true);
|
10029 |
|
10030 | |
10031 |
|
10032 |
|
10033 |
|
10034 |
|
10035 |
|
10036 |
|
10037 |
|
10038 |
|
10039 | function baseForIn(object, iteratee) {
|
10040 | return baseFor(object, iteratee, keysIn);
|
10041 | }
|
10042 |
|
10043 | |
10044 |
|
10045 |
|
10046 |
|
10047 |
|
10048 |
|
10049 |
|
10050 |
|
10051 |
|
10052 | function baseForOwn(object, iteratee) {
|
10053 | return baseFor(object, iteratee, keys);
|
10054 | }
|
10055 |
|
10056 | |
10057 |
|
10058 |
|
10059 |
|
10060 |
|
10061 |
|
10062 |
|
10063 |
|
10064 |
|
10065 | function baseForOwnRight(object, iteratee) {
|
10066 | return baseForRight(object, iteratee, keys);
|
10067 | }
|
10068 |
|
10069 | |
10070 |
|
10071 |
|
10072 |
|
10073 |
|
10074 |
|
10075 |
|
10076 |
|
10077 |
|
10078 | function baseFunctions(object, props) {
|
10079 | var index = -1,
|
10080 | length = props.length,
|
10081 | resIndex = -1,
|
10082 | result = [];
|
10083 |
|
10084 | while (++index < length) {
|
10085 | var key = props[index];
|
10086 | if (isFunction(object[key])) {
|
10087 | result[++resIndex] = key;
|
10088 | }
|
10089 | }
|
10090 | return result;
|
10091 | }
|
10092 |
|
10093 | |
10094 |
|
10095 |
|
10096 |
|
10097 |
|
10098 |
|
10099 |
|
10100 |
|
10101 |
|
10102 |
|
10103 | function baseGet(object, path, pathKey) {
|
10104 | if (object == null) {
|
10105 | return;
|
10106 | }
|
10107 | if (pathKey !== undefined && pathKey in toObject(object)) {
|
10108 | path = [pathKey];
|
10109 | }
|
10110 | var index = 0,
|
10111 | length = path.length;
|
10112 |
|
10113 | while (object != null && index < length) {
|
10114 | object = object[path[index++]];
|
10115 | }
|
10116 | return (index && index == length) ? object : undefined;
|
10117 | }
|
10118 |
|
10119 | |
10120 |
|
10121 |
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 |
|
10127 |
|
10128 |
|
10129 |
|
10130 |
|
10131 |
|
10132 | function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
|
10133 | if (value === other) {
|
10134 | return true;
|
10135 | }
|
10136 | if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
|
10137 | return value !== value && other !== other;
|
10138 | }
|
10139 | return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
|
10140 | }
|
10141 |
|
10142 | |
10143 |
|
10144 |
|
10145 |
|
10146 |
|
10147 |
|
10148 |
|
10149 |
|
10150 |
|
10151 |
|
10152 |
|
10153 |
|
10154 |
|
10155 |
|
10156 |
|
10157 | function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
|
10158 | var objIsArr = isArray(object),
|
10159 | othIsArr = isArray(other),
|
10160 | objTag = arrayTag,
|
10161 | othTag = arrayTag;
|
10162 |
|
10163 | if (!objIsArr) {
|
10164 | objTag = objToString.call(object);
|
10165 | if (objTag == argsTag) {
|
10166 | objTag = objectTag;
|
10167 | } else if (objTag != objectTag) {
|
10168 | objIsArr = isTypedArray(object);
|
10169 | }
|
10170 | }
|
10171 | if (!othIsArr) {
|
10172 | othTag = objToString.call(other);
|
10173 | if (othTag == argsTag) {
|
10174 | othTag = objectTag;
|
10175 | } else if (othTag != objectTag) {
|
10176 | othIsArr = isTypedArray(other);
|
10177 | }
|
10178 | }
|
10179 | var objIsObj = objTag == objectTag,
|
10180 | othIsObj = othTag == objectTag,
|
10181 | isSameTag = objTag == othTag;
|
10182 |
|
10183 | if (isSameTag && !(objIsArr || objIsObj)) {
|
10184 | return equalByTag(object, other, objTag);
|
10185 | }
|
10186 | if (!isLoose) {
|
10187 | var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
10188 | othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
10189 |
|
10190 | if (objIsWrapped || othIsWrapped) {
|
10191 | return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
|
10192 | }
|
10193 | }
|
10194 | if (!isSameTag) {
|
10195 | return false;
|
10196 | }
|
10197 |
|
10198 |
|
10199 | stackA || (stackA = []);
|
10200 | stackB || (stackB = []);
|
10201 |
|
10202 | var length = stackA.length;
|
10203 | while (length--) {
|
10204 | if (stackA[length] == object) {
|
10205 | return stackB[length] == other;
|
10206 | }
|
10207 | }
|
10208 |
|
10209 | stackA.push(object);
|
10210 | stackB.push(other);
|
10211 |
|
10212 | var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
|
10213 |
|
10214 | stackA.pop();
|
10215 | stackB.pop();
|
10216 |
|
10217 | return result;
|
10218 | }
|
10219 |
|
10220 | |
10221 |
|
10222 |
|
10223 |
|
10224 |
|
10225 |
|
10226 |
|
10227 |
|
10228 |
|
10229 |
|
10230 | function baseIsMatch(object, matchData, customizer) {
|
10231 | var index = matchData.length,
|
10232 | length = index,
|
10233 | noCustomizer = !customizer;
|
10234 |
|
10235 | if (object == null) {
|
10236 | return !length;
|
10237 | }
|
10238 | object = toObject(object);
|
10239 | while (index--) {
|
10240 | var data = matchData[index];
|
10241 | if ((noCustomizer && data[2])
|
10242 | ? data[1] !== object[data[0]]
|
10243 | : !(data[0] in object)
|
10244 | ) {
|
10245 | return false;
|
10246 | }
|
10247 | }
|
10248 | while (++index < length) {
|
10249 | data = matchData[index];
|
10250 | var key = data[0],
|
10251 | objValue = object[key],
|
10252 | srcValue = data[1];
|
10253 |
|
10254 | if (noCustomizer && data[2]) {
|
10255 | if (objValue === undefined && !(key in object)) {
|
10256 | return false;
|
10257 | }
|
10258 | } else {
|
10259 | var result = customizer ? customizer(objValue, srcValue, key) : undefined;
|
10260 | if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
|
10261 | return false;
|
10262 | }
|
10263 | }
|
10264 | }
|
10265 | return true;
|
10266 | }
|
10267 |
|
10268 | |
10269 |
|
10270 |
|
10271 |
|
10272 |
|
10273 |
|
10274 |
|
10275 |
|
10276 |
|
10277 | function baseMap(collection, iteratee) {
|
10278 | var index = -1,
|
10279 | result = isArrayLike(collection) ? Array(collection.length) : [];
|
10280 |
|
10281 | baseEach(collection, function(value, key, collection) {
|
10282 | result[++index] = iteratee(value, key, collection);
|
10283 | });
|
10284 | return result;
|
10285 | }
|
10286 |
|
10287 | |
10288 |
|
10289 |
|
10290 |
|
10291 |
|
10292 |
|
10293 |
|
10294 | function baseMatches(source) {
|
10295 | var matchData = getMatchData(source);
|
10296 | if (matchData.length == 1 && matchData[0][2]) {
|
10297 | var key = matchData[0][0],
|
10298 | value = matchData[0][1];
|
10299 |
|
10300 | return function(object) {
|
10301 | if (object == null) {
|
10302 | return false;
|
10303 | }
|
10304 | return object[key] === value && (value !== undefined || (key in toObject(object)));
|
10305 | };
|
10306 | }
|
10307 | return function(object) {
|
10308 | return baseIsMatch(object, matchData);
|
10309 | };
|
10310 | }
|
10311 |
|
10312 | |
10313 |
|
10314 |
|
10315 |
|
10316 |
|
10317 |
|
10318 |
|
10319 |
|
10320 | function baseMatchesProperty(path, srcValue) {
|
10321 | var isArr = isArray(path),
|
10322 | isCommon = isKey(path) && isStrictComparable(srcValue),
|
10323 | pathKey = (path + '');
|
10324 |
|
10325 | path = toPath(path);
|
10326 | return function(object) {
|
10327 | if (object == null) {
|
10328 | return false;
|
10329 | }
|
10330 | var key = pathKey;
|
10331 | object = toObject(object);
|
10332 | if ((isArr || !isCommon) && !(key in object)) {
|
10333 | object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
10334 | if (object == null) {
|
10335 | return false;
|
10336 | }
|
10337 | key = last(path);
|
10338 | object = toObject(object);
|
10339 | }
|
10340 | return object[key] === srcValue
|
10341 | ? (srcValue !== undefined || (key in object))
|
10342 | : baseIsEqual(srcValue, object[key], undefined, true);
|
10343 | };
|
10344 | }
|
10345 |
|
10346 | |
10347 |
|
10348 |
|
10349 |
|
10350 |
|
10351 |
|
10352 |
|
10353 |
|
10354 |
|
10355 |
|
10356 |
|
10357 |
|
10358 | function baseMerge(object, source, customizer, stackA, stackB) {
|
10359 | if (!isObject(object)) {
|
10360 | return object;
|
10361 | }
|
10362 | var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
|
10363 | props = isSrcArr ? undefined : keys(source);
|
10364 |
|
10365 | arrayEach(props || source, function(srcValue, key) {
|
10366 | if (props) {
|
10367 | key = srcValue;
|
10368 | srcValue = source[key];
|
10369 | }
|
10370 | if (isObjectLike(srcValue)) {
|
10371 | stackA || (stackA = []);
|
10372 | stackB || (stackB = []);
|
10373 | baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
|
10374 | }
|
10375 | else {
|
10376 | var value = object[key],
|
10377 | result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
10378 | isCommon = result === undefined;
|
10379 |
|
10380 | if (isCommon) {
|
10381 | result = srcValue;
|
10382 | }
|
10383 | if ((result !== undefined || (isSrcArr && !(key in object))) &&
|
10384 | (isCommon || (result === result ? (result !== value) : (value === value)))) {
|
10385 | object[key] = result;
|
10386 | }
|
10387 | }
|
10388 | });
|
10389 | return object;
|
10390 | }
|
10391 |
|
10392 | |
10393 |
|
10394 |
|
10395 |
|
10396 |
|
10397 |
|
10398 |
|
10399 |
|
10400 |
|
10401 |
|
10402 |
|
10403 |
|
10404 |
|
10405 |
|
10406 |
|
10407 | function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
|
10408 | var length = stackA.length,
|
10409 | srcValue = source[key];
|
10410 |
|
10411 | while (length--) {
|
10412 | if (stackA[length] == srcValue) {
|
10413 | object[key] = stackB[length];
|
10414 | return;
|
10415 | }
|
10416 | }
|
10417 | var value = object[key],
|
10418 | result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
10419 | isCommon = result === undefined;
|
10420 |
|
10421 | if (isCommon) {
|
10422 | result = srcValue;
|
10423 | if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
10424 | result = isArray(value)
|
10425 | ? value
|
10426 | : (isArrayLike(value) ? arrayCopy(value) : []);
|
10427 | }
|
10428 | else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
10429 | result = isArguments(value)
|
10430 | ? toPlainObject(value)
|
10431 | : (isPlainObject(value) ? value : {});
|
10432 | }
|
10433 | else {
|
10434 | isCommon = false;
|
10435 | }
|
10436 | }
|
10437 |
|
10438 |
|
10439 | stackA.push(srcValue);
|
10440 | stackB.push(result);
|
10441 |
|
10442 | if (isCommon) {
|
10443 |
|
10444 | object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
|
10445 | } else if (result === result ? (result !== value) : (value === value)) {
|
10446 | object[key] = result;
|
10447 | }
|
10448 | }
|
10449 |
|
10450 | |
10451 |
|
10452 |
|
10453 |
|
10454 |
|
10455 |
|
10456 |
|
10457 | function baseProperty(key) {
|
10458 | return function(object) {
|
10459 | return object == null ? undefined : object[key];
|
10460 | };
|
10461 | }
|
10462 |
|
10463 | |
10464 |
|
10465 |
|
10466 |
|
10467 |
|
10468 |
|
10469 |
|
10470 | function basePropertyDeep(path) {
|
10471 | var pathKey = (path + '');
|
10472 | path = toPath(path);
|
10473 | return function(object) {
|
10474 | return baseGet(object, path, pathKey);
|
10475 | };
|
10476 | }
|
10477 |
|
10478 | |
10479 |
|
10480 |
|
10481 |
|
10482 |
|
10483 |
|
10484 |
|
10485 |
|
10486 |
|
10487 | function basePullAt(array, indexes) {
|
10488 | var length = array ? indexes.length : 0;
|
10489 | while (length--) {
|
10490 | var index = indexes[length];
|
10491 | if (index != previous && isIndex(index)) {
|
10492 | var previous = index;
|
10493 | splice.call(array, index, 1);
|
10494 | }
|
10495 | }
|
10496 | return array;
|
10497 | }
|
10498 |
|
10499 | |
10500 |
|
10501 |
|
10502 |
|
10503 |
|
10504 |
|
10505 |
|
10506 |
|
10507 |
|
10508 | function baseRandom(min, max) {
|
10509 | return min + nativeFloor(nativeRandom() * (max - min + 1));
|
10510 | }
|
10511 |
|
10512 | |
10513 |
|
10514 |
|
10515 |
|
10516 |
|
10517 |
|
10518 |
|
10519 |
|
10520 |
|
10521 |
|
10522 |
|
10523 |
|
10524 |
|
10525 |
|
10526 | function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
|
10527 | eachFunc(collection, function(value, index, collection) {
|
10528 | accumulator = initFromCollection
|
10529 | ? (initFromCollection = false, value)
|
10530 | : iteratee(accumulator, value, index, collection);
|
10531 | });
|
10532 | return accumulator;
|
10533 | }
|
10534 |
|
10535 | |
10536 |
|
10537 |
|
10538 |
|
10539 |
|
10540 |
|
10541 |
|
10542 |
|
10543 | var baseSetData = !metaMap ? identity : function(func, data) {
|
10544 | metaMap.set(func, data);
|
10545 | return func;
|
10546 | };
|
10547 |
|
10548 | |
10549 |
|
10550 |
|
10551 |
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 | function baseSlice(array, start, end) {
|
10558 | var index = -1,
|
10559 | length = array.length;
|
10560 |
|
10561 | start = start == null ? 0 : (+start || 0);
|
10562 | if (start < 0) {
|
10563 | start = -start > length ? 0 : (length + start);
|
10564 | }
|
10565 | end = (end === undefined || end > length) ? length : (+end || 0);
|
10566 | if (end < 0) {
|
10567 | end += length;
|
10568 | }
|
10569 | length = start > end ? 0 : ((end - start) >>> 0);
|
10570 | start >>>= 0;
|
10571 |
|
10572 | var result = Array(length);
|
10573 | while (++index < length) {
|
10574 | result[index] = array[index + start];
|
10575 | }
|
10576 | return result;
|
10577 | }
|
10578 |
|
10579 | |
10580 |
|
10581 |
|
10582 |
|
10583 |
|
10584 |
|
10585 |
|
10586 |
|
10587 |
|
10588 |
|
10589 | function baseSome(collection, predicate) {
|
10590 | var result;
|
10591 |
|
10592 | baseEach(collection, function(value, index, collection) {
|
10593 | result = predicate(value, index, collection);
|
10594 | return !result;
|
10595 | });
|
10596 | return !!result;
|
10597 | }
|
10598 |
|
10599 | |
10600 |
|
10601 |
|
10602 |
|
10603 |
|
10604 |
|
10605 |
|
10606 |
|
10607 |
|
10608 |
|
10609 | function baseSortBy(array, comparer) {
|
10610 | var length = array.length;
|
10611 |
|
10612 | array.sort(comparer);
|
10613 | while (length--) {
|
10614 | array[length] = array[length].value;
|
10615 | }
|
10616 | return array;
|
10617 | }
|
10618 |
|
10619 | |
10620 |
|
10621 |
|
10622 |
|
10623 |
|
10624 |
|
10625 |
|
10626 |
|
10627 |
|
10628 | function baseSortByOrder(collection, iteratees, orders) {
|
10629 | var callback = getCallback(),
|
10630 | index = -1;
|
10631 |
|
10632 | iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); });
|
10633 |
|
10634 | var result = baseMap(collection, function(value) {
|
10635 | var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); });
|
10636 | return { 'criteria': criteria, 'index': ++index, 'value': value };
|
10637 | });
|
10638 |
|
10639 | return baseSortBy(result, function(object, other) {
|
10640 | return compareMultiple(object, other, orders);
|
10641 | });
|
10642 | }
|
10643 |
|
10644 | |
10645 |
|
10646 |
|
10647 |
|
10648 |
|
10649 |
|
10650 |
|
10651 |
|
10652 |
|
10653 | function baseSum(collection, iteratee) {
|
10654 | var result = 0;
|
10655 | baseEach(collection, function(value, index, collection) {
|
10656 | result += +iteratee(value, index, collection) || 0;
|
10657 | });
|
10658 | return result;
|
10659 | }
|
10660 |
|
10661 | |
10662 |
|
10663 |
|
10664 |
|
10665 |
|
10666 |
|
10667 |
|
10668 |
|
10669 |
|
10670 | function baseUniq(array, iteratee) {
|
10671 | var index = -1,
|
10672 | indexOf = getIndexOf(),
|
10673 | length = array.length,
|
10674 | isCommon = indexOf == baseIndexOf,
|
10675 | isLarge = isCommon && length >= LARGE_ARRAY_SIZE,
|
10676 | seen = isLarge ? createCache() : null,
|
10677 | result = [];
|
10678 |
|
10679 | if (seen) {
|
10680 | indexOf = cacheIndexOf;
|
10681 | isCommon = false;
|
10682 | } else {
|
10683 | isLarge = false;
|
10684 | seen = iteratee ? [] : result;
|
10685 | }
|
10686 | outer:
|
10687 | while (++index < length) {
|
10688 | var value = array[index],
|
10689 | computed = iteratee ? iteratee(value, index, array) : value;
|
10690 |
|
10691 | if (isCommon && value === value) {
|
10692 | var seenIndex = seen.length;
|
10693 | while (seenIndex--) {
|
10694 | if (seen[seenIndex] === computed) {
|
10695 | continue outer;
|
10696 | }
|
10697 | }
|
10698 | if (iteratee) {
|
10699 | seen.push(computed);
|
10700 | }
|
10701 | result.push(value);
|
10702 | }
|
10703 | else if (indexOf(seen, computed, 0) < 0) {
|
10704 | if (iteratee || isLarge) {
|
10705 | seen.push(computed);
|
10706 | }
|
10707 | result.push(value);
|
10708 | }
|
10709 | }
|
10710 | return result;
|
10711 | }
|
10712 |
|
10713 | |
10714 |
|
10715 |
|
10716 |
|
10717 |
|
10718 |
|
10719 |
|
10720 |
|
10721 |
|
10722 |
|
10723 | function baseValues(object, props) {
|
10724 | var index = -1,
|
10725 | length = props.length,
|
10726 | result = Array(length);
|
10727 |
|
10728 | while (++index < length) {
|
10729 | result[index] = object[props[index]];
|
10730 | }
|
10731 | return result;
|
10732 | }
|
10733 |
|
10734 | |
10735 |
|
10736 |
|
10737 |
|
10738 |
|
10739 |
|
10740 |
|
10741 |
|
10742 |
|
10743 |
|
10744 |
|
10745 | function baseWhile(array, predicate, isDrop, fromRight) {
|
10746 | var length = array.length,
|
10747 | index = fromRight ? length : -1;
|
10748 |
|
10749 | while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {}
|
10750 | return isDrop
|
10751 | ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
|
10752 | : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
|
10753 | }
|
10754 |
|
10755 | |
10756 |
|
10757 |
|
10758 |
|
10759 |
|
10760 |
|
10761 |
|
10762 |
|
10763 |
|
10764 |
|
10765 | function baseWrapperValue(value, actions) {
|
10766 | var result = value;
|
10767 | if (result instanceof LazyWrapper) {
|
10768 | result = result.value();
|
10769 | }
|
10770 | var index = -1,
|
10771 | length = actions.length;
|
10772 |
|
10773 | while (++index < length) {
|
10774 | var action = actions[index];
|
10775 | result = action.func.apply(action.thisArg, arrayPush([result], action.args));
|
10776 | }
|
10777 | return result;
|
10778 | }
|
10779 |
|
10780 | |
10781 |
|
10782 |
|
10783 |
|
10784 |
|
10785 |
|
10786 |
|
10787 |
|
10788 |
|
10789 |
|
10790 |
|
10791 | function binaryIndex(array, value, retHighest) {
|
10792 | var low = 0,
|
10793 | high = array ? array.length : low;
|
10794 |
|
10795 | if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
|
10796 | while (low < high) {
|
10797 | var mid = (low + high) >>> 1,
|
10798 | computed = array[mid];
|
10799 |
|
10800 | if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {
|
10801 | low = mid + 1;
|
10802 | } else {
|
10803 | high = mid;
|
10804 | }
|
10805 | }
|
10806 | return high;
|
10807 | }
|
10808 | return binaryIndexBy(array, value, identity, retHighest);
|
10809 | }
|
10810 |
|
10811 | |
10812 |
|
10813 |
|
10814 |
|
10815 |
|
10816 |
|
10817 |
|
10818 |
|
10819 |
|
10820 |
|
10821 |
|
10822 |
|
10823 |
|
10824 | function binaryIndexBy(array, value, iteratee, retHighest) {
|
10825 | value = iteratee(value);
|
10826 |
|
10827 | var low = 0,
|
10828 | high = array ? array.length : 0,
|
10829 | valIsNaN = value !== value,
|
10830 | valIsNull = value === null,
|
10831 | valIsUndef = value === undefined;
|
10832 |
|
10833 | while (low < high) {
|
10834 | var mid = nativeFloor((low + high) / 2),
|
10835 | computed = iteratee(array[mid]),
|
10836 | isDef = computed !== undefined,
|
10837 | isReflexive = computed === computed;
|
10838 |
|
10839 | if (valIsNaN) {
|
10840 | var setLow = isReflexive || retHighest;
|
10841 | } else if (valIsNull) {
|
10842 | setLow = isReflexive && isDef && (retHighest || computed != null);
|
10843 | } else if (valIsUndef) {
|
10844 | setLow = isReflexive && (retHighest || isDef);
|
10845 | } else if (computed == null) {
|
10846 | setLow = false;
|
10847 | } else {
|
10848 | setLow = retHighest ? (computed <= value) : (computed < value);
|
10849 | }
|
10850 | if (setLow) {
|
10851 | low = mid + 1;
|
10852 | } else {
|
10853 | high = mid;
|
10854 | }
|
10855 | }
|
10856 | return nativeMin(high, MAX_ARRAY_INDEX);
|
10857 | }
|
10858 |
|
10859 | |
10860 |
|
10861 |
|
10862 |
|
10863 |
|
10864 |
|
10865 |
|
10866 |
|
10867 |
|
10868 |
|
10869 | function bindCallback(func, thisArg, argCount) {
|
10870 | if (typeof func != 'function') {
|
10871 | return identity;
|
10872 | }
|
10873 | if (thisArg === undefined) {
|
10874 | return func;
|
10875 | }
|
10876 | switch (argCount) {
|
10877 | case 1: return function(value) {
|
10878 | return func.call(thisArg, value);
|
10879 | };
|
10880 | case 3: return function(value, index, collection) {
|
10881 | return func.call(thisArg, value, index, collection);
|
10882 | };
|
10883 | case 4: return function(accumulator, value, index, collection) {
|
10884 | return func.call(thisArg, accumulator, value, index, collection);
|
10885 | };
|
10886 | case 5: return function(value, other, key, object, source) {
|
10887 | return func.call(thisArg, value, other, key, object, source);
|
10888 | };
|
10889 | }
|
10890 | return function() {
|
10891 | return func.apply(thisArg, arguments);
|
10892 | };
|
10893 | }
|
10894 |
|
10895 | |
10896 |
|
10897 |
|
10898 |
|
10899 |
|
10900 |
|
10901 |
|
10902 | function bufferClone(buffer) {
|
10903 | var result = new ArrayBuffer(buffer.byteLength),
|
10904 | view = new Uint8Array(result);
|
10905 |
|
10906 | view.set(new Uint8Array(buffer));
|
10907 | return result;
|
10908 | }
|
10909 |
|
10910 | |
10911 |
|
10912 |
|
10913 |
|
10914 |
|
10915 |
|
10916 |
|
10917 |
|
10918 |
|
10919 |
|
10920 | function composeArgs(args, partials, holders) {
|
10921 | var holdersLength = holders.length,
|
10922 | argsIndex = -1,
|
10923 | argsLength = nativeMax(args.length - holdersLength, 0),
|
10924 | leftIndex = -1,
|
10925 | leftLength = partials.length,
|
10926 | result = Array(leftLength + argsLength);
|
10927 |
|
10928 | while (++leftIndex < leftLength) {
|
10929 | result[leftIndex] = partials[leftIndex];
|
10930 | }
|
10931 | while (++argsIndex < holdersLength) {
|
10932 | result[holders[argsIndex]] = args[argsIndex];
|
10933 | }
|
10934 | while (argsLength--) {
|
10935 | result[leftIndex++] = args[argsIndex++];
|
10936 | }
|
10937 | return result;
|
10938 | }
|
10939 |
|
10940 | |
10941 |
|
10942 |
|
10943 |
|
10944 |
|
10945 |
|
10946 |
|
10947 |
|
10948 |
|
10949 |
|
10950 | function composeArgsRight(args, partials, holders) {
|
10951 | var holdersIndex = -1,
|
10952 | holdersLength = holders.length,
|
10953 | argsIndex = -1,
|
10954 | argsLength = nativeMax(args.length - holdersLength, 0),
|
10955 | rightIndex = -1,
|
10956 | rightLength = partials.length,
|
10957 | result = Array(argsLength + rightLength);
|
10958 |
|
10959 | while (++argsIndex < argsLength) {
|
10960 | result[argsIndex] = args[argsIndex];
|
10961 | }
|
10962 | var offset = argsIndex;
|
10963 | while (++rightIndex < rightLength) {
|
10964 | result[offset + rightIndex] = partials[rightIndex];
|
10965 | }
|
10966 | while (++holdersIndex < holdersLength) {
|
10967 | result[offset + holders[holdersIndex]] = args[argsIndex++];
|
10968 | }
|
10969 | return result;
|
10970 | }
|
10971 |
|
10972 | |
10973 |
|
10974 |
|
10975 |
|
10976 |
|
10977 |
|
10978 |
|
10979 |
|
10980 | function createAggregator(setter, initializer) {
|
10981 | return function(collection, iteratee, thisArg) {
|
10982 | var result = initializer ? initializer() : {};
|
10983 | iteratee = getCallback(iteratee, thisArg, 3);
|
10984 |
|
10985 | if (isArray(collection)) {
|
10986 | var index = -1,
|
10987 | length = collection.length;
|
10988 |
|
10989 | while (++index < length) {
|
10990 | var value = collection[index];
|
10991 | setter(result, value, iteratee(value, index, collection), collection);
|
10992 | }
|
10993 | } else {
|
10994 | baseEach(collection, function(value, key, collection) {
|
10995 | setter(result, value, iteratee(value, key, collection), collection);
|
10996 | });
|
10997 | }
|
10998 | return result;
|
10999 | };
|
11000 | }
|
11001 |
|
11002 | |
11003 |
|
11004 |
|
11005 |
|
11006 |
|
11007 |
|
11008 |
|
11009 | function createAssigner(assigner) {
|
11010 | return restParam(function(object, sources) {
|
11011 | var index = -1,
|
11012 | length = object == null ? 0 : sources.length,
|
11013 | customizer = length > 2 ? sources[length - 2] : undefined,
|
11014 | guard = length > 2 ? sources[2] : undefined,
|
11015 | thisArg = length > 1 ? sources[length - 1] : undefined;
|
11016 |
|
11017 | if (typeof customizer == 'function') {
|
11018 | customizer = bindCallback(customizer, thisArg, 5);
|
11019 | length -= 2;
|
11020 | } else {
|
11021 | customizer = typeof thisArg == 'function' ? thisArg : undefined;
|
11022 | length -= (customizer ? 1 : 0);
|
11023 | }
|
11024 | if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
11025 | customizer = length < 3 ? undefined : customizer;
|
11026 | length = 1;
|
11027 | }
|
11028 | while (++index < length) {
|
11029 | var source = sources[index];
|
11030 | if (source) {
|
11031 | assigner(object, source, customizer);
|
11032 | }
|
11033 | }
|
11034 | return object;
|
11035 | });
|
11036 | }
|
11037 |
|
11038 | |
11039 |
|
11040 |
|
11041 |
|
11042 |
|
11043 |
|
11044 |
|
11045 |
|
11046 | function createBaseEach(eachFunc, fromRight) {
|
11047 | return function(collection, iteratee) {
|
11048 | var length = collection ? getLength(collection) : 0;
|
11049 | if (!isLength(length)) {
|
11050 | return eachFunc(collection, iteratee);
|
11051 | }
|
11052 | var index = fromRight ? length : -1,
|
11053 | iterable = toObject(collection);
|
11054 |
|
11055 | while ((fromRight ? index-- : ++index < length)) {
|
11056 | if (iteratee(iterable[index], index, iterable) === false) {
|
11057 | break;
|
11058 | }
|
11059 | }
|
11060 | return collection;
|
11061 | };
|
11062 | }
|
11063 |
|
11064 | |
11065 |
|
11066 |
|
11067 |
|
11068 |
|
11069 |
|
11070 |
|
11071 | function createBaseFor(fromRight) {
|
11072 | return function(object, iteratee, keysFunc) {
|
11073 | var iterable = toObject(object),
|
11074 | props = keysFunc(object),
|
11075 | length = props.length,
|
11076 | index = fromRight ? length : -1;
|
11077 |
|
11078 | while ((fromRight ? index-- : ++index < length)) {
|
11079 | var key = props[index];
|
11080 | if (iteratee(iterable[key], key, iterable) === false) {
|
11081 | break;
|
11082 | }
|
11083 | }
|
11084 | return object;
|
11085 | };
|
11086 | }
|
11087 |
|
11088 | |
11089 |
|
11090 |
|
11091 |
|
11092 |
|
11093 |
|
11094 |
|
11095 |
|
11096 |
|
11097 | function createBindWrapper(func, thisArg) {
|
11098 | var Ctor = createCtorWrapper(func);
|
11099 |
|
11100 | function wrapper() {
|
11101 | var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
|
11102 | return fn.apply(thisArg, arguments);
|
11103 | }
|
11104 | return wrapper;
|
11105 | }
|
11106 |
|
11107 | |
11108 |
|
11109 |
|
11110 |
|
11111 |
|
11112 |
|
11113 |
|
11114 | function createCache(values) {
|
11115 | return (nativeCreate && Set) ? new SetCache(values) : null;
|
11116 | }
|
11117 |
|
11118 | |
11119 |
|
11120 |
|
11121 |
|
11122 |
|
11123 |
|
11124 |
|
11125 |
|
11126 | function createCompounder(callback) {
|
11127 | return function(string) {
|
11128 | var index = -1,
|
11129 | array = words(deburr(string)),
|
11130 | length = array.length,
|
11131 | result = '';
|
11132 |
|
11133 | while (++index < length) {
|
11134 | result = callback(result, array[index], index);
|
11135 | }
|
11136 | return result;
|
11137 | };
|
11138 | }
|
11139 |
|
11140 | |
11141 |
|
11142 |
|
11143 |
|
11144 |
|
11145 |
|
11146 |
|
11147 |
|
11148 | function createCtorWrapper(Ctor) {
|
11149 | return function() {
|
11150 |
|
11151 |
|
11152 |
|
11153 | var args = arguments;
|
11154 | switch (args.length) {
|
11155 | case 0: return new Ctor;
|
11156 | case 1: return new Ctor(args[0]);
|
11157 | case 2: return new Ctor(args[0], args[1]);
|
11158 | case 3: return new Ctor(args[0], args[1], args[2]);
|
11159 | case 4: return new Ctor(args[0], args[1], args[2], args[3]);
|
11160 | case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
|
11161 | case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
|
11162 | case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
11163 | }
|
11164 | var thisBinding = baseCreate(Ctor.prototype),
|
11165 | result = Ctor.apply(thisBinding, args);
|
11166 |
|
11167 |
|
11168 |
|
11169 | return isObject(result) ? result : thisBinding;
|
11170 | };
|
11171 | }
|
11172 |
|
11173 | |
11174 |
|
11175 |
|
11176 |
|
11177 |
|
11178 |
|
11179 |
|
11180 | function createCurry(flag) {
|
11181 | function curryFunc(func, arity, guard) {
|
11182 | if (guard && isIterateeCall(func, arity, guard)) {
|
11183 | arity = undefined;
|
11184 | }
|
11185 | var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity);
|
11186 | result.placeholder = curryFunc.placeholder;
|
11187 | return result;
|
11188 | }
|
11189 | return curryFunc;
|
11190 | }
|
11191 |
|
11192 | |
11193 |
|
11194 |
|
11195 |
|
11196 |
|
11197 |
|
11198 |
|
11199 |
|
11200 | function createDefaults(assigner, customizer) {
|
11201 | return restParam(function(args) {
|
11202 | var object = args[0];
|
11203 | if (object == null) {
|
11204 | return object;
|
11205 | }
|
11206 | args.push(customizer);
|
11207 | return assigner.apply(undefined, args);
|
11208 | });
|
11209 | }
|
11210 |
|
11211 | |
11212 |
|
11213 |
|
11214 |
|
11215 |
|
11216 |
|
11217 |
|
11218 |
|
11219 | function createExtremum(comparator, exValue) {
|
11220 | return function(collection, iteratee, thisArg) {
|
11221 | if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
11222 | iteratee = undefined;
|
11223 | }
|
11224 | iteratee = getCallback(iteratee, thisArg, 3);
|
11225 | if (iteratee.length == 1) {
|
11226 | collection = isArray(collection) ? collection : toIterable(collection);
|
11227 | var result = arrayExtremum(collection, iteratee, comparator, exValue);
|
11228 | if (!(collection.length && result === exValue)) {
|
11229 | return result;
|
11230 | }
|
11231 | }
|
11232 | return baseExtremum(collection, iteratee, comparator, exValue);
|
11233 | };
|
11234 | }
|
11235 |
|
11236 | |
11237 |
|
11238 |
|
11239 |
|
11240 |
|
11241 |
|
11242 |
|
11243 |
|
11244 | function createFind(eachFunc, fromRight) {
|
11245 | return function(collection, predicate, thisArg) {
|
11246 | predicate = getCallback(predicate, thisArg, 3);
|
11247 | if (isArray(collection)) {
|
11248 | var index = baseFindIndex(collection, predicate, fromRight);
|
11249 | return index > -1 ? collection[index] : undefined;
|
11250 | }
|
11251 | return baseFind(collection, predicate, eachFunc);
|
11252 | };
|
11253 | }
|
11254 |
|
11255 | |
11256 |
|
11257 |
|
11258 |
|
11259 |
|
11260 |
|
11261 |
|
11262 | function createFindIndex(fromRight) {
|
11263 | return function(array, predicate, thisArg) {
|
11264 | if (!(array && array.length)) {
|
11265 | return -1;
|
11266 | }
|
11267 | predicate = getCallback(predicate, thisArg, 3);
|
11268 | return baseFindIndex(array, predicate, fromRight);
|
11269 | };
|
11270 | }
|
11271 |
|
11272 | |
11273 |
|
11274 |
|
11275 |
|
11276 |
|
11277 |
|
11278 |
|
11279 | function createFindKey(objectFunc) {
|
11280 | return function(object, predicate, thisArg) {
|
11281 | predicate = getCallback(predicate, thisArg, 3);
|
11282 | return baseFind(object, predicate, objectFunc, true);
|
11283 | };
|
11284 | }
|
11285 |
|
11286 | |
11287 |
|
11288 |
|
11289 |
|
11290 |
|
11291 |
|
11292 |
|
11293 | function createFlow(fromRight) {
|
11294 | return function() {
|
11295 | var wrapper,
|
11296 | length = arguments.length,
|
11297 | index = fromRight ? length : -1,
|
11298 | leftIndex = 0,
|
11299 | funcs = Array(length);
|
11300 |
|
11301 | while ((fromRight ? index-- : ++index < length)) {
|
11302 | var func = funcs[leftIndex++] = arguments[index];
|
11303 | if (typeof func != 'function') {
|
11304 | throw new TypeError(FUNC_ERROR_TEXT);
|
11305 | }
|
11306 | if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {
|
11307 | wrapper = new LodashWrapper([], true);
|
11308 | }
|
11309 | }
|
11310 | index = wrapper ? -1 : length;
|
11311 | while (++index < length) {
|
11312 | func = funcs[index];
|
11313 |
|
11314 | var funcName = getFuncName(func),
|
11315 | data = funcName == 'wrapper' ? getData(func) : undefined;
|
11316 |
|
11317 | if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
|
11318 | wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
11319 | } else {
|
11320 | wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
11321 | }
|
11322 | }
|
11323 | return function() {
|
11324 | var args = arguments,
|
11325 | value = args[0];
|
11326 |
|
11327 | if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
11328 | return wrapper.plant(value).value();
|
11329 | }
|
11330 | var index = 0,
|
11331 | result = length ? funcs[index].apply(this, args) : value;
|
11332 |
|
11333 | while (++index < length) {
|
11334 | result = funcs[index].call(this, result);
|
11335 | }
|
11336 | return result;
|
11337 | };
|
11338 | };
|
11339 | }
|
11340 |
|
11341 | |
11342 |
|
11343 |
|
11344 |
|
11345 |
|
11346 |
|
11347 |
|
11348 |
|
11349 | function createForEach(arrayFunc, eachFunc) {
|
11350 | return function(collection, iteratee, thisArg) {
|
11351 | return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
|
11352 | ? arrayFunc(collection, iteratee)
|
11353 | : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
|
11354 | };
|
11355 | }
|
11356 |
|
11357 | |
11358 |
|
11359 |
|
11360 |
|
11361 |
|
11362 |
|
11363 |
|
11364 | function createForIn(objectFunc) {
|
11365 | return function(object, iteratee, thisArg) {
|
11366 | if (typeof iteratee != 'function' || thisArg !== undefined) {
|
11367 | iteratee = bindCallback(iteratee, thisArg, 3);
|
11368 | }
|
11369 | return objectFunc(object, iteratee, keysIn);
|
11370 | };
|
11371 | }
|
11372 |
|
11373 | |
11374 |
|
11375 |
|
11376 |
|
11377 |
|
11378 |
|
11379 |
|
11380 | function createForOwn(objectFunc) {
|
11381 | return function(object, iteratee, thisArg) {
|
11382 | if (typeof iteratee != 'function' || thisArg !== undefined) {
|
11383 | iteratee = bindCallback(iteratee, thisArg, 3);
|
11384 | }
|
11385 | return objectFunc(object, iteratee);
|
11386 | };
|
11387 | }
|
11388 |
|
11389 | |
11390 |
|
11391 |
|
11392 |
|
11393 |
|
11394 |
|
11395 |
|
11396 | function createObjectMapper(isMapKeys) {
|
11397 | return function(object, iteratee, thisArg) {
|
11398 | var result = {};
|
11399 | iteratee = getCallback(iteratee, thisArg, 3);
|
11400 |
|
11401 | baseForOwn(object, function(value, key, object) {
|
11402 | var mapped = iteratee(value, key, object);
|
11403 | key = isMapKeys ? mapped : key;
|
11404 | value = isMapKeys ? value : mapped;
|
11405 | result[key] = value;
|
11406 | });
|
11407 | return result;
|
11408 | };
|
11409 | }
|
11410 |
|
11411 | |
11412 |
|
11413 |
|
11414 |
|
11415 |
|
11416 |
|
11417 |
|
11418 | function createPadDir(fromRight) {
|
11419 | return function(string, length, chars) {
|
11420 | string = baseToString(string);
|
11421 | return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string);
|
11422 | };
|
11423 | }
|
11424 |
|
11425 | |
11426 |
|
11427 |
|
11428 |
|
11429 |
|
11430 |
|
11431 |
|
11432 | function createPartial(flag) {
|
11433 | var partialFunc = restParam(function(func, partials) {
|
11434 | var holders = replaceHolders(partials, partialFunc.placeholder);
|
11435 | return createWrapper(func, flag, undefined, partials, holders);
|
11436 | });
|
11437 | return partialFunc;
|
11438 | }
|
11439 |
|
11440 | |
11441 |
|
11442 |
|
11443 |
|
11444 |
|
11445 |
|
11446 |
|
11447 |
|
11448 | function createReduce(arrayFunc, eachFunc) {
|
11449 | return function(collection, iteratee, accumulator, thisArg) {
|
11450 | var initFromArray = arguments.length < 3;
|
11451 | return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
|
11452 | ? arrayFunc(collection, iteratee, accumulator, initFromArray)
|
11453 | : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
|
11454 | };
|
11455 | }
|
11456 |
|
11457 | |
11458 |
|
11459 |
|
11460 |
|
11461 |
|
11462 |
|
11463 |
|
11464 |
|
11465 |
|
11466 |
|
11467 |
|
11468 |
|
11469 |
|
11470 |
|
11471 |
|
11472 |
|
11473 |
|
11474 | function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
|
11475 | var isAry = bitmask & ARY_FLAG,
|
11476 | isBind = bitmask & BIND_FLAG,
|
11477 | isBindKey = bitmask & BIND_KEY_FLAG,
|
11478 | isCurry = bitmask & CURRY_FLAG,
|
11479 | isCurryBound = bitmask & CURRY_BOUND_FLAG,
|
11480 | isCurryRight = bitmask & CURRY_RIGHT_FLAG,
|
11481 | Ctor = isBindKey ? undefined : createCtorWrapper(func);
|
11482 |
|
11483 | function wrapper() {
|
11484 |
|
11485 |
|
11486 | var length = arguments.length,
|
11487 | index = length,
|
11488 | args = Array(length);
|
11489 |
|
11490 | while (index--) {
|
11491 | args[index] = arguments[index];
|
11492 | }
|
11493 | if (partials) {
|
11494 | args = composeArgs(args, partials, holders);
|
11495 | }
|
11496 | if (partialsRight) {
|
11497 | args = composeArgsRight(args, partialsRight, holdersRight);
|
11498 | }
|
11499 | if (isCurry || isCurryRight) {
|
11500 | var placeholder = wrapper.placeholder,
|
11501 | argsHolders = replaceHolders(args, placeholder);
|
11502 |
|
11503 | length -= argsHolders.length;
|
11504 | if (length < arity) {
|
11505 | var newArgPos = argPos ? arrayCopy(argPos) : undefined,
|
11506 | newArity = nativeMax(arity - length, 0),
|
11507 | newsHolders = isCurry ? argsHolders : undefined,
|
11508 | newHoldersRight = isCurry ? undefined : argsHolders,
|
11509 | newPartials = isCurry ? args : undefined,
|
11510 | newPartialsRight = isCurry ? undefined : args;
|
11511 |
|
11512 | bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
|
11513 | bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
|
11514 |
|
11515 | if (!isCurryBound) {
|
11516 | bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
11517 | }
|
11518 | var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity],
|
11519 | result = createHybridWrapper.apply(undefined, newData);
|
11520 |
|
11521 | if (isLaziable(func)) {
|
11522 | setData(result, newData);
|
11523 | }
|
11524 | result.placeholder = placeholder;
|
11525 | return result;
|
11526 | }
|
11527 | }
|
11528 | var thisBinding = isBind ? thisArg : this,
|
11529 | fn = isBindKey ? thisBinding[func] : func;
|
11530 |
|
11531 | if (argPos) {
|
11532 | args = reorder(args, argPos);
|
11533 | }
|
11534 | if (isAry && ary < args.length) {
|
11535 | args.length = ary;
|
11536 | }
|
11537 | if (this && this !== root && this instanceof wrapper) {
|
11538 | fn = Ctor || createCtorWrapper(func);
|
11539 | }
|
11540 | return fn.apply(thisBinding, args);
|
11541 | }
|
11542 | return wrapper;
|
11543 | }
|
11544 |
|
11545 | |
11546 |
|
11547 |
|
11548 |
|
11549 |
|
11550 |
|
11551 |
|
11552 |
|
11553 |
|
11554 |
|
11555 | function createPadding(string, length, chars) {
|
11556 | var strLength = string.length;
|
11557 | length = +length;
|
11558 |
|
11559 | if (strLength >= length || !nativeIsFinite(length)) {
|
11560 | return '';
|
11561 | }
|
11562 | var padLength = length - strLength;
|
11563 | chars = chars == null ? ' ' : (chars + '');
|
11564 | return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength);
|
11565 | }
|
11566 |
|
11567 | |
11568 |
|
11569 |
|
11570 |
|
11571 |
|
11572 |
|
11573 |
|
11574 |
|
11575 |
|
11576 |
|
11577 |
|
11578 |
|
11579 | function createPartialWrapper(func, bitmask, thisArg, partials) {
|
11580 | var isBind = bitmask & BIND_FLAG,
|
11581 | Ctor = createCtorWrapper(func);
|
11582 |
|
11583 | function wrapper() {
|
11584 |
|
11585 |
|
11586 | var argsIndex = -1,
|
11587 | argsLength = arguments.length,
|
11588 | leftIndex = -1,
|
11589 | leftLength = partials.length,
|
11590 | args = Array(leftLength + argsLength);
|
11591 |
|
11592 | while (++leftIndex < leftLength) {
|
11593 | args[leftIndex] = partials[leftIndex];
|
11594 | }
|
11595 | while (argsLength--) {
|
11596 | args[leftIndex++] = arguments[++argsIndex];
|
11597 | }
|
11598 | var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
|
11599 | return fn.apply(isBind ? thisArg : this, args);
|
11600 | }
|
11601 | return wrapper;
|
11602 | }
|
11603 |
|
11604 | |
11605 |
|
11606 |
|
11607 |
|
11608 |
|
11609 |
|
11610 |
|
11611 | function createRound(methodName) {
|
11612 | var func = Math[methodName];
|
11613 | return function(number, precision) {
|
11614 | precision = precision === undefined ? 0 : (+precision || 0);
|
11615 | if (precision) {
|
11616 | precision = pow(10, precision);
|
11617 | return func(number * precision) / precision;
|
11618 | }
|
11619 | return func(number);
|
11620 | };
|
11621 | }
|
11622 |
|
11623 | |
11624 |
|
11625 |
|
11626 |
|
11627 |
|
11628 |
|
11629 |
|
11630 | function createSortedIndex(retHighest) {
|
11631 | return function(array, value, iteratee, thisArg) {
|
11632 | var callback = getCallback(iteratee);
|
11633 | return (iteratee == null && callback === baseCallback)
|
11634 | ? binaryIndex(array, value, retHighest)
|
11635 | : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest);
|
11636 | };
|
11637 | }
|
11638 |
|
11639 | |
11640 |
|
11641 |
|
11642 |
|
11643 |
|
11644 |
|
11645 |
|
11646 |
|
11647 |
|
11648 |
|
11649 |
|
11650 |
|
11651 |
|
11652 |
|
11653 |
|
11654 |
|
11655 |
|
11656 |
|
11657 |
|
11658 |
|
11659 |
|
11660 |
|
11661 |
|
11662 |
|
11663 |
|
11664 | function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
|
11665 | var isBindKey = bitmask & BIND_KEY_FLAG;
|
11666 | if (!isBindKey && typeof func != 'function') {
|
11667 | throw new TypeError(FUNC_ERROR_TEXT);
|
11668 | }
|
11669 | var length = partials ? partials.length : 0;
|
11670 | if (!length) {
|
11671 | bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
|
11672 | partials = holders = undefined;
|
11673 | }
|
11674 | length -= (holders ? holders.length : 0);
|
11675 | if (bitmask & PARTIAL_RIGHT_FLAG) {
|
11676 | var partialsRight = partials,
|
11677 | holdersRight = holders;
|
11678 |
|
11679 | partials = holders = undefined;
|
11680 | }
|
11681 | var data = isBindKey ? undefined : getData(func),
|
11682 | newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
11683 |
|
11684 | if (data) {
|
11685 | mergeData(newData, data);
|
11686 | bitmask = newData[1];
|
11687 | arity = newData[9];
|
11688 | }
|
11689 | newData[9] = arity == null
|
11690 | ? (isBindKey ? 0 : func.length)
|
11691 | : (nativeMax(arity - length, 0) || 0);
|
11692 |
|
11693 | if (bitmask == BIND_FLAG) {
|
11694 | var result = createBindWrapper(newData[0], newData[2]);
|
11695 | } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
|
11696 | result = createPartialWrapper.apply(undefined, newData);
|
11697 | } else {
|
11698 | result = createHybridWrapper.apply(undefined, newData);
|
11699 | }
|
11700 | var setter = data ? baseSetData : setData;
|
11701 | return setter(result, newData);
|
11702 | }
|
11703 |
|
11704 | |
11705 |
|
11706 |
|
11707 |
|
11708 |
|
11709 |
|
11710 |
|
11711 |
|
11712 |
|
11713 |
|
11714 |
|
11715 |
|
11716 |
|
11717 |
|
11718 | function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
|
11719 | var index = -1,
|
11720 | arrLength = array.length,
|
11721 | othLength = other.length;
|
11722 |
|
11723 | if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
|
11724 | return false;
|
11725 | }
|
11726 |
|
11727 | while (++index < arrLength) {
|
11728 | var arrValue = array[index],
|
11729 | othValue = other[index],
|
11730 | result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
|
11731 |
|
11732 | if (result !== undefined) {
|
11733 | if (result) {
|
11734 | continue;
|
11735 | }
|
11736 | return false;
|
11737 | }
|
11738 |
|
11739 | if (isLoose) {
|
11740 | if (!arraySome(other, function(othValue) {
|
11741 | return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
|
11742 | })) {
|
11743 | return false;
|
11744 | }
|
11745 | } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
|
11746 | return false;
|
11747 | }
|
11748 | }
|
11749 | return true;
|
11750 | }
|
11751 |
|
11752 | |
11753 |
|
11754 |
|
11755 |
|
11756 |
|
11757 |
|
11758 |
|
11759 |
|
11760 |
|
11761 |
|
11762 |
|
11763 |
|
11764 |
|
11765 | function equalByTag(object, other, tag) {
|
11766 | switch (tag) {
|
11767 | case boolTag:
|
11768 | case dateTag:
|
11769 |
|
11770 |
|
11771 | return +object == +other;
|
11772 |
|
11773 | case errorTag:
|
11774 | return object.name == other.name && object.message == other.message;
|
11775 |
|
11776 | case numberTag:
|
11777 |
|
11778 | return (object != +object)
|
11779 | ? other != +other
|
11780 | : object == +other;
|
11781 |
|
11782 | case regexpTag:
|
11783 | case stringTag:
|
11784 |
|
11785 |
|
11786 | return object == (other + '');
|
11787 | }
|
11788 | return false;
|
11789 | }
|
11790 |
|
11791 | |
11792 |
|
11793 |
|
11794 |
|
11795 |
|
11796 |
|
11797 |
|
11798 |
|
11799 |
|
11800 |
|
11801 |
|
11802 |
|
11803 |
|
11804 |
|
11805 | function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
|
11806 | var objProps = keys(object),
|
11807 | objLength = objProps.length,
|
11808 | othProps = keys(other),
|
11809 | othLength = othProps.length;
|
11810 |
|
11811 | if (objLength != othLength && !isLoose) {
|
11812 | return false;
|
11813 | }
|
11814 | var index = objLength;
|
11815 | while (index--) {
|
11816 | var key = objProps[index];
|
11817 | if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
|
11818 | return false;
|
11819 | }
|
11820 | }
|
11821 | var skipCtor = isLoose;
|
11822 | while (++index < objLength) {
|
11823 | key = objProps[index];
|
11824 | var objValue = object[key],
|
11825 | othValue = other[key],
|
11826 | result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
|
11827 |
|
11828 |
|
11829 | if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
|
11830 | return false;
|
11831 | }
|
11832 | skipCtor || (skipCtor = key == 'constructor');
|
11833 | }
|
11834 | if (!skipCtor) {
|
11835 | var objCtor = object.constructor,
|
11836 | othCtor = other.constructor;
|
11837 |
|
11838 |
|
11839 | if (objCtor != othCtor &&
|
11840 | ('constructor' in object && 'constructor' in other) &&
|
11841 | !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
11842 | typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
11843 | return false;
|
11844 | }
|
11845 | }
|
11846 | return true;
|
11847 | }
|
11848 |
|
11849 | |
11850 |
|
11851 |
|
11852 |
|
11853 |
|
11854 |
|
11855 |
|
11856 |
|
11857 |
|
11858 | function getCallback(func, thisArg, argCount) {
|
11859 | var result = lodash.callback || callback;
|
11860 | result = result === callback ? baseCallback : result;
|
11861 | return argCount ? result(func, thisArg, argCount) : result;
|
11862 | }
|
11863 |
|
11864 | |
11865 |
|
11866 |
|
11867 |
|
11868 |
|
11869 |
|
11870 |
|
11871 | var getData = !metaMap ? noop : function(func) {
|
11872 | return metaMap.get(func);
|
11873 | };
|
11874 |
|
11875 | |
11876 |
|
11877 |
|
11878 |
|
11879 |
|
11880 |
|
11881 |
|
11882 | function getFuncName(func) {
|
11883 | var result = func.name,
|
11884 | array = realNames[result],
|
11885 | length = array ? array.length : 0;
|
11886 |
|
11887 | while (length--) {
|
11888 | var data = array[length],
|
11889 | otherFunc = data.func;
|
11890 | if (otherFunc == null || otherFunc == func) {
|
11891 | return data.name;
|
11892 | }
|
11893 | }
|
11894 | return result;
|
11895 | }
|
11896 |
|
11897 | |
11898 |
|
11899 |
|
11900 |
|
11901 |
|
11902 |
|
11903 |
|
11904 |
|
11905 |
|
11906 | function getIndexOf(collection, target, fromIndex) {
|
11907 | var result = lodash.indexOf || indexOf;
|
11908 | result = result === indexOf ? baseIndexOf : result;
|
11909 | return collection ? result(collection, target, fromIndex) : result;
|
11910 | }
|
11911 |
|
11912 | |
11913 |
|
11914 |
|
11915 |
|
11916 |
|
11917 |
|
11918 |
|
11919 |
|
11920 |
|
11921 |
|
11922 | var getLength = baseProperty('length');
|
11923 |
|
11924 | |
11925 |
|
11926 |
|
11927 |
|
11928 |
|
11929 |
|
11930 |
|
11931 | function getMatchData(object) {
|
11932 | var result = pairs(object),
|
11933 | length = result.length;
|
11934 |
|
11935 | while (length--) {
|
11936 | result[length][2] = isStrictComparable(result[length][1]);
|
11937 | }
|
11938 | return result;
|
11939 | }
|
11940 |
|
11941 | |
11942 |
|
11943 |
|
11944 |
|
11945 |
|
11946 |
|
11947 |
|
11948 |
|
11949 | function getNative(object, key) {
|
11950 | var value = object == null ? undefined : object[key];
|
11951 | return isNative(value) ? value : undefined;
|
11952 | }
|
11953 |
|
11954 | |
11955 |
|
11956 |
|
11957 |
|
11958 |
|
11959 |
|
11960 |
|
11961 |
|
11962 |
|
11963 |
|
11964 | function getView(start, end, transforms) {
|
11965 | var index = -1,
|
11966 | length = transforms.length;
|
11967 |
|
11968 | while (++index < length) {
|
11969 | var data = transforms[index],
|
11970 | size = data.size;
|
11971 |
|
11972 | switch (data.type) {
|
11973 | case 'drop': start += size; break;
|
11974 | case 'dropRight': end -= size; break;
|
11975 | case 'take': end = nativeMin(end, start + size); break;
|
11976 | case 'takeRight': start = nativeMax(start, end - size); break;
|
11977 | }
|
11978 | }
|
11979 | return { 'start': start, 'end': end };
|
11980 | }
|
11981 |
|
11982 | |
11983 |
|
11984 |
|
11985 |
|
11986 |
|
11987 |
|
11988 |
|
11989 | function initCloneArray(array) {
|
11990 | var length = array.length,
|
11991 | result = new array.constructor(length);
|
11992 |
|
11993 |
|
11994 | if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
11995 | result.index = array.index;
|
11996 | result.input = array.input;
|
11997 | }
|
11998 | return result;
|
11999 | }
|
12000 |
|
12001 | |
12002 |
|
12003 |
|
12004 |
|
12005 |
|
12006 |
|
12007 |
|
12008 | function initCloneObject(object) {
|
12009 | var Ctor = object.constructor;
|
12010 | if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
|
12011 | Ctor = Object;
|
12012 | }
|
12013 | return new Ctor;
|
12014 | }
|
12015 |
|
12016 | |
12017 |
|
12018 |
|
12019 |
|
12020 |
|
12021 |
|
12022 |
|
12023 |
|
12024 |
|
12025 |
|
12026 |
|
12027 |
|
12028 | function initCloneByTag(object, tag, isDeep) {
|
12029 | var Ctor = object.constructor;
|
12030 | switch (tag) {
|
12031 | case arrayBufferTag:
|
12032 | return bufferClone(object);
|
12033 |
|
12034 | case boolTag:
|
12035 | case dateTag:
|
12036 | return new Ctor(+object);
|
12037 |
|
12038 | case float32Tag: case float64Tag:
|
12039 | case int8Tag: case int16Tag: case int32Tag:
|
12040 | case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
|
12041 | var buffer = object.buffer;
|
12042 | return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
|
12043 |
|
12044 | case numberTag:
|
12045 | case stringTag:
|
12046 | return new Ctor(object);
|
12047 |
|
12048 | case regexpTag:
|
12049 | var result = new Ctor(object.source, reFlags.exec(object));
|
12050 | result.lastIndex = object.lastIndex;
|
12051 | }
|
12052 | return result;
|
12053 | }
|
12054 |
|
12055 | |
12056 |
|
12057 |
|
12058 |
|
12059 |
|
12060 |
|
12061 |
|
12062 |
|
12063 |
|
12064 | function invokePath(object, path, args) {
|
12065 | if (object != null && !isKey(path, object)) {
|
12066 | path = toPath(path);
|
12067 | object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
12068 | path = last(path);
|
12069 | }
|
12070 | var func = object == null ? object : object[path];
|
12071 | return func == null ? undefined : func.apply(object, args);
|
12072 | }
|
12073 |
|
12074 | |
12075 |
|
12076 |
|
12077 |
|
12078 |
|
12079 |
|
12080 |
|
12081 | function isArrayLike(value) {
|
12082 | return value != null && isLength(getLength(value));
|
12083 | }
|
12084 |
|
12085 | |
12086 |
|
12087 |
|
12088 |
|
12089 |
|
12090 |
|
12091 |
|
12092 |
|
12093 | function isIndex(value, length) {
|
12094 | value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
|
12095 | length = length == null ? MAX_SAFE_INTEGER : length;
|
12096 | return value > -1 && value % 1 == 0 && value < length;
|
12097 | }
|
12098 |
|
12099 | |
12100 |
|
12101 |
|
12102 |
|
12103 |
|
12104 |
|
12105 |
|
12106 |
|
12107 |
|
12108 | function isIterateeCall(value, index, object) {
|
12109 | if (!isObject(object)) {
|
12110 | return false;
|
12111 | }
|
12112 | var type = typeof index;
|
12113 | if (type == 'number'
|
12114 | ? (isArrayLike(object) && isIndex(index, object.length))
|
12115 | : (type == 'string' && index in object)) {
|
12116 | var other = object[index];
|
12117 | return value === value ? (value === other) : (other !== other);
|
12118 | }
|
12119 | return false;
|
12120 | }
|
12121 |
|
12122 | |
12123 |
|
12124 |
|
12125 |
|
12126 |
|
12127 |
|
12128 |
|
12129 |
|
12130 | function isKey(value, object) {
|
12131 | var type = typeof value;
|
12132 | if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
|
12133 | return true;
|
12134 | }
|
12135 | if (isArray(value)) {
|
12136 | return false;
|
12137 | }
|
12138 | var result = !reIsDeepProp.test(value);
|
12139 | return result || (object != null && value in toObject(object));
|
12140 | }
|
12141 |
|
12142 | |
12143 |
|
12144 |
|
12145 |
|
12146 |
|
12147 |
|
12148 |
|
12149 | function isLaziable(func) {
|
12150 | var funcName = getFuncName(func);
|
12151 | if (!(funcName in LazyWrapper.prototype)) {
|
12152 | return false;
|
12153 | }
|
12154 | var other = lodash[funcName];
|
12155 | if (func === other) {
|
12156 | return true;
|
12157 | }
|
12158 | var data = getData(other);
|
12159 | return !!data && func === data[0];
|
12160 | }
|
12161 |
|
12162 | |
12163 |
|
12164 |
|
12165 |
|
12166 |
|
12167 |
|
12168 |
|
12169 |
|
12170 |
|
12171 | function isLength(value) {
|
12172 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
12173 | }
|
12174 |
|
12175 | |
12176 |
|
12177 |
|
12178 |
|
12179 |
|
12180 |
|
12181 |
|
12182 |
|
12183 | function isStrictComparable(value) {
|
12184 | return value === value && !isObject(value);
|
12185 | }
|
12186 |
|
12187 | |
12188 |
|
12189 |
|
12190 |
|
12191 |
|
12192 |
|
12193 |
|
12194 |
|
12195 |
|
12196 |
|
12197 |
|
12198 |
|
12199 |
|
12200 |
|
12201 |
|
12202 | function mergeData(data, source) {
|
12203 | var bitmask = data[1],
|
12204 | srcBitmask = source[1],
|
12205 | newBitmask = bitmask | srcBitmask,
|
12206 | isCommon = newBitmask < ARY_FLAG;
|
12207 |
|
12208 | var isCombo =
|
12209 | (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) ||
|
12210 | (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) ||
|
12211 | (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG);
|
12212 |
|
12213 |
|
12214 | if (!(isCommon || isCombo)) {
|
12215 | return data;
|
12216 | }
|
12217 |
|
12218 | if (srcBitmask & BIND_FLAG) {
|
12219 | data[2] = source[2];
|
12220 |
|
12221 | newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;
|
12222 | }
|
12223 |
|
12224 | var value = source[3];
|
12225 | if (value) {
|
12226 | var partials = data[3];
|
12227 | data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value);
|
12228 | data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]);
|
12229 | }
|
12230 |
|
12231 | value = source[5];
|
12232 | if (value) {
|
12233 | partials = data[5];
|
12234 | data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value);
|
12235 | data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]);
|
12236 | }
|
12237 |
|
12238 | value = source[7];
|
12239 | if (value) {
|
12240 | data[7] = arrayCopy(value);
|
12241 | }
|
12242 |
|
12243 | if (srcBitmask & ARY_FLAG) {
|
12244 | data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
|
12245 | }
|
12246 |
|
12247 | if (data[9] == null) {
|
12248 | data[9] = source[9];
|
12249 | }
|
12250 |
|
12251 | data[0] = source[0];
|
12252 | data[1] = newBitmask;
|
12253 |
|
12254 | return data;
|
12255 | }
|
12256 |
|
12257 | |
12258 |
|
12259 |
|
12260 |
|
12261 |
|
12262 |
|
12263 |
|
12264 |
|
12265 | function mergeDefaults(objectValue, sourceValue) {
|
12266 | return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults);
|
12267 | }
|
12268 |
|
12269 | |
12270 |
|
12271 |
|
12272 |
|
12273 |
|
12274 |
|
12275 |
|
12276 |
|
12277 |
|
12278 | function pickByArray(object, props) {
|
12279 | object = toObject(object);
|
12280 |
|
12281 | var index = -1,
|
12282 | length = props.length,
|
12283 | result = {};
|
12284 |
|
12285 | while (++index < length) {
|
12286 | var key = props[index];
|
12287 | if (key in object) {
|
12288 | result[key] = object[key];
|
12289 | }
|
12290 | }
|
12291 | return result;
|
12292 | }
|
12293 |
|
12294 | |
12295 |
|
12296 |
|
12297 |
|
12298 |
|
12299 |
|
12300 |
|
12301 |
|
12302 |
|
12303 | function pickByCallback(object, predicate) {
|
12304 | var result = {};
|
12305 | baseForIn(object, function(value, key, object) {
|
12306 | if (predicate(value, key, object)) {
|
12307 | result[key] = value;
|
12308 | }
|
12309 | });
|
12310 | return result;
|
12311 | }
|
12312 |
|
12313 | |
12314 |
|
12315 |
|
12316 |
|
12317 |
|
12318 |
|
12319 |
|
12320 |
|
12321 |
|
12322 |
|
12323 | function reorder(array, indexes) {
|
12324 | var arrLength = array.length,
|
12325 | length = nativeMin(indexes.length, arrLength),
|
12326 | oldArray = arrayCopy(array);
|
12327 |
|
12328 | while (length--) {
|
12329 | var index = indexes[length];
|
12330 | array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
|
12331 | }
|
12332 | return array;
|
12333 | }
|
12334 |
|
12335 | |
12336 |
|
12337 |
|
12338 |
|
12339 |
|
12340 |
|
12341 |
|
12342 |
|
12343 |
|
12344 |
|
12345 |
|
12346 |
|
12347 |
|
12348 | var setData = (function() {
|
12349 | var count = 0,
|
12350 | lastCalled = 0;
|
12351 |
|
12352 | return function(key, value) {
|
12353 | var stamp = now(),
|
12354 | remaining = HOT_SPAN - (stamp - lastCalled);
|
12355 |
|
12356 | lastCalled = stamp;
|
12357 | if (remaining > 0) {
|
12358 | if (++count >= HOT_COUNT) {
|
12359 | return key;
|
12360 | }
|
12361 | } else {
|
12362 | count = 0;
|
12363 | }
|
12364 | return baseSetData(key, value);
|
12365 | };
|
12366 | }());
|
12367 |
|
12368 | |
12369 |
|
12370 |
|
12371 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 | function shimKeys(object) {
|
12377 | var props = keysIn(object),
|
12378 | propsLength = props.length,
|
12379 | length = propsLength && object.length;
|
12380 |
|
12381 | var allowIndexes = !!length && isLength(length) &&
|
12382 | (isArray(object) || isArguments(object));
|
12383 |
|
12384 | var index = -1,
|
12385 | result = [];
|
12386 |
|
12387 | while (++index < propsLength) {
|
12388 | var key = props[index];
|
12389 | if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
|
12390 | result.push(key);
|
12391 | }
|
12392 | }
|
12393 | return result;
|
12394 | }
|
12395 |
|
12396 | |
12397 |
|
12398 |
|
12399 |
|
12400 |
|
12401 |
|
12402 |
|
12403 | function toIterable(value) {
|
12404 | if (value == null) {
|
12405 | return [];
|
12406 | }
|
12407 | if (!isArrayLike(value)) {
|
12408 | return values(value);
|
12409 | }
|
12410 | return isObject(value) ? value : Object(value);
|
12411 | }
|
12412 |
|
12413 | |
12414 |
|
12415 |
|
12416 |
|
12417 |
|
12418 |
|
12419 |
|
12420 | function toObject(value) {
|
12421 | return isObject(value) ? value : Object(value);
|
12422 | }
|
12423 |
|
12424 | |
12425 |
|
12426 |
|
12427 |
|
12428 |
|
12429 |
|
12430 |
|
12431 | function toPath(value) {
|
12432 | if (isArray(value)) {
|
12433 | return value;
|
12434 | }
|
12435 | var result = [];
|
12436 | baseToString(value).replace(rePropName, function(match, number, quote, string) {
|
12437 | result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
|
12438 | });
|
12439 | return result;
|
12440 | }
|
12441 |
|
12442 | |
12443 |
|
12444 |
|
12445 |
|
12446 |
|
12447 |
|
12448 |
|
12449 | function wrapperClone(wrapper) {
|
12450 | return wrapper instanceof LazyWrapper
|
12451 | ? wrapper.clone()
|
12452 | : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));
|
12453 | }
|
12454 |
|
12455 |
|
12456 |
|
12457 | |
12458 |
|
12459 |
|
12460 |
|
12461 |
|
12462 |
|
12463 |
|
12464 |
|
12465 |
|
12466 |
|
12467 |
|
12468 |
|
12469 |
|
12470 |
|
12471 |
|
12472 |
|
12473 |
|
12474 |
|
12475 |
|
12476 |
|
12477 | function chunk(array, size, guard) {
|
12478 | if (guard ? isIterateeCall(array, size, guard) : size == null) {
|
12479 | size = 1;
|
12480 | } else {
|
12481 | size = nativeMax(nativeFloor(size) || 1, 1);
|
12482 | }
|
12483 | var index = 0,
|
12484 | length = array ? array.length : 0,
|
12485 | resIndex = -1,
|
12486 | result = Array(nativeCeil(length / size));
|
12487 |
|
12488 | while (index < length) {
|
12489 | result[++resIndex] = baseSlice(array, index, (index += size));
|
12490 | }
|
12491 | return result;
|
12492 | }
|
12493 |
|
12494 | |
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 |
|
12504 |
|
12505 |
|
12506 |
|
12507 |
|
12508 | function compact(array) {
|
12509 | var index = -1,
|
12510 | length = array ? array.length : 0,
|
12511 | resIndex = -1,
|
12512 | result = [];
|
12513 |
|
12514 | while (++index < length) {
|
12515 | var value = array[index];
|
12516 | if (value) {
|
12517 | result[++resIndex] = value;
|
12518 | }
|
12519 | }
|
12520 | return result;
|
12521 | }
|
12522 |
|
12523 | |
12524 |
|
12525 |
|
12526 |
|
12527 |
|
12528 |
|
12529 |
|
12530 |
|
12531 |
|
12532 |
|
12533 |
|
12534 |
|
12535 |
|
12536 |
|
12537 |
|
12538 |
|
12539 | var difference = restParam(function(array, values) {
|
12540 | return (isObjectLike(array) && isArrayLike(array))
|
12541 | ? baseDifference(array, baseFlatten(values, false, true))
|
12542 | : [];
|
12543 | });
|
12544 |
|
12545 | |
12546 |
|
12547 |
|
12548 |
|
12549 |
|
12550 |
|
12551 |
|
12552 |
|
12553 |
|
12554 |
|
12555 |
|
12556 |
|
12557 |
|
12558 |
|
12559 |
|
12560 |
|
12561 |
|
12562 |
|
12563 |
|
12564 |
|
12565 |
|
12566 |
|
12567 |
|
12568 |
|
12569 | function drop(array, n, guard) {
|
12570 | var length = array ? array.length : 0;
|
12571 | if (!length) {
|
12572 | return [];
|
12573 | }
|
12574 | if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
12575 | n = 1;
|
12576 | }
|
12577 | return baseSlice(array, n < 0 ? 0 : n);
|
12578 | }
|
12579 |
|
12580 | |
12581 |
|
12582 |
|
12583 |
|
12584 |
|
12585 |
|
12586 |
|
12587 |
|
12588 |
|
12589 |
|
12590 |
|
12591 |
|
12592 |
|
12593 |
|
12594 |
|
12595 |
|
12596 |
|
12597 |
|
12598 |
|
12599 |
|
12600 |
|
12601 |
|
12602 |
|
12603 |
|
12604 | function dropRight(array, n, guard) {
|
12605 | var length = array ? array.length : 0;
|
12606 | if (!length) {
|
12607 | return [];
|
12608 | }
|
12609 | if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
12610 | n = 1;
|
12611 | }
|
12612 | n = length - (+n || 0);
|
12613 | return baseSlice(array, 0, n < 0 ? 0 : n);
|
12614 | }
|
12615 |
|
12616 | |
12617 |
|
12618 |
|
12619 |
|
12620 |
|
12621 |
|
12622 |
|
12623 |
|
12624 |
|
12625 |
|
12626 |
|
12627 |
|
12628 |
|
12629 |
|
12630 |
|
12631 |
|
12632 |
|
12633 |
|
12634 |
|
12635 |
|
12636 |
|
12637 |
|
12638 |
|
12639 |
|
12640 |
|
12641 |
|
12642 |
|
12643 |
|
12644 |
|
12645 |
|
12646 |
|
12647 |
|
12648 |
|
12649 |
|
12650 |
|
12651 |
|
12652 |
|
12653 |
|
12654 |
|
12655 |
|
12656 |
|
12657 |
|
12658 |
|
12659 |
|
12660 |
|
12661 |
|
12662 |
|
12663 |
|
12664 |
|
12665 | function dropRightWhile(array, predicate, thisArg) {
|
12666 | return (array && array.length)
|
12667 | ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true)
|
12668 | : [];
|
12669 | }
|
12670 |
|
12671 | |
12672 |
|
12673 |
|
12674 |
|
12675 |
|
12676 |
|
12677 |
|
12678 |
|
12679 |
|
12680 |
|
12681 |
|
12682 |
|
12683 |
|
12684 |
|
12685 |
|
12686 |
|
12687 |
|
12688 |
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 |
|
12694 |
|
12695 |
|
12696 |
|
12697 |
|
12698 |
|
12699 |
|
12700 |
|
12701 |
|
12702 |
|
12703 |
|
12704 |
|
12705 |
|
12706 |
|
12707 |
|
12708 |
|
12709 |
|
12710 |
|
12711 |
|
12712 |
|
12713 |
|
12714 |
|
12715 |
|
12716 |
|
12717 |
|
12718 |
|
12719 |
|
12720 | function dropWhile(array, predicate, thisArg) {
|
12721 | return (array && array.length)
|
12722 | ? baseWhile(array, getCallback(predicate, thisArg, 3), true)
|
12723 | : [];
|
12724 | }
|
12725 |
|
12726 | |
12727 |
|
12728 |
|
12729 |
|
12730 |
|
12731 |
|
12732 |
|
12733 |
|
12734 |
|
12735 |
|
12736 |
|
12737 |
|
12738 |
|
12739 |
|
12740 |
|
12741 |
|
12742 |
|
12743 |
|
12744 |
|
12745 |
|
12746 |
|
12747 |
|
12748 |
|
12749 |
|
12750 |
|
12751 |
|
12752 |
|
12753 |
|
12754 | function fill(array, value, start, end) {
|
12755 | var length = array ? array.length : 0;
|
12756 | if (!length) {
|
12757 | return [];
|
12758 | }
|
12759 | if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
|
12760 | start = 0;
|
12761 | end = length;
|
12762 | }
|
12763 | return baseFill(array, value, start, end);
|
12764 | }
|
12765 |
|
12766 | |
12767 |
|
12768 |
|
12769 |
|
12770 |
|
12771 |
|
12772 |
|
12773 |
|
12774 |
|
12775 |
|
12776 |
|
12777 |
|
12778 |
|
12779 |
|
12780 |
|
12781 |
|
12782 |
|
12783 |
|
12784 |
|
12785 |
|
12786 |
|
12787 |
|
12788 |
|
12789 |
|
12790 |
|
12791 |
|
12792 |
|
12793 |
|
12794 |
|
12795 |
|
12796 |
|
12797 |
|
12798 |
|
12799 |
|
12800 |
|
12801 |
|
12802 |
|
12803 |
|
12804 |
|
12805 |
|
12806 |
|
12807 |
|
12808 |
|
12809 |
|
12810 |
|
12811 |
|
12812 |
|
12813 |
|
12814 | var findIndex = createFindIndex();
|
12815 |
|
12816 | |
12817 |
|
12818 |
|
12819 |
|
12820 |
|
12821 |
|
12822 |
|
12823 |
|
12824 |
|
12825 |
|
12826 |
|
12827 |
|
12828 |
|
12829 |
|
12830 |
|
12831 |
|
12832 |
|
12833 |
|
12834 |
|
12835 |
|
12836 |
|
12837 |
|
12838 |
|
12839 |
|
12840 |
|
12841 |
|
12842 |
|
12843 |
|
12844 |
|
12845 |
|
12846 |
|
12847 |
|
12848 |
|
12849 |
|
12850 |
|
12851 |
|
12852 |
|
12853 |
|
12854 |
|
12855 |
|
12856 |
|
12857 |
|
12858 |
|
12859 |
|
12860 |
|
12861 |
|
12862 |
|
12863 |
|
12864 | var findLastIndex = createFindIndex(true);
|
12865 |
|
12866 | |
12867 |
|
12868 |
|
12869 |
|
12870 |
|
12871 |
|
12872 |
|
12873 |
|
12874 |
|
12875 |
|
12876 |
|
12877 |
|
12878 |
|
12879 |
|
12880 |
|
12881 |
|
12882 |
|
12883 | function first(array) {
|
12884 | return array ? array[0] : undefined;
|
12885 | }
|
12886 |
|
12887 | |
12888 |
|
12889 |
|
12890 |
|
12891 |
|
12892 |
|
12893 |
|
12894 |
|
12895 |
|
12896 |
|
12897 |
|
12898 |
|
12899 |
|
12900 |
|
12901 |
|
12902 |
|
12903 |
|
12904 |
|
12905 |
|
12906 |
|
12907 | function flatten(array, isDeep, guard) {
|
12908 | var length = array ? array.length : 0;
|
12909 | if (guard && isIterateeCall(array, isDeep, guard)) {
|
12910 | isDeep = false;
|
12911 | }
|
12912 | return length ? baseFlatten(array, isDeep) : [];
|
12913 | }
|
12914 |
|
12915 | |
12916 |
|
12917 |
|
12918 |
|
12919 |
|
12920 |
|
12921 |
|
12922 |
|
12923 |
|
12924 |
|
12925 |
|
12926 |
|
12927 |
|
12928 | function flattenDeep(array) {
|
12929 | var length = array ? array.length : 0;
|
12930 | return length ? baseFlatten(array, true) : [];
|
12931 | }
|
12932 |
|
12933 | |
12934 |
|
12935 |
|
12936 |
|
12937 |
|
12938 |
|
12939 |
|
12940 |
|
12941 |
|
12942 |
|
12943 |
|
12944 |
|
12945 |
|
12946 |
|
12947 |
|
12948 |
|
12949 |
|
12950 |
|
12951 |
|
12952 |
|
12953 |
|
12954 |
|
12955 |
|
12956 |
|
12957 |
|
12958 |
|
12959 |
|
12960 |
|
12961 | function indexOf(array, value, fromIndex) {
|
12962 | var length = array ? array.length : 0;
|
12963 | if (!length) {
|
12964 | return -1;
|
12965 | }
|
12966 | if (typeof fromIndex == 'number') {
|
12967 | fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
|
12968 | } else if (fromIndex) {
|
12969 | var index = binaryIndex(array, value);
|
12970 | if (index < length &&
|
12971 | (value === value ? (value === array[index]) : (array[index] !== array[index]))) {
|
12972 | return index;
|
12973 | }
|
12974 | return -1;
|
12975 | }
|
12976 | return baseIndexOf(array, value, fromIndex || 0);
|
12977 | }
|
12978 |
|
12979 | |
12980 |
|
12981 |
|
12982 |
|
12983 |
|
12984 |
|
12985 |
|
12986 |
|
12987 |
|
12988 |
|
12989 |
|
12990 |
|
12991 |
|
12992 | function initial(array) {
|
12993 | return dropRight(array, 1);
|
12994 | }
|
12995 |
|
12996 | |
12997 |
|
12998 |
|
12999 |
|
13000 |
|
13001 |
|
13002 |
|
13003 |
|
13004 |
|
13005 |
|
13006 |
|
13007 |
|
13008 |
|
13009 |
|
13010 | var intersection = restParam(function(arrays) {
|
13011 | var othLength = arrays.length,
|
13012 | othIndex = othLength,
|
13013 | caches = Array(length),
|
13014 | indexOf = getIndexOf(),
|
13015 | isCommon = indexOf == baseIndexOf,
|
13016 | result = [];
|
13017 |
|
13018 | while (othIndex--) {
|
13019 | var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
|
13020 | caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;
|
13021 | }
|
13022 | var array = arrays[0],
|
13023 | index = -1,
|
13024 | length = array ? array.length : 0,
|
13025 | seen = caches[0];
|
13026 |
|
13027 | outer:
|
13028 | while (++index < length) {
|
13029 | value = array[index];
|
13030 | if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
|
13031 | var othIndex = othLength;
|
13032 | while (--othIndex) {
|
13033 | var cache = caches[othIndex];
|
13034 | if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {
|
13035 | continue outer;
|
13036 | }
|
13037 | }
|
13038 | if (seen) {
|
13039 | seen.push(value);
|
13040 | }
|
13041 | result.push(value);
|
13042 | }
|
13043 | }
|
13044 | return result;
|
13045 | });
|
13046 |
|
13047 | |
13048 |
|
13049 |
|
13050 |
|
13051 |
|
13052 |
|
13053 |
|
13054 |
|
13055 |
|
13056 |
|
13057 |
|
13058 |
|
13059 |
|
13060 | function last(array) {
|
13061 | var length = array ? array.length : 0;
|
13062 | return length ? array[length - 1] : undefined;
|
13063 | }
|
13064 |
|
13065 | |
13066 |
|
13067 |
|
13068 |
|
13069 |
|
13070 |
|
13071 |
|
13072 |
|
13073 |
|
13074 |
|
13075 |
|
13076 |
|
13077 |
|
13078 |
|
13079 |
|
13080 |
|
13081 |
|
13082 |
|
13083 |
|
13084 |
|
13085 |
|
13086 |
|
13087 |
|
13088 |
|
13089 |
|
13090 | function lastIndexOf(array, value, fromIndex) {
|
13091 | var length = array ? array.length : 0;
|
13092 | if (!length) {
|
13093 | return -1;
|
13094 | }
|
13095 | var index = length;
|
13096 | if (typeof fromIndex == 'number') {
|
13097 | index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1;
|
13098 | } else if (fromIndex) {
|
13099 | index = binaryIndex(array, value, true) - 1;
|
13100 | var other = array[index];
|
13101 | if (value === value ? (value === other) : (other !== other)) {
|
13102 | return index;
|
13103 | }
|
13104 | return -1;
|
13105 | }
|
13106 | if (value !== value) {
|
13107 | return indexOfNaN(array, index, true);
|
13108 | }
|
13109 | while (index--) {
|
13110 | if (array[index] === value) {
|
13111 | return index;
|
13112 | }
|
13113 | }
|
13114 | return -1;
|
13115 | }
|
13116 |
|
13117 | |
13118 |
|
13119 |
|
13120 |
|
13121 |
|
13122 |
|
13123 |
|
13124 |
|
13125 |
|
13126 |
|
13127 |
|
13128 |
|
13129 |
|
13130 |
|
13131 |
|
13132 |
|
13133 |
|
13134 |
|
13135 |
|
13136 |
|
13137 |
|
13138 | function pull() {
|
13139 | var args = arguments,
|
13140 | array = args[0];
|
13141 |
|
13142 | if (!(array && array.length)) {
|
13143 | return array;
|
13144 | }
|
13145 | var index = 0,
|
13146 | indexOf = getIndexOf(),
|
13147 | length = args.length;
|
13148 |
|
13149 | while (++index < length) {
|
13150 | var fromIndex = 0,
|
13151 | value = args[index];
|
13152 |
|
13153 | while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
|
13154 | splice.call(array, fromIndex, 1);
|
13155 | }
|
13156 | }
|
13157 | return array;
|
13158 | }
|
13159 |
|
13160 | |
13161 |
|
13162 |
|
13163 |
|
13164 |
|
13165 |
|
13166 |
|
13167 |
|
13168 |
|
13169 |
|
13170 |
|
13171 |
|
13172 |
|
13173 |
|
13174 |
|
13175 |
|
13176 |
|
13177 |
|
13178 |
|
13179 |
|
13180 |
|
13181 |
|
13182 |
|
13183 |
|
13184 |
|
13185 | var pullAt = restParam(function(array, indexes) {
|
13186 | indexes = baseFlatten(indexes);
|
13187 |
|
13188 | var result = baseAt(array, indexes);
|
13189 | basePullAt(array, indexes.sort(baseCompareAscending));
|
13190 | return result;
|
13191 | });
|
13192 |
|
13193 | |
13194 |
|
13195 |
|
13196 |
|
13197 |
|
13198 |
|
13199 |
|
13200 |
|
13201 |
|
13202 |
|
13203 |
|
13204 |
|
13205 |
|
13206 |
|
13207 |
|
13208 |
|
13209 |
|
13210 |
|
13211 |
|
13212 |
|
13213 |
|
13214 |
|
13215 |
|
13216 |
|
13217 |
|
13218 |
|
13219 |
|
13220 |
|
13221 |
|
13222 |
|
13223 |
|
13224 |
|
13225 |
|
13226 |
|
13227 |
|
13228 |
|
13229 |
|
13230 |
|
13231 |
|
13232 | function remove(array, predicate, thisArg) {
|
13233 | var result = [];
|
13234 | if (!(array && array.length)) {
|
13235 | return result;
|
13236 | }
|
13237 | var index = -1,
|
13238 | indexes = [],
|
13239 | length = array.length;
|
13240 |
|
13241 | predicate = getCallback(predicate, thisArg, 3);
|
13242 | while (++index < length) {
|
13243 | var value = array[index];
|
13244 | if (predicate(value, index, array)) {
|
13245 | result.push(value);
|
13246 | indexes.push(index);
|
13247 | }
|
13248 | }
|
13249 | basePullAt(array, indexes);
|
13250 | return result;
|
13251 | }
|
13252 |
|
13253 | |
13254 |
|
13255 |
|
13256 |
|
13257 |
|
13258 |
|
13259 |
|
13260 |
|
13261 |
|
13262 |
|
13263 |
|
13264 |
|
13265 |
|
13266 |
|
13267 | function rest(array) {
|
13268 | return drop(array, 1);
|
13269 | }
|
13270 |
|
13271 | |
13272 |
|
13273 |
|
13274 |
|
13275 |
|
13276 |
|
13277 |
|
13278 |
|
13279 |
|
13280 |
|
13281 |
|
13282 |
|
13283 |
|
13284 |
|
13285 | function slice(array, start, end) {
|
13286 | var length = array ? array.length : 0;
|
13287 | if (!length) {
|
13288 | return [];
|
13289 | }
|
13290 | if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
|
13291 | start = 0;
|
13292 | end = length;
|
13293 | }
|
13294 | return baseSlice(array, start, end);
|
13295 | }
|
13296 |
|
13297 | |
13298 |
|
13299 |
|
13300 |
|
13301 |
|
13302 |
|
13303 |
|
13304 |
|
13305 |
|
13306 |
|
13307 |
|
13308 |
|
13309 |
|
13310 |
|
13311 |
|
13312 |
|
13313 |
|
13314 |
|
13315 |
|
13316 |
|
13317 |
|
13318 |
|
13319 |
|
13320 |
|
13321 |
|
13322 |
|
13323 |
|
13324 |
|
13325 |
|
13326 |
|
13327 |
|
13328 |
|
13329 |
|
13330 |
|
13331 |
|
13332 |
|
13333 |
|
13334 |
|
13335 |
|
13336 |
|
13337 |
|
13338 |
|
13339 |
|
13340 |
|
13341 |
|
13342 |
|
13343 |
|
13344 |
|
13345 | var sortedIndex = createSortedIndex();
|
13346 |
|
13347 | |
13348 |
|
13349 |
|
13350 |
|
13351 |
|
13352 |
|
13353 |
|
13354 |
|
13355 |
|
13356 |
|
13357 |
|
13358 |
|
13359 |
|
13360 |
|
13361 |
|
13362 |
|
13363 |
|
13364 |
|
13365 |
|
13366 |
|
13367 | var sortedLastIndex = createSortedIndex(true);
|
13368 |
|
13369 | |
13370 |
|
13371 |
|
13372 |
|
13373 |
|
13374 |
|
13375 |
|
13376 |
|
13377 |
|
13378 |
|
13379 |
|
13380 |
|
13381 |
|
13382 |
|
13383 |
|
13384 |
|
13385 |
|
13386 |
|
13387 |
|
13388 |
|
13389 |
|
13390 |
|
13391 |
|
13392 |
|
13393 | function take(array, n, guard) {
|
13394 | var length = array ? array.length : 0;
|
13395 | if (!length) {
|
13396 | return [];
|
13397 | }
|
13398 | if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
13399 | n = 1;
|
13400 | }
|
13401 | return baseSlice(array, 0, n < 0 ? 0 : n);
|
13402 | }
|
13403 |
|
13404 | |
13405 |
|
13406 |
|
13407 |
|
13408 |
|
13409 |
|
13410 |
|
13411 |
|
13412 |
|
13413 |
|
13414 |
|
13415 |
|
13416 |
|
13417 |
|
13418 |
|
13419 |
|
13420 |
|
13421 |
|
13422 |
|
13423 |
|
13424 |
|
13425 |
|
13426 |
|
13427 |
|
13428 | function takeRight(array, n, guard) {
|
13429 | var length = array ? array.length : 0;
|
13430 | if (!length) {
|
13431 | return [];
|
13432 | }
|
13433 | if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
13434 | n = 1;
|
13435 | }
|
13436 | n = length - (+n || 0);
|
13437 | return baseSlice(array, n < 0 ? 0 : n);
|
13438 | }
|
13439 |
|
13440 | |
13441 |
|
13442 |
|
13443 |
|
13444 |
|
13445 |
|
13446 |
|
13447 |
|
13448 |
|
13449 |
|
13450 |
|
13451 |
|
13452 |
|
13453 |
|
13454 |
|
13455 |
|
13456 |
|
13457 |
|
13458 |
|
13459 |
|
13460 |
|
13461 |
|
13462 |
|
13463 |
|
13464 |
|
13465 |
|
13466 |
|
13467 |
|
13468 |
|
13469 |
|
13470 |
|
13471 |
|
13472 |
|
13473 |
|
13474 |
|
13475 |
|
13476 |
|
13477 |
|
13478 |
|
13479 |
|
13480 |
|
13481 |
|
13482 |
|
13483 |
|
13484 |
|
13485 |
|
13486 |
|
13487 |
|
13488 |
|
13489 | function takeRightWhile(array, predicate, thisArg) {
|
13490 | return (array && array.length)
|
13491 | ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true)
|
13492 | : [];
|
13493 | }
|
13494 |
|
13495 | |
13496 |
|
13497 |
|
13498 |
|
13499 |
|
13500 |
|
13501 |
|
13502 |
|
13503 |
|
13504 |
|
13505 |
|
13506 |
|
13507 |
|
13508 |
|
13509 |
|
13510 |
|
13511 |
|
13512 |
|
13513 |
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 |
|
13519 |
|
13520 |
|
13521 |
|
13522 |
|
13523 |
|
13524 |
|
13525 |
|
13526 |
|
13527 |
|
13528 |
|
13529 |
|
13530 |
|
13531 |
|
13532 |
|
13533 |
|
13534 |
|
13535 |
|
13536 |
|
13537 |
|
13538 |
|
13539 |
|
13540 |
|
13541 |
|
13542 |
|
13543 |
|
13544 | function takeWhile(array, predicate, thisArg) {
|
13545 | return (array && array.length)
|
13546 | ? baseWhile(array, getCallback(predicate, thisArg, 3))
|
13547 | : [];
|
13548 | }
|
13549 |
|
13550 | |
13551 |
|
13552 |
|
13553 |
|
13554 |
|
13555 |
|
13556 |
|
13557 |
|
13558 |
|
13559 |
|
13560 |
|
13561 |
|
13562 |
|
13563 |
|
13564 |
|
13565 | var union = restParam(function(arrays) {
|
13566 | return baseUniq(baseFlatten(arrays, false, true));
|
13567 | });
|
13568 |
|
13569 | |
13570 |
|
13571 |
|
13572 |
|
13573 |
|
13574 |
|
13575 |
|
13576 |
|
13577 |
|
13578 |
|
13579 |
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 |
|
13585 |
|
13586 |
|
13587 |
|
13588 |
|
13589 |
|
13590 |
|
13591 |
|
13592 |
|
13593 |
|
13594 |
|
13595 |
|
13596 |
|
13597 |
|
13598 |
|
13599 |
|
13600 |
|
13601 |
|
13602 |
|
13603 |
|
13604 |
|
13605 |
|
13606 |
|
13607 |
|
13608 |
|
13609 |
|
13610 |
|
13611 |
|
13612 |
|
13613 |
|
13614 |
|
13615 |
|
13616 |
|
13617 |
|
13618 | function uniq(array, isSorted, iteratee, thisArg) {
|
13619 | var length = array ? array.length : 0;
|
13620 | if (!length) {
|
13621 | return [];
|
13622 | }
|
13623 | if (isSorted != null && typeof isSorted != 'boolean') {
|
13624 | thisArg = iteratee;
|
13625 | iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted;
|
13626 | isSorted = false;
|
13627 | }
|
13628 | var callback = getCallback();
|
13629 | if (!(iteratee == null && callback === baseCallback)) {
|
13630 | iteratee = callback(iteratee, thisArg, 3);
|
13631 | }
|
13632 | return (isSorted && getIndexOf() == baseIndexOf)
|
13633 | ? sortedUniq(array, iteratee)
|
13634 | : baseUniq(array, iteratee);
|
13635 | }
|
13636 |
|
13637 | |
13638 |
|
13639 |
|
13640 |
|
13641 |
|
13642 |
|
13643 |
|
13644 |
|
13645 |
|
13646 |
|
13647 |
|
13648 |
|
13649 |
|
13650 |
|
13651 |
|
13652 |
|
13653 |
|
13654 |
|
13655 | function unzip(array) {
|
13656 | if (!(array && array.length)) {
|
13657 | return [];
|
13658 | }
|
13659 | var index = -1,
|
13660 | length = 0;
|
13661 |
|
13662 | array = arrayFilter(array, function(group) {
|
13663 | if (isArrayLike(group)) {
|
13664 | length = nativeMax(group.length, length);
|
13665 | return true;
|
13666 | }
|
13667 | });
|
13668 | var result = Array(length);
|
13669 | while (++index < length) {
|
13670 | result[index] = arrayMap(array, baseProperty(index));
|
13671 | }
|
13672 | return result;
|
13673 | }
|
13674 |
|
13675 | |
13676 |
|
13677 |
|
13678 |
|
13679 |
|
13680 |
|
13681 |
|
13682 |
|
13683 |
|
13684 |
|
13685 |
|
13686 |
|
13687 |
|
13688 |
|
13689 |
|
13690 |
|
13691 |
|
13692 |
|
13693 |
|
13694 |
|
13695 | function unzipWith(array, iteratee, thisArg) {
|
13696 | var length = array ? array.length : 0;
|
13697 | if (!length) {
|
13698 | return [];
|
13699 | }
|
13700 | var result = unzip(array);
|
13701 | if (iteratee == null) {
|
13702 | return result;
|
13703 | }
|
13704 | iteratee = bindCallback(iteratee, thisArg, 4);
|
13705 | return arrayMap(result, function(group) {
|
13706 | return arrayReduce(group, iteratee, undefined, true);
|
13707 | });
|
13708 | }
|
13709 |
|
13710 | |
13711 |
|
13712 |
|
13713 |
|
13714 |
|
13715 |
|
13716 |
|
13717 |
|
13718 |
|
13719 |
|
13720 |
|
13721 |
|
13722 |
|
13723 |
|
13724 |
|
13725 |
|
13726 | var without = restParam(function(array, values) {
|
13727 | return isArrayLike(array)
|
13728 | ? baseDifference(array, values)
|
13729 | : [];
|
13730 | });
|
13731 |
|
13732 | |
13733 |
|
13734 |
|
13735 |
|
13736 |
|
13737 |
|
13738 |
|
13739 |
|
13740 |
|
13741 |
|
13742 |
|
13743 |
|
13744 |
|
13745 |
|
13746 | function xor() {
|
13747 | var index = -1,
|
13748 | length = arguments.length;
|
13749 |
|
13750 | while (++index < length) {
|
13751 | var array = arguments[index];
|
13752 | if (isArrayLike(array)) {
|
13753 | var result = result
|
13754 | ? arrayPush(baseDifference(result, array), baseDifference(array, result))
|
13755 | : array;
|
13756 | }
|
13757 | }
|
13758 | return result ? baseUniq(result) : [];
|
13759 | }
|
13760 |
|
13761 | |
13762 |
|
13763 |
|
13764 |
|
13765 |
|
13766 |
|
13767 |
|
13768 |
|
13769 |
|
13770 |
|
13771 |
|
13772 |
|
13773 |
|
13774 |
|
13775 |
|
13776 | var zip = restParam(unzip);
|
13777 |
|
13778 | |
13779 |
|
13780 |
|
13781 |
|
13782 |
|
13783 |
|
13784 |
|
13785 |
|
13786 |
|
13787 |
|
13788 |
|
13789 |
|
13790 |
|
13791 |
|
13792 |
|
13793 |
|
13794 |
|
13795 |
|
13796 |
|
13797 |
|
13798 |
|
13799 | function zipObject(props, values) {
|
13800 | var index = -1,
|
13801 | length = props ? props.length : 0,
|
13802 | result = {};
|
13803 |
|
13804 | if (length && !values && !isArray(props[0])) {
|
13805 | values = [];
|
13806 | }
|
13807 | while (++index < length) {
|
13808 | var key = props[index];
|
13809 | if (values) {
|
13810 | result[key] = values[index];
|
13811 | } else if (key) {
|
13812 | result[key[0]] = key[1];
|
13813 | }
|
13814 | }
|
13815 | return result;
|
13816 | }
|
13817 |
|
13818 | |
13819 |
|
13820 |
|
13821 |
|
13822 |
|
13823 |
|
13824 |
|
13825 |
|
13826 |
|
13827 |
|
13828 |
|
13829 |
|
13830 |
|
13831 |
|
13832 |
|
13833 |
|
13834 |
|
13835 | var zipWith = restParam(function(arrays) {
|
13836 | var length = arrays.length,
|
13837 | iteratee = length > 2 ? arrays[length - 2] : undefined,
|
13838 | thisArg = length > 1 ? arrays[length - 1] : undefined;
|
13839 |
|
13840 | if (length > 2 && typeof iteratee == 'function') {
|
13841 | length -= 2;
|
13842 | } else {
|
13843 | iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined;
|
13844 | thisArg = undefined;
|
13845 | }
|
13846 | arrays.length = length;
|
13847 | return unzipWith(arrays, iteratee, thisArg);
|
13848 | });
|
13849 |
|
13850 |
|
13851 |
|
13852 | |
13853 |
|
13854 |
|
13855 |
|
13856 |
|
13857 |
|
13858 |
|
13859 |
|
13860 |
|
13861 |
|
13862 |
|
13863 |
|
13864 |
|
13865 |
|
13866 |
|
13867 |
|
13868 |
|
13869 |
|
13870 |
|
13871 |
|
13872 |
|
13873 |
|
13874 |
|
13875 |
|
13876 |
|
13877 |
|
13878 | function chain(value) {
|
13879 | var result = lodash(value);
|
13880 | result.__chain__ = true;
|
13881 | return result;
|
13882 | }
|
13883 |
|
13884 | |
13885 |
|
13886 |
|
13887 |
|
13888 |
|
13889 |
|
13890 |
|
13891 |
|
13892 |
|
13893 |
|
13894 |
|
13895 |
|
13896 |
|
13897 |
|
13898 |
|
13899 |
|
13900 |
|
13901 |
|
13902 |
|
13903 |
|
13904 |
|
13905 |
|
13906 |
|
13907 | function tap(value, interceptor, thisArg) {
|
13908 | interceptor.call(thisArg, value);
|
13909 | return value;
|
13910 | }
|
13911 |
|
13912 | |
13913 |
|
13914 |
|
13915 |
|
13916 |
|
13917 |
|
13918 |
|
13919 |
|
13920 |
|
13921 |
|
13922 |
|
13923 |
|
13924 |
|
13925 |
|
13926 |
|
13927 |
|
13928 |
|
13929 |
|
13930 |
|
13931 |
|
13932 |
|
13933 | function thru(value, interceptor, thisArg) {
|
13934 | return interceptor.call(thisArg, value);
|
13935 | }
|
13936 |
|
13937 | |
13938 |
|
13939 |
|
13940 |
|
13941 |
|
13942 |
|
13943 |
|
13944 |
|
13945 |
|
13946 |
|
13947 |
|
13948 |
|
13949 |
|
13950 |
|
13951 |
|
13952 |
|
13953 |
|
13954 |
|
13955 |
|
13956 |
|
13957 |
|
13958 |
|
13959 |
|
13960 |
|
13961 |
|
13962 | function wrapperChain() {
|
13963 | return chain(this);
|
13964 | }
|
13965 |
|
13966 | |
13967 |
|
13968 |
|
13969 |
|
13970 |
|
13971 |
|
13972 |
|
13973 |
|
13974 |
|
13975 |
|
13976 |
|
13977 |
|
13978 |
|
13979 |
|
13980 |
|
13981 |
|
13982 |
|
13983 |
|
13984 |
|
13985 |
|
13986 |
|
13987 |
|
13988 |
|
13989 |
|
13990 |
|
13991 | function wrapperCommit() {
|
13992 | return new LodashWrapper(this.value(), this.__chain__);
|
13993 | }
|
13994 |
|
13995 | |
13996 |
|
13997 |
|
13998 |
|
13999 |
|
14000 |
|
14001 |
|
14002 |
|
14003 |
|
14004 |
|
14005 |
|
14006 |
|
14007 |
|
14008 |
|
14009 |
|
14010 |
|
14011 |
|
14012 |
|
14013 |
|
14014 |
|
14015 | var wrapperConcat = restParam(function(values) {
|
14016 | values = baseFlatten(values);
|
14017 | return this.thru(function(array) {
|
14018 | return arrayConcat(isArray(array) ? array : [toObject(array)], values);
|
14019 | });
|
14020 | });
|
14021 |
|
14022 | |
14023 |
|
14024 |
|
14025 |
|
14026 |
|
14027 |
|
14028 |
|
14029 |
|
14030 |
|
14031 |
|
14032 |
|
14033 |
|
14034 |
|
14035 |
|
14036 |
|
14037 |
|
14038 |
|
14039 |
|
14040 |
|
14041 |
|
14042 |
|
14043 |
|
14044 |
|
14045 | function wrapperPlant(value) {
|
14046 | var result,
|
14047 | parent = this;
|
14048 |
|
14049 | while (parent instanceof baseLodash) {
|
14050 | var clone = wrapperClone(parent);
|
14051 | if (result) {
|
14052 | previous.__wrapped__ = clone;
|
14053 | } else {
|
14054 | result = clone;
|
14055 | }
|
14056 | var previous = clone;
|
14057 | parent = parent.__wrapped__;
|
14058 | }
|
14059 | previous.__wrapped__ = value;
|
14060 | return result;
|
14061 | }
|
14062 |
|
14063 | |
14064 |
|
14065 |
|
14066 |
|
14067 |
|
14068 |
|
14069 |
|
14070 |
|
14071 |
|
14072 |
|
14073 |
|
14074 |
|
14075 |
|
14076 |
|
14077 |
|
14078 |
|
14079 |
|
14080 |
|
14081 |
|
14082 |
|
14083 | function wrapperReverse() {
|
14084 | var value = this.__wrapped__;
|
14085 |
|
14086 | var interceptor = function(value) {
|
14087 | return (wrapped && wrapped.__dir__ < 0) ? value : value.reverse();
|
14088 | };
|
14089 | if (value instanceof LazyWrapper) {
|
14090 | var wrapped = value;
|
14091 | if (this.__actions__.length) {
|
14092 | wrapped = new LazyWrapper(this);
|
14093 | }
|
14094 | wrapped = wrapped.reverse();
|
14095 | wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
|
14096 | return new LodashWrapper(wrapped, this.__chain__);
|
14097 | }
|
14098 | return this.thru(interceptor);
|
14099 | }
|
14100 |
|
14101 | |
14102 |
|
14103 |
|
14104 |
|
14105 |
|
14106 |
|
14107 |
|
14108 |
|
14109 |
|
14110 |
|
14111 |
|
14112 |
|
14113 | function wrapperToString() {
|
14114 | return (this.value() + '');
|
14115 | }
|
14116 |
|
14117 | |
14118 |
|
14119 |
|
14120 |
|
14121 |
|
14122 |
|
14123 |
|
14124 |
|
14125 |
|
14126 |
|
14127 |
|
14128 |
|
14129 |
|
14130 | function wrapperValue() {
|
14131 | return baseWrapperValue(this.__wrapped__, this.__actions__);
|
14132 | }
|
14133 |
|
14134 |
|
14135 |
|
14136 | |
14137 |
|
14138 |
|
14139 |
|
14140 |
|
14141 |
|
14142 |
|
14143 |
|
14144 |
|
14145 |
|
14146 |
|
14147 |
|
14148 |
|
14149 |
|
14150 |
|
14151 |
|
14152 |
|
14153 |
|
14154 |
|
14155 |
|
14156 | var at = restParam(function(collection, props) {
|
14157 | return baseAt(collection, baseFlatten(props));
|
14158 | });
|
14159 |
|
14160 | |
14161 |
|
14162 |
|
14163 |
|
14164 |
|
14165 |
|
14166 |
|
14167 |
|
14168 |
|
14169 |
|
14170 |
|
14171 |
|
14172 |
|
14173 |
|
14174 |
|
14175 |
|
14176 |
|
14177 |
|
14178 |
|
14179 |
|
14180 |
|
14181 |
|
14182 |
|
14183 |
|
14184 |
|
14185 |
|
14186 |
|
14187 |
|
14188 |
|
14189 |
|
14190 |
|
14191 |
|
14192 |
|
14193 |
|
14194 |
|
14195 |
|
14196 |
|
14197 |
|
14198 |
|
14199 |
|
14200 |
|
14201 | var countBy = createAggregator(function(result, value, key) {
|
14202 | hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);
|
14203 | });
|
14204 |
|
14205 | |
14206 |
|
14207 |
|
14208 |
|
14209 |
|
14210 |
|
14211 |
|
14212 |
|
14213 |
|
14214 |
|
14215 |
|
14216 |
|
14217 |
|
14218 |
|
14219 |
|
14220 |
|
14221 |
|
14222 |
|
14223 |
|
14224 |
|
14225 |
|
14226 |
|
14227 |
|
14228 |
|
14229 |
|
14230 |
|
14231 |
|
14232 |
|
14233 |
|
14234 |
|
14235 |
|
14236 |
|
14237 |
|
14238 |
|
14239 |
|
14240 |
|
14241 |
|
14242 |
|
14243 |
|
14244 |
|
14245 |
|
14246 |
|
14247 |
|
14248 |
|
14249 |
|
14250 |
|
14251 |
|
14252 |
|
14253 | function every(collection, predicate, thisArg) {
|
14254 | var func = isArray(collection) ? arrayEvery : baseEvery;
|
14255 | if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
14256 | predicate = undefined;
|
14257 | }
|
14258 | if (typeof predicate != 'function' || thisArg !== undefined) {
|
14259 | predicate = getCallback(predicate, thisArg, 3);
|
14260 | }
|
14261 | return func(collection, predicate);
|
14262 | }
|
14263 |
|
14264 | |
14265 |
|
14266 |
|
14267 |
|
14268 |
|
14269 |
|
14270 |
|
14271 |
|
14272 |
|
14273 |
|
14274 |
|
14275 |
|
14276 |
|
14277 |
|
14278 |
|
14279 |
|
14280 |
|
14281 |
|
14282 |
|
14283 |
|
14284 |
|
14285 |
|
14286 |
|
14287 |
|
14288 |
|
14289 |
|
14290 |
|
14291 |
|
14292 |
|
14293 |
|
14294 |
|
14295 |
|
14296 |
|
14297 |
|
14298 |
|
14299 |
|
14300 |
|
14301 |
|
14302 |
|
14303 |
|
14304 |
|
14305 |
|
14306 |
|
14307 |
|
14308 |
|
14309 |
|
14310 |
|
14311 |
|
14312 |
|
14313 | function filter(collection, predicate, thisArg) {
|
14314 | var func = isArray(collection) ? arrayFilter : baseFilter;
|
14315 | predicate = getCallback(predicate, thisArg, 3);
|
14316 | return func(collection, predicate);
|
14317 | }
|
14318 |
|
14319 | |
14320 |
|
14321 |
|
14322 |
|
14323 |
|
14324 |
|
14325 |
|
14326 |
|
14327 |
|
14328 |
|
14329 |
|
14330 |
|
14331 |
|
14332 |
|
14333 |
|
14334 |
|
14335 |
|
14336 |
|
14337 |
|
14338 |
|
14339 |
|
14340 |
|
14341 |
|
14342 |
|
14343 |
|
14344 |
|
14345 |
|
14346 |
|
14347 |
|
14348 |
|
14349 |
|
14350 |
|
14351 |
|
14352 |
|
14353 |
|
14354 |
|
14355 |
|
14356 |
|
14357 |
|
14358 |
|
14359 |
|
14360 |
|
14361 |
|
14362 |
|
14363 |
|
14364 |
|
14365 |
|
14366 |
|
14367 |
|
14368 |
|
14369 | var find = createFind(baseEach);
|
14370 |
|
14371 | |
14372 |
|
14373 |
|
14374 |
|
14375 |
|
14376 |
|
14377 |
|
14378 |
|
14379 |
|
14380 |
|
14381 |
|
14382 |
|
14383 |
|
14384 |
|
14385 |
|
14386 |
|
14387 |
|
14388 |
|
14389 |
|
14390 | var findLast = createFind(baseEachRight, true);
|
14391 |
|
14392 | |
14393 |
|
14394 |
|
14395 |
|
14396 |
|
14397 |
|
14398 |
|
14399 |
|
14400 |
|
14401 |
|
14402 |
|
14403 |
|
14404 |
|
14405 |
|
14406 |
|
14407 |
|
14408 |
|
14409 |
|
14410 |
|
14411 |
|
14412 |
|
14413 |
|
14414 |
|
14415 |
|
14416 |
|
14417 |
|
14418 |
|
14419 |
|
14420 |
|
14421 | function findWhere(collection, source) {
|
14422 | return find(collection, baseMatches(source));
|
14423 | }
|
14424 |
|
14425 | |
14426 |
|
14427 |
|
14428 |
|
14429 |
|
14430 |
|
14431 |
|
14432 |
|
14433 |
|
14434 |
|
14435 |
|
14436 |
|
14437 |
|
14438 |
|
14439 |
|
14440 |
|
14441 |
|
14442 |
|
14443 |
|
14444 |
|
14445 |
|
14446 |
|
14447 |
|
14448 |
|
14449 |
|
14450 |
|
14451 |
|
14452 |
|
14453 |
|
14454 |
|
14455 | var forEach = createForEach(arrayEach, baseEach);
|
14456 |
|
14457 | |
14458 |
|
14459 |
|
14460 |
|
14461 |
|
14462 |
|
14463 |
|
14464 |
|
14465 |
|
14466 |
|
14467 |
|
14468 |
|
14469 |
|
14470 |
|
14471 |
|
14472 |
|
14473 |
|
14474 |
|
14475 |
|
14476 | var forEachRight = createForEach(arrayEachRight, baseEachRight);
|
14477 |
|
14478 | |
14479 |
|
14480 |
|
14481 |
|
14482 |
|
14483 |
|
14484 |
|
14485 |
|
14486 |
|
14487 |
|
14488 |
|
14489 |
|
14490 |
|
14491 |
|
14492 |
|
14493 |
|
14494 |
|
14495 |
|
14496 |
|
14497 |
|
14498 |
|
14499 |
|
14500 |
|
14501 |
|
14502 |
|
14503 |
|
14504 |
|
14505 |
|
14506 |
|
14507 |
|
14508 |
|
14509 |
|
14510 |
|
14511 |
|
14512 |
|
14513 |
|
14514 |
|
14515 |
|
14516 |
|
14517 |
|
14518 |
|
14519 |
|
14520 | var groupBy = createAggregator(function(result, value, key) {
|
14521 | if (hasOwnProperty.call(result, key)) {
|
14522 | result[key].push(value);
|
14523 | } else {
|
14524 | result[key] = [value];
|
14525 | }
|
14526 | });
|
14527 |
|
14528 | |
14529 |
|
14530 |
|
14531 |
|
14532 |
|
14533 |
|
14534 |
|
14535 |
|
14536 |
|
14537 |
|
14538 |
|
14539 |
|
14540 |
|
14541 |
|
14542 |
|
14543 |
|
14544 |
|
14545 |
|
14546 |
|
14547 |
|
14548 |
|
14549 |
|
14550 |
|
14551 |
|
14552 |
|
14553 |
|
14554 |
|
14555 |
|
14556 |
|
14557 | function includes(collection, target, fromIndex, guard) {
|
14558 | var length = collection ? getLength(collection) : 0;
|
14559 | if (!isLength(length)) {
|
14560 | collection = values(collection);
|
14561 | length = collection.length;
|
14562 | }
|
14563 | if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
|
14564 | fromIndex = 0;
|
14565 | } else {
|
14566 | fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
|
14567 | }
|
14568 | return (typeof collection == 'string' || !isArray(collection) && isString(collection))
|
14569 | ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1)
|
14570 | : (!!length && getIndexOf(collection, target, fromIndex) > -1);
|
14571 | }
|
14572 |
|
14573 | |
14574 |
|
14575 |
|
14576 |
|
14577 |
|
14578 |
|
14579 |
|
14580 |
|
14581 |
|
14582 |
|
14583 |
|
14584 |
|
14585 |
|
14586 |
|
14587 |
|
14588 |
|
14589 |
|
14590 |
|
14591 |
|
14592 |
|
14593 |
|
14594 |
|
14595 |
|
14596 |
|
14597 |
|
14598 |
|
14599 |
|
14600 |
|
14601 |
|
14602 |
|
14603 |
|
14604 |
|
14605 |
|
14606 |
|
14607 |
|
14608 |
|
14609 |
|
14610 |
|
14611 |
|
14612 |
|
14613 |
|
14614 |
|
14615 |
|
14616 |
|
14617 |
|
14618 |
|
14619 | var indexBy = createAggregator(function(result, value, key) {
|
14620 | result[key] = value;
|
14621 | });
|
14622 |
|
14623 | |
14624 |
|
14625 |
|
14626 |
|
14627 |
|
14628 |
|
14629 |
|
14630 |
|
14631 |
|
14632 |
|
14633 |
|
14634 |
|
14635 |
|
14636 |
|
14637 |
|
14638 |
|
14639 |
|
14640 |
|
14641 |
|
14642 |
|
14643 |
|
14644 |
|
14645 | var invoke = restParam(function(collection, path, args) {
|
14646 | var index = -1,
|
14647 | isFunc = typeof path == 'function',
|
14648 | isProp = isKey(path),
|
14649 | result = isArrayLike(collection) ? Array(collection.length) : [];
|
14650 |
|
14651 | baseEach(collection, function(value) {
|
14652 | var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
|
14653 | result[++index] = func ? func.apply(value, args) : invokePath(value, path, args);
|
14654 | });
|
14655 | return result;
|
14656 | });
|
14657 |
|
14658 | |
14659 |
|
14660 |
|
14661 |
|
14662 |
|
14663 |
|
14664 |
|
14665 |
|
14666 |
|
14667 |
|
14668 |
|
14669 |
|
14670 |
|
14671 |
|
14672 |
|
14673 |
|
14674 |
|
14675 |
|
14676 |
|
14677 |
|
14678 |
|
14679 |
|
14680 |
|
14681 |
|
14682 |
|
14683 |
|
14684 |
|
14685 |
|
14686 |
|
14687 |
|
14688 |
|
14689 |
|
14690 |
|
14691 |
|
14692 |
|
14693 |
|
14694 |
|
14695 |
|
14696 |
|
14697 |
|
14698 |
|
14699 |
|
14700 |
|
14701 |
|
14702 |
|
14703 |
|
14704 |
|
14705 |
|
14706 |
|
14707 |
|
14708 |
|
14709 |
|
14710 |
|
14711 |
|
14712 |
|
14713 |
|
14714 | function map(collection, iteratee, thisArg) {
|
14715 | var func = isArray(collection) ? arrayMap : baseMap;
|
14716 | iteratee = getCallback(iteratee, thisArg, 3);
|
14717 | return func(collection, iteratee);
|
14718 | }
|
14719 |
|
14720 | |
14721 |
|
14722 |
|
14723 |
|
14724 |
|
14725 |
|
14726 |
|
14727 |
|
14728 |
|
14729 |
|
14730 |
|
14731 |
|
14732 |
|
14733 |
|
14734 |
|
14735 |
|
14736 |
|
14737 |
|
14738 |
|
14739 |
|
14740 |
|
14741 |
|
14742 |
|
14743 |
|
14744 |
|
14745 |
|
14746 |
|
14747 |
|
14748 |
|
14749 |
|
14750 |
|
14751 |
|
14752 |
|
14753 |
|
14754 |
|
14755 |
|
14756 |
|
14757 |
|
14758 |
|
14759 |
|
14760 |
|
14761 |
|
14762 |
|
14763 |
|
14764 |
|
14765 |
|
14766 |
|
14767 |
|
14768 |
|
14769 |
|
14770 |
|
14771 |
|
14772 |
|
14773 |
|
14774 |
|
14775 |
|
14776 |
|
14777 |
|
14778 |
|
14779 | var partition = createAggregator(function(result, value, key) {
|
14780 | result[key ? 0 : 1].push(value);
|
14781 | }, function() { return [[], []]; });
|
14782 |
|
14783 | |
14784 |
|
14785 |
|
14786 |
|
14787 |
|
14788 |
|
14789 |
|
14790 |
|
14791 |
|
14792 |
|
14793 |
|
14794 |
|
14795 |
|
14796 |
|
14797 |
|
14798 |
|
14799 |
|
14800 |
|
14801 |
|
14802 |
|
14803 |
|
14804 |
|
14805 |
|
14806 | function pluck(collection, path) {
|
14807 | return map(collection, property(path));
|
14808 | }
|
14809 |
|
14810 | |
14811 |
|
14812 |
|
14813 |
|
14814 |
|
14815 |
|
14816 |
|
14817 |
|
14818 |
|
14819 |
|
14820 |
|
14821 |
|
14822 |
|
14823 |
|
14824 |
|
14825 |
|
14826 |
|
14827 |
|
14828 |
|
14829 |
|
14830 |
|
14831 |
|
14832 |
|
14833 |
|
14834 |
|
14835 |
|
14836 |
|
14837 |
|
14838 |
|
14839 |
|
14840 |
|
14841 |
|
14842 |
|
14843 |
|
14844 |
|
14845 |
|
14846 |
|
14847 | var reduce = createReduce(arrayReduce, baseEach);
|
14848 |
|
14849 | |
14850 |
|
14851 |
|
14852 |
|
14853 |
|
14854 |
|
14855 |
|
14856 |
|
14857 |
|
14858 |
|
14859 |
|
14860 |
|
14861 |
|
14862 |
|
14863 |
|
14864 |
|
14865 |
|
14866 |
|
14867 |
|
14868 |
|
14869 |
|
14870 |
|
14871 | var reduceRight = createReduce(arrayReduceRight, baseEachRight);
|
14872 |
|
14873 | |
14874 |
|
14875 |
|
14876 |
|
14877 |
|
14878 |
|
14879 |
|
14880 |
|
14881 |
|
14882 |
|
14883 |
|
14884 |
|
14885 |
|
14886 |
|
14887 |
|
14888 |
|
14889 |
|
14890 |
|
14891 |
|
14892 |
|
14893 |
|
14894 |
|
14895 |
|
14896 |
|
14897 |
|
14898 |
|
14899 |
|
14900 |
|
14901 |
|
14902 |
|
14903 |
|
14904 |
|
14905 |
|
14906 |
|
14907 |
|
14908 |
|
14909 | function reject(collection, predicate, thisArg) {
|
14910 | var func = isArray(collection) ? arrayFilter : baseFilter;
|
14911 | predicate = getCallback(predicate, thisArg, 3);
|
14912 | return func(collection, function(value, index, collection) {
|
14913 | return !predicate(value, index, collection);
|
14914 | });
|
14915 | }
|
14916 |
|
14917 | |
14918 |
|
14919 |
|
14920 |
|
14921 |
|
14922 |
|
14923 |
|
14924 |
|
14925 |
|
14926 |
|
14927 |
|
14928 |
|
14929 |
|
14930 |
|
14931 |
|
14932 |
|
14933 |
|
14934 |
|
14935 | function sample(collection, n, guard) {
|
14936 | if (guard ? isIterateeCall(collection, n, guard) : n == null) {
|
14937 | collection = toIterable(collection);
|
14938 | var length = collection.length;
|
14939 | return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;
|
14940 | }
|
14941 | var index = -1,
|
14942 | result = toArray(collection),
|
14943 | length = result.length,
|
14944 | lastIndex = length - 1;
|
14945 |
|
14946 | n = nativeMin(n < 0 ? 0 : (+n || 0), length);
|
14947 | while (++index < n) {
|
14948 | var rand = baseRandom(index, lastIndex),
|
14949 | value = result[rand];
|
14950 |
|
14951 | result[rand] = result[index];
|
14952 | result[index] = value;
|
14953 | }
|
14954 | result.length = n;
|
14955 | return result;
|
14956 | }
|
14957 |
|
14958 | |
14959 |
|
14960 |
|
14961 |
|
14962 |
|
14963 |
|
14964 |
|
14965 |
|
14966 |
|
14967 |
|
14968 |
|
14969 |
|
14970 |
|
14971 |
|
14972 | function shuffle(collection) {
|
14973 | return sample(collection, POSITIVE_INFINITY);
|
14974 | }
|
14975 |
|
14976 | |
14977 |
|
14978 |
|
14979 |
|
14980 |
|
14981 |
|
14982 |
|
14983 |
|
14984 |
|
14985 |
|
14986 |
|
14987 |
|
14988 |
|
14989 |
|
14990 |
|
14991 |
|
14992 |
|
14993 |
|
14994 |
|
14995 |
|
14996 | function size(collection) {
|
14997 | var length = collection ? getLength(collection) : 0;
|
14998 | return isLength(length) ? length : keys(collection).length;
|
14999 | }
|
15000 |
|
15001 | |
15002 |
|
15003 |
|
15004 |
|
15005 |
|
15006 |
|
15007 |
|
15008 |
|
15009 |
|
15010 |
|
15011 |
|
15012 |
|
15013 |
|
15014 |
|
15015 |
|
15016 |
|
15017 |
|
15018 |
|
15019 |
|
15020 |
|
15021 |
|
15022 |
|
15023 |
|
15024 |
|
15025 |
|
15026 |
|
15027 |
|
15028 |
|
15029 |
|
15030 |
|
15031 |
|
15032 |
|
15033 |
|
15034 |
|
15035 |
|
15036 |
|
15037 |
|
15038 |
|
15039 |
|
15040 |
|
15041 |
|
15042 |
|
15043 |
|
15044 |
|
15045 |
|
15046 |
|
15047 |
|
15048 |
|
15049 |
|
15050 | function some(collection, predicate, thisArg) {
|
15051 | var func = isArray(collection) ? arraySome : baseSome;
|
15052 | if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
|
15053 | predicate = undefined;
|
15054 | }
|
15055 | if (typeof predicate != 'function' || thisArg !== undefined) {
|
15056 | predicate = getCallback(predicate, thisArg, 3);
|
15057 | }
|
15058 | return func(collection, predicate);
|
15059 | }
|
15060 |
|
15061 | |
15062 |
|
15063 |
|
15064 |
|
15065 |
|
15066 |
|
15067 |
|
15068 |
|
15069 |
|
15070 |
|
15071 |
|
15072 |
|
15073 |
|
15074 |
|
15075 |
|
15076 |
|
15077 |
|
15078 |
|
15079 |
|
15080 |
|
15081 |
|
15082 |
|
15083 |
|
15084 |
|
15085 |
|
15086 |
|
15087 |
|
15088 |
|
15089 |
|
15090 |
|
15091 |
|
15092 |
|
15093 |
|
15094 |
|
15095 |
|
15096 |
|
15097 |
|
15098 |
|
15099 |
|
15100 |
|
15101 |
|
15102 |
|
15103 |
|
15104 |
|
15105 |
|
15106 |
|
15107 |
|
15108 |
|
15109 | function sortBy(collection, iteratee, thisArg) {
|
15110 | if (collection == null) {
|
15111 | return [];
|
15112 | }
|
15113 | if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
15114 | iteratee = undefined;
|
15115 | }
|
15116 | var index = -1;
|
15117 | iteratee = getCallback(iteratee, thisArg, 3);
|
15118 |
|
15119 | var result = baseMap(collection, function(value, key, collection) {
|
15120 | return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value };
|
15121 | });
|
15122 | return baseSortBy(result, compareAscending);
|
15123 | }
|
15124 |
|
15125 | |
15126 |
|
15127 |
|
15128 |
|
15129 |
|
15130 |
|
15131 |
|
15132 |
|
15133 |
|
15134 |
|
15135 |
|
15136 |
|
15137 |
|
15138 |
|
15139 |
|
15140 |
|
15141 |
|
15142 |
|
15143 |
|
15144 |
|
15145 |
|
15146 |
|
15147 |
|
15148 |
|
15149 |
|
15150 |
|
15151 |
|
15152 |
|
15153 |
|
15154 |
|
15155 |
|
15156 |
|
15157 |
|
15158 |
|
15159 |
|
15160 | var sortByAll = restParam(function(collection, iteratees) {
|
15161 | if (collection == null) {
|
15162 | return [];
|
15163 | }
|
15164 | var guard = iteratees[2];
|
15165 | if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) {
|
15166 | iteratees.length = 1;
|
15167 | }
|
15168 | return baseSortByOrder(collection, baseFlatten(iteratees), []);
|
15169 | });
|
15170 |
|
15171 | |
15172 |
|
15173 |
|
15174 |
|
15175 |
|
15176 |
|
15177 |
|
15178 |
|
15179 |
|
15180 |
|
15181 |
|
15182 |
|
15183 |
|
15184 |
|
15185 |
|
15186 |
|
15187 |
|
15188 |
|
15189 |
|
15190 |
|
15191 |
|
15192 |
|
15193 |
|
15194 |
|
15195 |
|
15196 |
|
15197 |
|
15198 |
|
15199 |
|
15200 |
|
15201 |
|
15202 |
|
15203 |
|
15204 |
|
15205 | function sortByOrder(collection, iteratees, orders, guard) {
|
15206 | if (collection == null) {
|
15207 | return [];
|
15208 | }
|
15209 | if (guard && isIterateeCall(iteratees, orders, guard)) {
|
15210 | orders = undefined;
|
15211 | }
|
15212 | if (!isArray(iteratees)) {
|
15213 | iteratees = iteratees == null ? [] : [iteratees];
|
15214 | }
|
15215 | if (!isArray(orders)) {
|
15216 | orders = orders == null ? [] : [orders];
|
15217 | }
|
15218 | return baseSortByOrder(collection, iteratees, orders);
|
15219 | }
|
15220 |
|
15221 | |
15222 |
|
15223 |
|
15224 |
|
15225 |
|
15226 |
|
15227 |
|
15228 |
|
15229 |
|
15230 |
|
15231 |
|
15232 |
|
15233 |
|
15234 |
|
15235 |
|
15236 |
|
15237 |
|
15238 |
|
15239 |
|
15240 |
|
15241 |
|
15242 |
|
15243 |
|
15244 |
|
15245 |
|
15246 |
|
15247 |
|
15248 |
|
15249 |
|
15250 | function where(collection, source) {
|
15251 | return filter(collection, baseMatches(source));
|
15252 | }
|
15253 |
|
15254 |
|
15255 |
|
15256 | |
15257 |
|
15258 |
|
15259 |
|
15260 |
|
15261 |
|
15262 |
|
15263 |
|
15264 |
|
15265 |
|
15266 |
|
15267 |
|
15268 |
|
15269 |
|
15270 | var now = nativeNow || function() {
|
15271 | return new Date().getTime();
|
15272 | };
|
15273 |
|
15274 |
|
15275 |
|
15276 | |
15277 |
|
15278 |
|
15279 |
|
15280 |
|
15281 |
|
15282 |
|
15283 |
|
15284 |
|
15285 |
|
15286 |
|
15287 |
|
15288 |
|
15289 |
|
15290 |
|
15291 |
|
15292 |
|
15293 |
|
15294 |
|
15295 |
|
15296 |
|
15297 |
|
15298 |
|
15299 | function after(n, func) {
|
15300 | if (typeof func != 'function') {
|
15301 | if (typeof n == 'function') {
|
15302 | var temp = n;
|
15303 | n = func;
|
15304 | func = temp;
|
15305 | } else {
|
15306 | throw new TypeError(FUNC_ERROR_TEXT);
|
15307 | }
|
15308 | }
|
15309 | n = nativeIsFinite(n = +n) ? n : 0;
|
15310 | return function() {
|
15311 | if (--n < 1) {
|
15312 | return func.apply(this, arguments);
|
15313 | }
|
15314 | };
|
15315 | }
|
15316 |
|
15317 | |
15318 |
|
15319 |
|
15320 |
|
15321 |
|
15322 |
|
15323 |
|
15324 |
|
15325 |
|
15326 |
|
15327 |
|
15328 |
|
15329 |
|
15330 |
|
15331 |
|
15332 |
|
15333 | function ary(func, n, guard) {
|
15334 | if (guard && isIterateeCall(func, n, guard)) {
|
15335 | n = undefined;
|
15336 | }
|
15337 | n = (func && n == null) ? func.length : nativeMax(+n || 0, 0);
|
15338 | return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
|
15339 | }
|
15340 |
|
15341 | |
15342 |
|
15343 |
|
15344 |
|
15345 |
|
15346 |
|
15347 |
|
15348 |
|
15349 |
|
15350 |
|
15351 |
|
15352 |
|
15353 |
|
15354 |
|
15355 |
|
15356 |
|
15357 | function before(n, func) {
|
15358 | var result;
|
15359 | if (typeof func != 'function') {
|
15360 | if (typeof n == 'function') {
|
15361 | var temp = n;
|
15362 | n = func;
|
15363 | func = temp;
|
15364 | } else {
|
15365 | throw new TypeError(FUNC_ERROR_TEXT);
|
15366 | }
|
15367 | }
|
15368 | return function() {
|
15369 | if (--n > 0) {
|
15370 | result = func.apply(this, arguments);
|
15371 | }
|
15372 | if (n <= 1) {
|
15373 | func = undefined;
|
15374 | }
|
15375 | return result;
|
15376 | };
|
15377 | }
|
15378 |
|
15379 | |
15380 |
|
15381 |
|
15382 |
|
15383 |
|
15384 |
|
15385 |
|
15386 |
|
15387 |
|
15388 |
|
15389 |
|
15390 |
|
15391 |
|
15392 |
|
15393 |
|
15394 |
|
15395 |
|
15396 |
|
15397 |
|
15398 |
|
15399 |
|
15400 |
|
15401 |
|
15402 |
|
15403 |
|
15404 |
|
15405 |
|
15406 |
|
15407 |
|
15408 |
|
15409 |
|
15410 |
|
15411 |
|
15412 |
|
15413 |
|
15414 | var bind = restParam(function(func, thisArg, partials) {
|
15415 | var bitmask = BIND_FLAG;
|
15416 | if (partials.length) {
|
15417 | var holders = replaceHolders(partials, bind.placeholder);
|
15418 | bitmask |= PARTIAL_FLAG;
|
15419 | }
|
15420 | return createWrapper(func, bitmask, thisArg, partials, holders);
|
15421 | });
|
15422 |
|
15423 | |
15424 |
|
15425 |
|
15426 |
|
15427 |
|
15428 |
|
15429 |
|
15430 |
|
15431 |
|
15432 |
|
15433 |
|
15434 |
|
15435 |
|
15436 |
|
15437 |
|
15438 |
|
15439 |
|
15440 |
|
15441 |
|
15442 |
|
15443 |
|
15444 |
|
15445 |
|
15446 |
|
15447 |
|
15448 |
|
15449 |
|
15450 |
|
15451 | var bindAll = restParam(function(object, methodNames) {
|
15452 | methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object);
|
15453 |
|
15454 | var index = -1,
|
15455 | length = methodNames.length;
|
15456 |
|
15457 | while (++index < length) {
|
15458 | var key = methodNames[index];
|
15459 | object[key] = createWrapper(object[key], BIND_FLAG, object);
|
15460 | }
|
15461 | return object;
|
15462 | });
|
15463 |
|
15464 | |
15465 |
|
15466 |
|
15467 |
|
15468 |
|
15469 |
|
15470 |
|
15471 |
|
15472 |
|
15473 |
|
15474 |
|
15475 |
|
15476 |
|
15477 |
|
15478 |
|
15479 |
|
15480 |
|
15481 |
|
15482 |
|
15483 |
|
15484 |
|
15485 |
|
15486 |
|
15487 |
|
15488 |
|
15489 |
|
15490 |
|
15491 |
|
15492 |
|
15493 |
|
15494 |
|
15495 |
|
15496 |
|
15497 |
|
15498 |
|
15499 |
|
15500 |
|
15501 |
|
15502 |
|
15503 |
|
15504 |
|
15505 |
|
15506 |
|
15507 |
|
15508 | var bindKey = restParam(function(object, key, partials) {
|
15509 | var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
15510 | if (partials.length) {
|
15511 | var holders = replaceHolders(partials, bindKey.placeholder);
|
15512 | bitmask |= PARTIAL_FLAG;
|
15513 | }
|
15514 | return createWrapper(key, bitmask, object, partials, holders);
|
15515 | });
|
15516 |
|
15517 | |
15518 |
|
15519 |
|
15520 |
|
15521 |
|
15522 |
|
15523 |
|
15524 |
|
15525 |
|
15526 |
|
15527 |
|
15528 |
|
15529 |
|
15530 |
|
15531 |
|
15532 |
|
15533 |
|
15534 |
|
15535 |
|
15536 |
|
15537 |
|
15538 |
|
15539 |
|
15540 |
|
15541 |
|
15542 |
|
15543 |
|
15544 |
|
15545 |
|
15546 |
|
15547 |
|
15548 |
|
15549 |
|
15550 |
|
15551 |
|
15552 |
|
15553 |
|
15554 |
|
15555 |
|
15556 |
|
15557 | var curry = createCurry(CURRY_FLAG);
|
15558 |
|
15559 | |
15560 |
|
15561 |
|
15562 |
|
15563 |
|
15564 |
|
15565 |
|
15566 |
|
15567 |
|
15568 |
|
15569 |
|
15570 |
|
15571 |
|
15572 |
|
15573 |
|
15574 |
|
15575 |
|
15576 |
|
15577 |
|
15578 |
|
15579 |
|
15580 |
|
15581 |
|
15582 |
|
15583 |
|
15584 |
|
15585 |
|
15586 |
|
15587 |
|
15588 |
|
15589 |
|
15590 |
|
15591 |
|
15592 |
|
15593 |
|
15594 |
|
15595 |
|
15596 | var curryRight = createCurry(CURRY_RIGHT_FLAG);
|
15597 |
|
15598 | |
15599 |
|
15600 |
|
15601 |
|
15602 |
|
15603 |
|
15604 |
|
15605 |
|
15606 |
|
15607 |
|
15608 |
|
15609 |
|
15610 |
|
15611 |
|
15612 |
|
15613 |
|
15614 |
|
15615 |
|
15616 |
|
15617 |
|
15618 |
|
15619 |
|
15620 |
|
15621 |
|
15622 |
|
15623 |
|
15624 |
|
15625 |
|
15626 |
|
15627 |
|
15628 |
|
15629 |
|
15630 |
|
15631 |
|
15632 |
|
15633 |
|
15634 |
|
15635 |
|
15636 |
|
15637 |
|
15638 |
|
15639 |
|
15640 |
|
15641 |
|
15642 |
|
15643 |
|
15644 |
|
15645 |
|
15646 |
|
15647 |
|
15648 |
|
15649 |
|
15650 |
|
15651 |
|
15652 |
|
15653 |
|
15654 |
|
15655 |
|
15656 |
|
15657 |
|
15658 |
|
15659 |
|
15660 |
|
15661 | function debounce(func, wait, options) {
|
15662 | var args,
|
15663 | maxTimeoutId,
|
15664 | result,
|
15665 | stamp,
|
15666 | thisArg,
|
15667 | timeoutId,
|
15668 | trailingCall,
|
15669 | lastCalled = 0,
|
15670 | maxWait = false,
|
15671 | trailing = true;
|
15672 |
|
15673 | if (typeof func != 'function') {
|
15674 | throw new TypeError(FUNC_ERROR_TEXT);
|
15675 | }
|
15676 | wait = wait < 0 ? 0 : (+wait || 0);
|
15677 | if (options === true) {
|
15678 | var leading = true;
|
15679 | trailing = false;
|
15680 | } else if (isObject(options)) {
|
15681 | leading = !!options.leading;
|
15682 | maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
|
15683 | trailing = 'trailing' in options ? !!options.trailing : trailing;
|
15684 | }
|
15685 |
|
15686 | function cancel() {
|
15687 | if (timeoutId) {
|
15688 | clearTimeout(timeoutId);
|
15689 | }
|
15690 | if (maxTimeoutId) {
|
15691 | clearTimeout(maxTimeoutId);
|
15692 | }
|
15693 | lastCalled = 0;
|
15694 | maxTimeoutId = timeoutId = trailingCall = undefined;
|
15695 | }
|
15696 |
|
15697 | function complete(isCalled, id) {
|
15698 | if (id) {
|
15699 | clearTimeout(id);
|
15700 | }
|
15701 | maxTimeoutId = timeoutId = trailingCall = undefined;
|
15702 | if (isCalled) {
|
15703 | lastCalled = now();
|
15704 | result = func.apply(thisArg, args);
|
15705 | if (!timeoutId && !maxTimeoutId) {
|
15706 | args = thisArg = undefined;
|
15707 | }
|
15708 | }
|
15709 | }
|
15710 |
|
15711 | function delayed() {
|
15712 | var remaining = wait - (now() - stamp);
|
15713 | if (remaining <= 0 || remaining > wait) {
|
15714 | complete(trailingCall, maxTimeoutId);
|
15715 | } else {
|
15716 | timeoutId = setTimeout(delayed, remaining);
|
15717 | }
|
15718 | }
|
15719 |
|
15720 | function maxDelayed() {
|
15721 | complete(trailing, timeoutId);
|
15722 | }
|
15723 |
|
15724 | function debounced() {
|
15725 | args = arguments;
|
15726 | stamp = now();
|
15727 | thisArg = this;
|
15728 | trailingCall = trailing && (timeoutId || !leading);
|
15729 |
|
15730 | if (maxWait === false) {
|
15731 | var leadingCall = leading && !timeoutId;
|
15732 | } else {
|
15733 | if (!maxTimeoutId && !leading) {
|
15734 | lastCalled = stamp;
|
15735 | }
|
15736 | var remaining = maxWait - (stamp - lastCalled),
|
15737 | isCalled = remaining <= 0 || remaining > maxWait;
|
15738 |
|
15739 | if (isCalled) {
|
15740 | if (maxTimeoutId) {
|
15741 | maxTimeoutId = clearTimeout(maxTimeoutId);
|
15742 | }
|
15743 | lastCalled = stamp;
|
15744 | result = func.apply(thisArg, args);
|
15745 | }
|
15746 | else if (!maxTimeoutId) {
|
15747 | maxTimeoutId = setTimeout(maxDelayed, remaining);
|
15748 | }
|
15749 | }
|
15750 | if (isCalled && timeoutId) {
|
15751 | timeoutId = clearTimeout(timeoutId);
|
15752 | }
|
15753 | else if (!timeoutId && wait !== maxWait) {
|
15754 | timeoutId = setTimeout(delayed, wait);
|
15755 | }
|
15756 | if (leadingCall) {
|
15757 | isCalled = true;
|
15758 | result = func.apply(thisArg, args);
|
15759 | }
|
15760 | if (isCalled && !timeoutId && !maxTimeoutId) {
|
15761 | args = thisArg = undefined;
|
15762 | }
|
15763 | return result;
|
15764 | }
|
15765 | debounced.cancel = cancel;
|
15766 | return debounced;
|
15767 | }
|
15768 |
|
15769 | |
15770 |
|
15771 |
|
15772 |
|
15773 |
|
15774 |
|
15775 |
|
15776 |
|
15777 |
|
15778 |
|
15779 |
|
15780 |
|
15781 |
|
15782 |
|
15783 |
|
15784 |
|
15785 |
|
15786 | var defer = restParam(function(func, args) {
|
15787 | return baseDelay(func, 1, args);
|
15788 | });
|
15789 |
|
15790 | |
15791 |
|
15792 |
|
15793 |
|
15794 |
|
15795 |
|
15796 |
|
15797 |
|
15798 |
|
15799 |
|
15800 |
|
15801 |
|
15802 |
|
15803 |
|
15804 |
|
15805 |
|
15806 |
|
15807 |
|
15808 | var delay = restParam(function(func, wait, args) {
|
15809 | return baseDelay(func, wait, args);
|
15810 | });
|
15811 |
|
15812 | |
15813 |
|
15814 |
|
15815 |
|
15816 |
|
15817 |
|
15818 |
|
15819 |
|
15820 |
|
15821 |
|
15822 |
|
15823 |
|
15824 |
|
15825 |
|
15826 |
|
15827 |
|
15828 |
|
15829 |
|
15830 |
|
15831 |
|
15832 | var flow = createFlow();
|
15833 |
|
15834 | |
15835 |
|
15836 |
|
15837 |
|
15838 |
|
15839 |
|
15840 |
|
15841 |
|
15842 |
|
15843 |
|
15844 |
|
15845 |
|
15846 |
|
15847 |
|
15848 |
|
15849 |
|
15850 |
|
15851 |
|
15852 |
|
15853 |
|
15854 | var flowRight = createFlow(true);
|
15855 |
|
15856 | |
15857 |
|
15858 |
|
15859 |
|
15860 |
|
15861 |
|
15862 |
|
15863 |
|
15864 |
|
15865 |
|
15866 |
|
15867 |
|
15868 |
|
15869 |
|
15870 |
|
15871 |
|
15872 |
|
15873 |
|
15874 |
|
15875 |
|
15876 |
|
15877 |
|
15878 |
|
15879 |
|
15880 |
|
15881 |
|
15882 |
|
15883 |
|
15884 |
|
15885 |
|
15886 |
|
15887 |
|
15888 |
|
15889 |
|
15890 |
|
15891 |
|
15892 |
|
15893 |
|
15894 |
|
15895 |
|
15896 |
|
15897 |
|
15898 |
|
15899 |
|
15900 |
|
15901 |
|
15902 |
|
15903 |
|
15904 |
|
15905 |
|
15906 |
|
15907 | function memoize(func, resolver) {
|
15908 | if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
|
15909 | throw new TypeError(FUNC_ERROR_TEXT);
|
15910 | }
|
15911 | var memoized = function() {
|
15912 | var args = arguments,
|
15913 | key = resolver ? resolver.apply(this, args) : args[0],
|
15914 | cache = memoized.cache;
|
15915 |
|
15916 | if (cache.has(key)) {
|
15917 | return cache.get(key);
|
15918 | }
|
15919 | var result = func.apply(this, args);
|
15920 | memoized.cache = cache.set(key, result);
|
15921 | return result;
|
15922 | };
|
15923 | memoized.cache = new memoize.Cache;
|
15924 | return memoized;
|
15925 | }
|
15926 |
|
15927 | |
15928 |
|
15929 |
|
15930 |
|
15931 |
|
15932 |
|
15933 |
|
15934 |
|
15935 |
|
15936 |
|
15937 |
|
15938 |
|
15939 |
|
15940 |
|
15941 |
|
15942 |
|
15943 |
|
15944 |
|
15945 |
|
15946 |
|
15947 |
|
15948 |
|
15949 |
|
15950 |
|
15951 |
|
15952 |
|
15953 |
|
15954 |
|
15955 |
|
15956 |
|
15957 |
|
15958 | var modArgs = restParam(function(func, transforms) {
|
15959 | transforms = baseFlatten(transforms);
|
15960 | if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) {
|
15961 | throw new TypeError(FUNC_ERROR_TEXT);
|
15962 | }
|
15963 | var length = transforms.length;
|
15964 | return restParam(function(args) {
|
15965 | var index = nativeMin(args.length, length);
|
15966 | while (index--) {
|
15967 | args[index] = transforms[index](args[index]);
|
15968 | }
|
15969 | return func.apply(this, args);
|
15970 | });
|
15971 | });
|
15972 |
|
15973 | |
15974 |
|
15975 |
|
15976 |
|
15977 |
|
15978 |
|
15979 |
|
15980 |
|
15981 |
|
15982 |
|
15983 |
|
15984 |
|
15985 |
|
15986 |
|
15987 |
|
15988 |
|
15989 |
|
15990 |
|
15991 |
|
15992 | function negate(predicate) {
|
15993 | if (typeof predicate != 'function') {
|
15994 | throw new TypeError(FUNC_ERROR_TEXT);
|
15995 | }
|
15996 | return function() {
|
15997 | return !predicate.apply(this, arguments);
|
15998 | };
|
15999 | }
|
16000 |
|
16001 | |
16002 |
|
16003 |
|
16004 |
|
16005 |
|
16006 |
|
16007 |
|
16008 |
|
16009 |
|
16010 |
|
16011 |
|
16012 |
|
16013 |
|
16014 |
|
16015 |
|
16016 |
|
16017 |
|
16018 | function once(func) {
|
16019 | return before(2, func);
|
16020 | }
|
16021 |
|
16022 | |
16023 |
|
16024 |
|
16025 |
|
16026 |
|
16027 |
|
16028 |
|
16029 |
|
16030 |
|
16031 |
|
16032 |
|
16033 |
|
16034 |
|
16035 |
|
16036 |
|
16037 |
|
16038 |
|
16039 |
|
16040 |
|
16041 |
|
16042 |
|
16043 |
|
16044 |
|
16045 |
|
16046 |
|
16047 |
|
16048 |
|
16049 |
|
16050 |
|
16051 |
|
16052 |
|
16053 |
|
16054 | var partial = createPartial(PARTIAL_FLAG);
|
16055 |
|
16056 | |
16057 |
|
16058 |
|
16059 |
|
16060 |
|
16061 |
|
16062 |
|
16063 |
|
16064 |
|
16065 |
|
16066 |
|
16067 |
|
16068 |
|
16069 |
|
16070 |
|
16071 |
|
16072 |
|
16073 |
|
16074 |
|
16075 |
|
16076 |
|
16077 |
|
16078 |
|
16079 |
|
16080 |
|
16081 |
|
16082 |
|
16083 |
|
16084 |
|
16085 |
|
16086 |
|
16087 | var partialRight = createPartial(PARTIAL_RIGHT_FLAG);
|
16088 |
|
16089 | |
16090 |
|
16091 |
|
16092 |
|
16093 |
|
16094 |
|
16095 |
|
16096 |
|
16097 |
|
16098 |
|
16099 |
|
16100 |
|
16101 |
|
16102 |
|
16103 |
|
16104 |
|
16105 |
|
16106 |
|
16107 |
|
16108 |
|
16109 |
|
16110 |
|
16111 |
|
16112 |
|
16113 |
|
16114 |
|
16115 |
|
16116 |
|
16117 | var rearg = restParam(function(func, indexes) {
|
16118 | return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes));
|
16119 | });
|
16120 |
|
16121 | |
16122 |
|
16123 |
|
16124 |
|
16125 |
|
16126 |
|
16127 |
|
16128 |
|
16129 |
|
16130 |
|
16131 |
|
16132 |
|
16133 |
|
16134 |
|
16135 |
|
16136 |
|
16137 |
|
16138 |
|
16139 |
|
16140 |
|
16141 |
|
16142 |
|
16143 | function restParam(func, start) {
|
16144 | if (typeof func != 'function') {
|
16145 | throw new TypeError(FUNC_ERROR_TEXT);
|
16146 | }
|
16147 | start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
|
16148 | return function() {
|
16149 | var args = arguments,
|
16150 | index = -1,
|
16151 | length = nativeMax(args.length - start, 0),
|
16152 | rest = Array(length);
|
16153 |
|
16154 | while (++index < length) {
|
16155 | rest[index] = args[start + index];
|
16156 | }
|
16157 | switch (start) {
|
16158 | case 0: return func.call(this, rest);
|
16159 | case 1: return func.call(this, args[0], rest);
|
16160 | case 2: return func.call(this, args[0], args[1], rest);
|
16161 | }
|
16162 | var otherArgs = Array(start + 1);
|
16163 | index = -1;
|
16164 | while (++index < start) {
|
16165 | otherArgs[index] = args[index];
|
16166 | }
|
16167 | otherArgs[start] = rest;
|
16168 | return func.apply(this, otherArgs);
|
16169 | };
|
16170 | }
|
16171 |
|
16172 | |
16173 |
|
16174 |
|
16175 |
|
16176 |
|
16177 |
|
16178 |
|
16179 |
|
16180 |
|
16181 |
|
16182 |
|
16183 |
|
16184 |
|
16185 |
|
16186 |
|
16187 |
|
16188 |
|
16189 |
|
16190 |
|
16191 |
|
16192 |
|
16193 |
|
16194 |
|
16195 |
|
16196 |
|
16197 |
|
16198 |
|
16199 |
|
16200 |
|
16201 |
|
16202 |
|
16203 | function spread(func) {
|
16204 | if (typeof func != 'function') {
|
16205 | throw new TypeError(FUNC_ERROR_TEXT);
|
16206 | }
|
16207 | return function(array) {
|
16208 | return func.apply(this, array);
|
16209 | };
|
16210 | }
|
16211 |
|
16212 | |
16213 |
|
16214 |
|
16215 |
|
16216 |
|
16217 |
|
16218 |
|
16219 |
|
16220 |
|
16221 |
|
16222 |
|
16223 |
|
16224 |
|
16225 |
|
16226 |
|
16227 |
|
16228 |
|
16229 |
|
16230 |
|
16231 |
|
16232 |
|
16233 |
|
16234 |
|
16235 |
|
16236 |
|
16237 |
|
16238 |
|
16239 |
|
16240 |
|
16241 |
|
16242 |
|
16243 |
|
16244 |
|
16245 |
|
16246 |
|
16247 |
|
16248 |
|
16249 |
|
16250 |
|
16251 | function throttle(func, wait, options) {
|
16252 | var leading = true,
|
16253 | trailing = true;
|
16254 |
|
16255 | if (typeof func != 'function') {
|
16256 | throw new TypeError(FUNC_ERROR_TEXT);
|
16257 | }
|
16258 | if (options === false) {
|
16259 | leading = false;
|
16260 | } else if (isObject(options)) {
|
16261 | leading = 'leading' in options ? !!options.leading : leading;
|
16262 | trailing = 'trailing' in options ? !!options.trailing : trailing;
|
16263 | }
|
16264 | return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing });
|
16265 | }
|
16266 |
|
16267 | |
16268 |
|
16269 |
|
16270 |
|
16271 |
|
16272 |
|
16273 |
|
16274 |
|
16275 |
|
16276 |
|
16277 |
|
16278 |
|
16279 |
|
16280 |
|
16281 |
|
16282 |
|
16283 |
|
16284 |
|
16285 |
|
16286 |
|
16287 |
|
16288 | function wrap(value, wrapper) {
|
16289 | wrapper = wrapper == null ? identity : wrapper;
|
16290 | return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []);
|
16291 | }
|
16292 |
|
16293 |
|
16294 |
|
16295 | |
16296 |
|
16297 |
|
16298 |
|
16299 |
|
16300 |
|
16301 |
|
16302 |
|
16303 |
|
16304 |
|
16305 |
|
16306 |
|
16307 |
|
16308 |
|
16309 |
|
16310 |
|
16311 |
|
16312 |
|
16313 |
|
16314 |
|
16315 |
|
16316 |
|
16317 |
|
16318 |
|
16319 |
|
16320 |
|
16321 |
|
16322 |
|
16323 |
|
16324 |
|
16325 |
|
16326 |
|
16327 |
|
16328 |
|
16329 |
|
16330 |
|
16331 |
|
16332 |
|
16333 |
|
16334 |
|
16335 |
|
16336 |
|
16337 |
|
16338 |
|
16339 |
|
16340 |
|
16341 |
|
16342 |
|
16343 |
|
16344 |
|
16345 |
|
16346 | function clone(value, isDeep, customizer, thisArg) {
|
16347 | if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
|
16348 | isDeep = false;
|
16349 | }
|
16350 | else if (typeof isDeep == 'function') {
|
16351 | thisArg = customizer;
|
16352 | customizer = isDeep;
|
16353 | isDeep = false;
|
16354 | }
|
16355 | return typeof customizer == 'function'
|
16356 | ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1))
|
16357 | : baseClone(value, isDeep);
|
16358 | }
|
16359 |
|
16360 | |
16361 |
|
16362 |
|
16363 |
|
16364 |
|
16365 |
|
16366 |
|
16367 |
|
16368 |
|
16369 |
|
16370 |
|
16371 |
|
16372 |
|
16373 |
|
16374 |
|
16375 |
|
16376 |
|
16377 |
|
16378 |
|
16379 |
|
16380 |
|
16381 |
|
16382 |
|
16383 |
|
16384 |
|
16385 |
|
16386 |
|
16387 |
|
16388 |
|
16389 |
|
16390 |
|
16391 |
|
16392 |
|
16393 |
|
16394 |
|
16395 |
|
16396 |
|
16397 |
|
16398 |
|
16399 |
|
16400 |
|
16401 |
|
16402 |
|
16403 |
|
16404 |
|
16405 | function cloneDeep(value, customizer, thisArg) {
|
16406 | return typeof customizer == 'function'
|
16407 | ? baseClone(value, true, bindCallback(customizer, thisArg, 1))
|
16408 | : baseClone(value, true);
|
16409 | }
|
16410 |
|
16411 | |
16412 |
|
16413 |
|
16414 |
|
16415 |
|
16416 |
|
16417 |
|
16418 |
|
16419 |
|
16420 |
|
16421 |
|
16422 |
|
16423 |
|
16424 |
|
16425 |
|
16426 |
|
16427 |
|
16428 |
|
16429 |
|
16430 |
|
16431 | function gt(value, other) {
|
16432 | return value > other;
|
16433 | }
|
16434 |
|
16435 | |
16436 |
|
16437 |
|
16438 |
|
16439 |
|
16440 |
|
16441 |
|
16442 |
|
16443 |
|
16444 |
|
16445 |
|
16446 |
|
16447 |
|
16448 |
|
16449 |
|
16450 |
|
16451 |
|
16452 |
|
16453 |
|
16454 |
|
16455 | function gte(value, other) {
|
16456 | return value >= other;
|
16457 | }
|
16458 |
|
16459 | |
16460 |
|
16461 |
|
16462 |
|
16463 |
|
16464 |
|
16465 |
|
16466 |
|
16467 |
|
16468 |
|
16469 |
|
16470 |
|
16471 |
|
16472 |
|
16473 |
|
16474 |
|
16475 | function isArguments(value) {
|
16476 | return isObjectLike(value) && isArrayLike(value) &&
|
16477 | hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
|
16478 | }
|
16479 |
|
16480 | |
16481 |
|
16482 |
|
16483 |
|
16484 |
|
16485 |
|
16486 |
|
16487 |
|
16488 |
|
16489 |
|
16490 |
|
16491 |
|
16492 |
|
16493 |
|
16494 |
|
16495 |
|
16496 | var isArray = nativeIsArray || function(value) {
|
16497 | return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
|
16498 | };
|
16499 |
|
16500 | |
16501 |
|
16502 |
|
16503 |
|
16504 |
|
16505 |
|
16506 |
|
16507 |
|
16508 |
|
16509 |
|
16510 |
|
16511 |
|
16512 |
|
16513 |
|
16514 |
|
16515 |
|
16516 | function isBoolean(value) {
|
16517 | return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag);
|
16518 | }
|
16519 |
|
16520 | |
16521 |
|
16522 |
|
16523 |
|
16524 |
|
16525 |
|
16526 |
|
16527 |
|
16528 |
|
16529 |
|
16530 |
|
16531 |
|
16532 |
|
16533 |
|
16534 |
|
16535 |
|
16536 | function isDate(value) {
|
16537 | return isObjectLike(value) && objToString.call(value) == dateTag;
|
16538 | }
|
16539 |
|
16540 | |
16541 |
|
16542 |
|
16543 |
|
16544 |
|
16545 |
|
16546 |
|
16547 |
|
16548 |
|
16549 |
|
16550 |
|
16551 |
|
16552 |
|
16553 |
|
16554 |
|
16555 |
|
16556 | function isElement(value) {
|
16557 | return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
16558 | }
|
16559 |
|
16560 | |
16561 |
|
16562 |
|
16563 |
|
16564 |
|
16565 |
|
16566 |
|
16567 |
|
16568 |
|
16569 |
|
16570 |
|
16571 |
|
16572 |
|
16573 |
|
16574 |
|
16575 |
|
16576 |
|
16577 |
|
16578 |
|
16579 |
|
16580 |
|
16581 |
|
16582 |
|
16583 |
|
16584 |
|
16585 |
|
16586 |
|
16587 | function isEmpty(value) {
|
16588 | if (value == null) {
|
16589 | return true;
|
16590 | }
|
16591 | if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||
|
16592 | (isObjectLike(value) && isFunction(value.splice)))) {
|
16593 | return !value.length;
|
16594 | }
|
16595 | return !keys(value).length;
|
16596 | }
|
16597 |
|
16598 | |
16599 |
|
16600 |
|
16601 |
|
16602 |
|
16603 |
|
16604 |
|
16605 |
|
16606 |
|
16607 |
|
16608 |
|
16609 |
|
16610 |
|
16611 |
|
16612 |
|
16613 |
|
16614 |
|
16615 |
|
16616 |
|
16617 |
|
16618 |
|
16619 |
|
16620 |
|
16621 |
|
16622 |
|
16623 |
|
16624 |
|
16625 |
|
16626 |
|
16627 |
|
16628 |
|
16629 |
|
16630 |
|
16631 |
|
16632 |
|
16633 |
|
16634 |
|
16635 |
|
16636 |
|
16637 |
|
16638 |
|
16639 |
|
16640 |
|
16641 |
|
16642 | function isEqual(value, other, customizer, thisArg) {
|
16643 | customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;
|
16644 | var result = customizer ? customizer(value, other) : undefined;
|
16645 | return result === undefined ? baseIsEqual(value, other, customizer) : !!result;
|
16646 | }
|
16647 |
|
16648 | |
16649 |
|
16650 |
|
16651 |
|
16652 |
|
16653 |
|
16654 |
|
16655 |
|
16656 |
|
16657 |
|
16658 |
|
16659 |
|
16660 |
|
16661 |
|
16662 |
|
16663 |
|
16664 |
|
16665 | function isError(value) {
|
16666 | return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag;
|
16667 | }
|
16668 |
|
16669 | |
16670 |
|
16671 |
|
16672 |
|
16673 |
|
16674 |
|
16675 |
|
16676 |
|
16677 |
|
16678 |
|
16679 |
|
16680 |
|
16681 |
|
16682 |
|
16683 |
|
16684 |
|
16685 |
|
16686 |
|
16687 |
|
16688 |
|
16689 |
|
16690 |
|
16691 |
|
16692 |
|
16693 |
|
16694 |
|
16695 |
|
16696 | function isFinite(value) {
|
16697 | return typeof value == 'number' && nativeIsFinite(value);
|
16698 | }
|
16699 |
|
16700 | |
16701 |
|
16702 |
|
16703 |
|
16704 |
|
16705 |
|
16706 |
|
16707 |
|
16708 |
|
16709 |
|
16710 |
|
16711 |
|
16712 |
|
16713 |
|
16714 |
|
16715 |
|
16716 | function isFunction(value) {
|
16717 |
|
16718 |
|
16719 |
|
16720 | return isObject(value) && objToString.call(value) == funcTag;
|
16721 | }
|
16722 |
|
16723 | |
16724 |
|
16725 |
|
16726 |
|
16727 |
|
16728 |
|
16729 |
|
16730 |
|
16731 |
|
16732 |
|
16733 |
|
16734 |
|
16735 |
|
16736 |
|
16737 |
|
16738 |
|
16739 |
|
16740 |
|
16741 |
|
16742 |
|
16743 | function isObject(value) {
|
16744 |
|
16745 |
|
16746 | var type = typeof value;
|
16747 | return !!value && (type == 'object' || type == 'function');
|
16748 | }
|
16749 |
|
16750 | |
16751 |
|
16752 |
|
16753 |
|
16754 |
|
16755 |
|
16756 |
|
16757 |
|
16758 |
|
16759 |
|
16760 |
|
16761 |
|
16762 |
|
16763 |
|
16764 |
|
16765 |
|
16766 |
|
16767 |
|
16768 |
|
16769 |
|
16770 |
|
16771 |
|
16772 |
|
16773 |
|
16774 |
|
16775 |
|
16776 |
|
16777 |
|
16778 |
|
16779 |
|
16780 |
|
16781 |
|
16782 |
|
16783 |
|
16784 |
|
16785 |
|
16786 |
|
16787 |
|
16788 |
|
16789 | function isMatch(object, source, customizer, thisArg) {
|
16790 | customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;
|
16791 | return baseIsMatch(object, getMatchData(source), customizer);
|
16792 | }
|
16793 |
|
16794 | |
16795 |
|
16796 |
|
16797 |
|
16798 |
|
16799 |
|
16800 |
|
16801 |
|
16802 |
|
16803 |
|
16804 |
|
16805 |
|
16806 |
|
16807 |
|
16808 |
|
16809 |
|
16810 |
|
16811 |
|
16812 |
|
16813 |
|
16814 |
|
16815 |
|
16816 |
|
16817 |
|
16818 |
|
16819 | function isNaN(value) {
|
16820 |
|
16821 |
|
16822 | return isNumber(value) && value != +value;
|
16823 | }
|
16824 |
|
16825 | |
16826 |
|
16827 |
|
16828 |
|
16829 |
|
16830 |
|
16831 |
|
16832 |
|
16833 |
|
16834 |
|
16835 |
|
16836 |
|
16837 |
|
16838 |
|
16839 |
|
16840 |
|
16841 | function isNative(value) {
|
16842 | if (value == null) {
|
16843 | return false;
|
16844 | }
|
16845 | if (isFunction(value)) {
|
16846 | return reIsNative.test(fnToString.call(value));
|
16847 | }
|
16848 | return isObjectLike(value) && reIsHostCtor.test(value);
|
16849 | }
|
16850 |
|
16851 | |
16852 |
|
16853 |
|
16854 |
|
16855 |
|
16856 |
|
16857 |
|
16858 |
|
16859 |
|
16860 |
|
16861 |
|
16862 |
|
16863 |
|
16864 |
|
16865 |
|
16866 |
|
16867 | function isNull(value) {
|
16868 | return value === null;
|
16869 | }
|
16870 |
|
16871 | |
16872 |
|
16873 |
|
16874 |
|
16875 |
|
16876 |
|
16877 |
|
16878 |
|
16879 |
|
16880 |
|
16881 |
|
16882 |
|
16883 |
|
16884 |
|
16885 |
|
16886 |
|
16887 |
|
16888 |
|
16889 |
|
16890 |
|
16891 |
|
16892 |
|
16893 | function isNumber(value) {
|
16894 | return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
|
16895 | }
|
16896 |
|
16897 | |
16898 |
|
16899 |
|
16900 |
|
16901 |
|
16902 |
|
16903 |
|
16904 |
|
16905 |
|
16906 |
|
16907 |
|
16908 |
|
16909 |
|
16910 |
|
16911 |
|
16912 |
|
16913 |
|
16914 |
|
16915 |
|
16916 |
|
16917 |
|
16918 |
|
16919 |
|
16920 |
|
16921 |
|
16922 |
|
16923 |
|
16924 |
|
16925 |
|
16926 |
|
16927 | function isPlainObject(value) {
|
16928 | var Ctor;
|
16929 |
|
16930 |
|
16931 | if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
|
16932 | (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
|
16933 | return false;
|
16934 | }
|
16935 |
|
16936 |
|
16937 |
|
16938 | var result;
|
16939 |
|
16940 |
|
16941 |
|
16942 | baseForIn(value, function(subValue, key) {
|
16943 | result = key;
|
16944 | });
|
16945 | return result === undefined || hasOwnProperty.call(value, result);
|
16946 | }
|
16947 |
|
16948 | |
16949 |
|
16950 |
|
16951 |
|
16952 |
|
16953 |
|
16954 |
|
16955 |
|
16956 |
|
16957 |
|
16958 |
|
16959 |
|
16960 |
|
16961 |
|
16962 |
|
16963 |
|
16964 | function isRegExp(value) {
|
16965 | return isObject(value) && objToString.call(value) == regexpTag;
|
16966 | }
|
16967 |
|
16968 | |
16969 |
|
16970 |
|
16971 |
|
16972 |
|
16973 |
|
16974 |
|
16975 |
|
16976 |
|
16977 |
|
16978 |
|
16979 |
|
16980 |
|
16981 |
|
16982 |
|
16983 |
|
16984 | function isString(value) {
|
16985 | return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
|
16986 | }
|
16987 |
|
16988 | |
16989 |
|
16990 |
|
16991 |
|
16992 |
|
16993 |
|
16994 |
|
16995 |
|
16996 |
|
16997 |
|
16998 |
|
16999 |
|
17000 |
|
17001 |
|
17002 |
|
17003 |
|
17004 | function isTypedArray(value) {
|
17005 | return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
|
17006 | }
|
17007 |
|
17008 | |
17009 |
|
17010 |
|
17011 |
|
17012 |
|
17013 |
|
17014 |
|
17015 |
|
17016 |
|
17017 |
|
17018 |
|
17019 |
|
17020 |
|
17021 |
|
17022 |
|
17023 |
|
17024 | function isUndefined(value) {
|
17025 | return value === undefined;
|
17026 | }
|
17027 |
|
17028 | |
17029 |
|
17030 |
|
17031 |
|
17032 |
|
17033 |
|
17034 |
|
17035 |
|
17036 |
|
17037 |
|
17038 |
|
17039 |
|
17040 |
|
17041 |
|
17042 |
|
17043 |
|
17044 |
|
17045 |
|
17046 |
|
17047 |
|
17048 | function lt(value, other) {
|
17049 | return value < other;
|
17050 | }
|
17051 |
|
17052 | |
17053 |
|
17054 |
|
17055 |
|
17056 |
|
17057 |
|
17058 |
|
17059 |
|
17060 |
|
17061 |
|
17062 |
|
17063 |
|
17064 |
|
17065 |
|
17066 |
|
17067 |
|
17068 |
|
17069 |
|
17070 |
|
17071 |
|
17072 | function lte(value, other) {
|
17073 | return value <= other;
|
17074 | }
|
17075 |
|
17076 | |
17077 |
|
17078 |
|
17079 |
|
17080 |
|
17081 |
|
17082 |
|
17083 |
|
17084 |
|
17085 |
|
17086 |
|
17087 |
|
17088 |
|
17089 |
|
17090 |
|
17091 | function toArray(value) {
|
17092 | var length = value ? getLength(value) : 0;
|
17093 | if (!isLength(length)) {
|
17094 | return values(value);
|
17095 | }
|
17096 | if (!length) {
|
17097 | return [];
|
17098 | }
|
17099 | return arrayCopy(value);
|
17100 | }
|
17101 |
|
17102 | |
17103 |
|
17104 |
|
17105 |
|
17106 |
|
17107 |
|
17108 |
|
17109 |
|
17110 |
|
17111 |
|
17112 |
|
17113 |
|
17114 |
|
17115 |
|
17116 |
|
17117 |
|
17118 |
|
17119 |
|
17120 |
|
17121 |
|
17122 |
|
17123 |
|
17124 |
|
17125 | function toPlainObject(value) {
|
17126 | return baseCopy(value, keysIn(value));
|
17127 | }
|
17128 |
|
17129 |
|
17130 |
|
17131 | |
17132 |
|
17133 |
|
17134 |
|
17135 |
|
17136 |
|
17137 |
|
17138 |
|
17139 |
|
17140 |
|
17141 |
|
17142 |
|
17143 |
|
17144 |
|
17145 |
|
17146 |
|
17147 |
|
17148 |
|
17149 |
|
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 |
|
17155 |
|
17156 |
|
17157 |
|
17158 |
|
17159 |
|
17160 |
|
17161 |
|
17162 |
|
17163 |
|
17164 |
|
17165 |
|
17166 |
|
17167 |
|
17168 |
|
17169 |
|
17170 |
|
17171 |
|
17172 |
|
17173 |
|
17174 |
|
17175 |
|
17176 |
|
17177 |
|
17178 |
|
17179 | var merge = createAssigner(baseMerge);
|
17180 |
|
17181 | |
17182 |
|
17183 |
|
17184 |
|
17185 |
|
17186 |
|
17187 |
|
17188 |
|
17189 |
|
17190 |
|
17191 |
|
17192 |
|
17193 |
|
17194 |
|
17195 |
|
17196 |
|
17197 |
|
17198 |
|
17199 |
|
17200 |
|
17201 |
|
17202 |
|
17203 |
|
17204 |
|
17205 |
|
17206 |
|
17207 |
|
17208 |
|
17209 |
|
17210 |
|
17211 |
|
17212 |
|
17213 | var assign = createAssigner(function(object, source, customizer) {
|
17214 | return customizer
|
17215 | ? assignWith(object, source, customizer)
|
17216 | : baseAssign(object, source);
|
17217 | });
|
17218 |
|
17219 | |
17220 |
|
17221 |
|
17222 |
|
17223 |
|
17224 |
|
17225 |
|
17226 |
|
17227 |
|
17228 |
|
17229 |
|
17230 |
|
17231 |
|
17232 |
|
17233 |
|
17234 |
|
17235 |
|
17236 |
|
17237 |
|
17238 |
|
17239 |
|
17240 |
|
17241 |
|
17242 |
|
17243 |
|
17244 |
|
17245 |
|
17246 |
|
17247 |
|
17248 |
|
17249 |
|
17250 |
|
17251 |
|
17252 |
|
17253 | function create(prototype, properties, guard) {
|
17254 | var result = baseCreate(prototype);
|
17255 | if (guard && isIterateeCall(prototype, properties, guard)) {
|
17256 | properties = undefined;
|
17257 | }
|
17258 | return properties ? baseAssign(result, properties) : result;
|
17259 | }
|
17260 |
|
17261 | |
17262 |
|
17263 |
|
17264 |
|
17265 |
|
17266 |
|
17267 |
|
17268 |
|
17269 |
|
17270 |
|
17271 |
|
17272 |
|
17273 |
|
17274 |
|
17275 |
|
17276 |
|
17277 |
|
17278 |
|
17279 | var defaults = createDefaults(assign, assignDefaults);
|
17280 |
|
17281 | |
17282 |
|
17283 |
|
17284 |
|
17285 |
|
17286 |
|
17287 |
|
17288 |
|
17289 |
|
17290 |
|
17291 |
|
17292 |
|
17293 |
|
17294 |
|
17295 |
|
17296 |
|
17297 |
|
17298 |
|
17299 | var defaultsDeep = createDefaults(merge, mergeDefaults);
|
17300 |
|
17301 | |
17302 |
|
17303 |
|
17304 |
|
17305 |
|
17306 |
|
17307 |
|
17308 |
|
17309 |
|
17310 |
|
17311 |
|
17312 |
|
17313 |
|
17314 |
|
17315 |
|
17316 |
|
17317 |
|
17318 |
|
17319 |
|
17320 |
|
17321 |
|
17322 |
|
17323 |
|
17324 |
|
17325 |
|
17326 |
|
17327 |
|
17328 |
|
17329 |
|
17330 |
|
17331 |
|
17332 |
|
17333 |
|
17334 |
|
17335 |
|
17336 |
|
17337 |
|
17338 |
|
17339 |
|
17340 |
|
17341 |
|
17342 |
|
17343 |
|
17344 |
|
17345 |
|
17346 |
|
17347 |
|
17348 |
|
17349 | var findKey = createFindKey(baseForOwn);
|
17350 |
|
17351 | |
17352 |
|
17353 |
|
17354 |
|
17355 |
|
17356 |
|
17357 |
|
17358 |
|
17359 |
|
17360 |
|
17361 |
|
17362 |
|
17363 |
|
17364 |
|
17365 |
|
17366 |
|
17367 |
|
17368 |
|
17369 |
|
17370 |
|
17371 |
|
17372 |
|
17373 |
|
17374 |
|
17375 |
|
17376 |
|
17377 |
|
17378 |
|
17379 |
|
17380 |
|
17381 |
|
17382 |
|
17383 |
|
17384 |
|
17385 |
|
17386 |
|
17387 |
|
17388 |
|
17389 |
|
17390 |
|
17391 |
|
17392 |
|
17393 |
|
17394 |
|
17395 |
|
17396 |
|
17397 |
|
17398 |
|
17399 | var findLastKey = createFindKey(baseForOwnRight);
|
17400 |
|
17401 | |
17402 |
|
17403 |
|
17404 |
|
17405 |
|
17406 |
|
17407 |
|
17408 |
|
17409 |
|
17410 |
|
17411 |
|
17412 |
|
17413 |
|
17414 |
|
17415 |
|
17416 |
|
17417 |
|
17418 |
|
17419 |
|
17420 |
|
17421 |
|
17422 |
|
17423 |
|
17424 |
|
17425 |
|
17426 |
|
17427 |
|
17428 | var forIn = createForIn(baseFor);
|
17429 |
|
17430 | |
17431 |
|
17432 |
|
17433 |
|
17434 |
|
17435 |
|
17436 |
|
17437 |
|
17438 |
|
17439 |
|
17440 |
|
17441 |
|
17442 |
|
17443 |
|
17444 |
|
17445 |
|
17446 |
|
17447 |
|
17448 |
|
17449 |
|
17450 |
|
17451 |
|
17452 |
|
17453 |
|
17454 |
|
17455 | var forInRight = createForIn(baseForRight);
|
17456 |
|
17457 | |
17458 |
|
17459 |
|
17460 |
|
17461 |
|
17462 |
|
17463 |
|
17464 |
|
17465 |
|
17466 |
|
17467 |
|
17468 |
|
17469 |
|
17470 |
|
17471 |
|
17472 |
|
17473 |
|
17474 |
|
17475 |
|
17476 |
|
17477 |
|
17478 |
|
17479 |
|
17480 |
|
17481 |
|
17482 |
|
17483 |
|
17484 | var forOwn = createForOwn(baseForOwn);
|
17485 |
|
17486 | |
17487 |
|
17488 |
|
17489 |
|
17490 |
|
17491 |
|
17492 |
|
17493 |
|
17494 |
|
17495 |
|
17496 |
|
17497 |
|
17498 |
|
17499 |
|
17500 |
|
17501 |
|
17502 |
|
17503 |
|
17504 |
|
17505 |
|
17506 |
|
17507 |
|
17508 |
|
17509 |
|
17510 |
|
17511 | var forOwnRight = createForOwn(baseForOwnRight);
|
17512 |
|
17513 | |
17514 |
|
17515 |
|
17516 |
|
17517 |
|
17518 |
|
17519 |
|
17520 |
|
17521 |
|
17522 |
|
17523 |
|
17524 |
|
17525 |
|
17526 |
|
17527 |
|
17528 | function functions(object) {
|
17529 | return baseFunctions(object, keysIn(object));
|
17530 | }
|
17531 |
|
17532 | |
17533 |
|
17534 |
|
17535 |
|
17536 |
|
17537 |
|
17538 |
|
17539 |
|
17540 |
|
17541 |
|
17542 |
|
17543 |
|
17544 |
|
17545 |
|
17546 |
|
17547 |
|
17548 |
|
17549 |
|
17550 |
|
17551 |
|
17552 |
|
17553 |
|
17554 |
|
17555 |
|
17556 | function get(object, path, defaultValue) {
|
17557 | var result = object == null ? undefined : baseGet(object, toPath(path), path + '');
|
17558 | return result === undefined ? defaultValue : result;
|
17559 | }
|
17560 |
|
17561 | |
17562 |
|
17563 |
|
17564 |
|
17565 |
|
17566 |
|
17567 |
|
17568 |
|
17569 |
|
17570 |
|
17571 |
|
17572 |
|
17573 |
|
17574 |
|
17575 |
|
17576 |
|
17577 |
|
17578 |
|
17579 |
|
17580 |
|
17581 |
|
17582 |
|
17583 | function has(object, path) {
|
17584 | if (object == null) {
|
17585 | return false;
|
17586 | }
|
17587 | var result = hasOwnProperty.call(object, path);
|
17588 | if (!result && !isKey(path)) {
|
17589 | path = toPath(path);
|
17590 | object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
17591 | if (object == null) {
|
17592 | return false;
|
17593 | }
|
17594 | path = last(path);
|
17595 | result = hasOwnProperty.call(object, path);
|
17596 | }
|
17597 | return result || (isLength(object.length) && isIndex(path, object.length) &&
|
17598 | (isArray(object) || isArguments(object)));
|
17599 | }
|
17600 |
|
17601 | |
17602 |
|
17603 |
|
17604 |
|
17605 |
|
17606 |
|
17607 |
|
17608 |
|
17609 |
|
17610 |
|
17611 |
|
17612 |
|
17613 |
|
17614 |
|
17615 |
|
17616 |
|
17617 |
|
17618 |
|
17619 |
|
17620 |
|
17621 |
|
17622 |
|
17623 |
|
17624 | function invert(object, multiValue, guard) {
|
17625 | if (guard && isIterateeCall(object, multiValue, guard)) {
|
17626 | multiValue = undefined;
|
17627 | }
|
17628 | var index = -1,
|
17629 | props = keys(object),
|
17630 | length = props.length,
|
17631 | result = {};
|
17632 |
|
17633 | while (++index < length) {
|
17634 | var key = props[index],
|
17635 | value = object[key];
|
17636 |
|
17637 | if (multiValue) {
|
17638 | if (hasOwnProperty.call(result, value)) {
|
17639 | result[value].push(key);
|
17640 | } else {
|
17641 | result[value] = [key];
|
17642 | }
|
17643 | }
|
17644 | else {
|
17645 | result[value] = key;
|
17646 | }
|
17647 | }
|
17648 | return result;
|
17649 | }
|
17650 |
|
17651 | |
17652 |
|
17653 |
|
17654 |
|
17655 |
|
17656 |
|
17657 |
|
17658 |
|
17659 |
|
17660 |
|
17661 |
|
17662 |
|
17663 |
|
17664 |
|
17665 |
|
17666 |
|
17667 |
|
17668 |
|
17669 |
|
17670 |
|
17671 |
|
17672 |
|
17673 |
|
17674 |
|
17675 |
|
17676 |
|
17677 |
|
17678 | var keys = !nativeKeys ? shimKeys : function(object) {
|
17679 | var Ctor = object == null ? undefined : object.constructor;
|
17680 | if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
|
17681 | (typeof object != 'function' && isArrayLike(object))) {
|
17682 | return shimKeys(object);
|
17683 | }
|
17684 | return isObject(object) ? nativeKeys(object) : [];
|
17685 | };
|
17686 |
|
17687 | |
17688 |
|
17689 |
|
17690 |
|
17691 |
|
17692 |
|
17693 |
|
17694 |
|
17695 |
|
17696 |
|
17697 |
|
17698 |
|
17699 |
|
17700 |
|
17701 |
|
17702 |
|
17703 |
|
17704 |
|
17705 |
|
17706 |
|
17707 |
|
17708 |
|
17709 | function keysIn(object) {
|
17710 | if (object == null) {
|
17711 | return [];
|
17712 | }
|
17713 | if (!isObject(object)) {
|
17714 | object = Object(object);
|
17715 | }
|
17716 | var length = object.length;
|
17717 | length = (length && isLength(length) &&
|
17718 | (isArray(object) || isArguments(object)) && length) || 0;
|
17719 |
|
17720 | var Ctor = object.constructor,
|
17721 | index = -1,
|
17722 | isProto = typeof Ctor == 'function' && Ctor.prototype === object,
|
17723 | result = Array(length),
|
17724 | skipIndexes = length > 0;
|
17725 |
|
17726 | while (++index < length) {
|
17727 | result[index] = (index + '');
|
17728 | }
|
17729 | for (var key in object) {
|
17730 | if (!(skipIndexes && isIndex(key, length)) &&
|
17731 | !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
17732 | result.push(key);
|
17733 | }
|
17734 | }
|
17735 | return result;
|
17736 | }
|
17737 |
|
17738 | |
17739 |
|
17740 |
|
17741 |
|
17742 |
|
17743 |
|
17744 |
|
17745 |
|
17746 |
|
17747 |
|
17748 |
|
17749 |
|
17750 |
|
17751 |
|
17752 |
|
17753 |
|
17754 |
|
17755 |
|
17756 |
|
17757 |
|
17758 | var mapKeys = createObjectMapper(true);
|
17759 |
|
17760 | |
17761 |
|
17762 |
|
17763 |
|
17764 |
|
17765 |
|
17766 |
|
17767 |
|
17768 |
|
17769 |
|
17770 |
|
17771 |
|
17772 |
|
17773 |
|
17774 |
|
17775 |
|
17776 |
|
17777 |
|
17778 |
|
17779 |
|
17780 |
|
17781 |
|
17782 |
|
17783 |
|
17784 |
|
17785 |
|
17786 |
|
17787 |
|
17788 |
|
17789 |
|
17790 |
|
17791 |
|
17792 |
|
17793 |
|
17794 |
|
17795 |
|
17796 |
|
17797 |
|
17798 |
|
17799 |
|
17800 |
|
17801 | var mapValues = createObjectMapper();
|
17802 |
|
17803 | |
17804 |
|
17805 |
|
17806 |
|
17807 |
|
17808 |
|
17809 |
|
17810 |
|
17811 |
|
17812 |
|
17813 |
|
17814 |
|
17815 |
|
17816 |
|
17817 |
|
17818 |
|
17819 |
|
17820 |
|
17821 |
|
17822 |
|
17823 |
|
17824 |
|
17825 |
|
17826 | var omit = restParam(function(object, props) {
|
17827 | if (object == null) {
|
17828 | return {};
|
17829 | }
|
17830 | if (typeof props[0] != 'function') {
|
17831 | var props = arrayMap(baseFlatten(props), String);
|
17832 | return pickByArray(object, baseDifference(keysIn(object), props));
|
17833 | }
|
17834 | var predicate = bindCallback(props[0], props[1], 3);
|
17835 | return pickByCallback(object, function(value, key, object) {
|
17836 | return !predicate(value, key, object);
|
17837 | });
|
17838 | });
|
17839 |
|
17840 | |
17841 |
|
17842 |
|
17843 |
|
17844 |
|
17845 |
|
17846 |
|
17847 |
|
17848 |
|
17849 |
|
17850 |
|
17851 |
|
17852 |
|
17853 |
|
17854 | function pairs(object) {
|
17855 | object = toObject(object);
|
17856 |
|
17857 | var index = -1,
|
17858 | props = keys(object),
|
17859 | length = props.length,
|
17860 | result = Array(length);
|
17861 |
|
17862 | while (++index < length) {
|
17863 | var key = props[index];
|
17864 | result[index] = [key, object[key]];
|
17865 | }
|
17866 | return result;
|
17867 | }
|
17868 |
|
17869 | |
17870 |
|
17871 |
|
17872 |
|
17873 |
|
17874 |
|
17875 |
|
17876 |
|
17877 |
|
17878 |
|
17879 |
|
17880 |
|
17881 |
|
17882 |
|
17883 |
|
17884 |
|
17885 |
|
17886 |
|
17887 |
|
17888 |
|
17889 |
|
17890 |
|
17891 |
|
17892 |
|
17893 |
|
17894 |
|
17895 | var pick = restParam(function(object, props) {
|
17896 | if (object == null) {
|
17897 | return {};
|
17898 | }
|
17899 | return typeof props[0] == 'function'
|
17900 | ? pickByCallback(object, bindCallback(props[0], props[1], 3))
|
17901 | : pickByArray(object, baseFlatten(props));
|
17902 | });
|
17903 |
|
17904 | |
17905 |
|
17906 |
|
17907 |
|
17908 |
|
17909 |
|
17910 |
|
17911 |
|
17912 |
|
17913 |
|
17914 |
|
17915 |
|
17916 |
|
17917 |
|
17918 |
|
17919 |
|
17920 |
|
17921 |
|
17922 |
|
17923 |
|
17924 |
|
17925 |
|
17926 |
|
17927 |
|
17928 |
|
17929 |
|
17930 |
|
17931 |
|
17932 | function result(object, path, defaultValue) {
|
17933 | var result = object == null ? undefined : object[path];
|
17934 | if (result === undefined) {
|
17935 | if (object != null && !isKey(path, object)) {
|
17936 | path = toPath(path);
|
17937 | object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
17938 | result = object == null ? undefined : object[last(path)];
|
17939 | }
|
17940 | result = result === undefined ? defaultValue : result;
|
17941 | }
|
17942 | return isFunction(result) ? result.call(object) : result;
|
17943 | }
|
17944 |
|
17945 | |
17946 |
|
17947 |
|
17948 |
|
17949 |
|
17950 |
|
17951 |
|
17952 |
|
17953 |
|
17954 |
|
17955 |
|
17956 |
|
17957 |
|
17958 |
|
17959 |
|
17960 |
|
17961 |
|
17962 |
|
17963 |
|
17964 |
|
17965 |
|
17966 |
|
17967 |
|
17968 | function set(object, path, value) {
|
17969 | if (object == null) {
|
17970 | return object;
|
17971 | }
|
17972 | var pathKey = (path + '');
|
17973 | path = (object[pathKey] != null || isKey(path, object)) ? [pathKey] : toPath(path);
|
17974 |
|
17975 | var index = -1,
|
17976 | length = path.length,
|
17977 | lastIndex = length - 1,
|
17978 | nested = object;
|
17979 |
|
17980 | while (nested != null && ++index < length) {
|
17981 | var key = path[index];
|
17982 | if (isObject(nested)) {
|
17983 | if (index == lastIndex) {
|
17984 | nested[key] = value;
|
17985 | } else if (nested[key] == null) {
|
17986 | nested[key] = isIndex(path[index + 1]) ? [] : {};
|
17987 | }
|
17988 | }
|
17989 | nested = nested[key];
|
17990 | }
|
17991 | return object;
|
17992 | }
|
17993 |
|
17994 | |
17995 |
|
17996 |
|
17997 |
|
17998 |
|
17999 |
|
18000 |
|
18001 |
|
18002 |
|
18003 |
|
18004 |
|
18005 |
|
18006 |
|
18007 |
|
18008 |
|
18009 |
|
18010 |
|
18011 |
|
18012 |
|
18013 |
|
18014 |
|
18015 |
|
18016 |
|
18017 |
|
18018 |
|
18019 |
|
18020 |
|
18021 |
|
18022 |
|
18023 | function transform(object, iteratee, accumulator, thisArg) {
|
18024 | var isArr = isArray(object) || isTypedArray(object);
|
18025 | iteratee = getCallback(iteratee, thisArg, 4);
|
18026 |
|
18027 | if (accumulator == null) {
|
18028 | if (isArr || isObject(object)) {
|
18029 | var Ctor = object.constructor;
|
18030 | if (isArr) {
|
18031 | accumulator = isArray(object) ? new Ctor : [];
|
18032 | } else {
|
18033 | accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
|
18034 | }
|
18035 | } else {
|
18036 | accumulator = {};
|
18037 | }
|
18038 | }
|
18039 | (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
|
18040 | return iteratee(accumulator, value, index, object);
|
18041 | });
|
18042 | return accumulator;
|
18043 | }
|
18044 |
|
18045 | |
18046 |
|
18047 |
|
18048 |
|
18049 |
|
18050 |
|
18051 |
|
18052 |
|
18053 |
|
18054 |
|
18055 |
|
18056 |
|
18057 |
|
18058 |
|
18059 |
|
18060 |
|
18061 |
|
18062 |
|
18063 |
|
18064 |
|
18065 |
|
18066 |
|
18067 |
|
18068 |
|
18069 |
|
18070 | function values(object) {
|
18071 | return baseValues(object, keys(object));
|
18072 | }
|
18073 |
|
18074 | |
18075 |
|
18076 |
|
18077 |
|
18078 |
|
18079 |
|
18080 |
|
18081 |
|
18082 |
|
18083 |
|
18084 |
|
18085 |
|
18086 |
|
18087 |
|
18088 |
|
18089 |
|
18090 |
|
18091 |
|
18092 |
|
18093 |
|
18094 |
|
18095 |
|
18096 |
|
18097 | function valuesIn(object) {
|
18098 | return baseValues(object, keysIn(object));
|
18099 | }
|
18100 |
|
18101 |
|
18102 |
|
18103 | |
18104 |
|
18105 |
|
18106 |
|
18107 |
|
18108 |
|
18109 |
|
18110 |
|
18111 |
|
18112 |
|
18113 |
|
18114 |
|
18115 |
|
18116 |
|
18117 |
|
18118 |
|
18119 |
|
18120 |
|
18121 |
|
18122 |
|
18123 |
|
18124 |
|
18125 |
|
18126 |
|
18127 |
|
18128 |
|
18129 |
|
18130 |
|
18131 |
|
18132 |
|
18133 |
|
18134 | function inRange(value, start, end) {
|
18135 | start = +start || 0;
|
18136 | if (end === undefined) {
|
18137 | end = start;
|
18138 | start = 0;
|
18139 | } else {
|
18140 | end = +end || 0;
|
18141 | }
|
18142 | return value >= nativeMin(start, end) && value < nativeMax(start, end);
|
18143 | }
|
18144 |
|
18145 | |
18146 |
|
18147 |
|
18148 |
|
18149 |
|
18150 |
|
18151 |
|
18152 |
|
18153 |
|
18154 |
|
18155 |
|
18156 |
|
18157 |
|
18158 |
|
18159 |
|
18160 |
|
18161 |
|
18162 |
|
18163 |
|
18164 |
|
18165 |
|
18166 |
|
18167 |
|
18168 |
|
18169 |
|
18170 |
|
18171 |
|
18172 | function random(min, max, floating) {
|
18173 | if (floating && isIterateeCall(min, max, floating)) {
|
18174 | max = floating = undefined;
|
18175 | }
|
18176 | var noMin = min == null,
|
18177 | noMax = max == null;
|
18178 |
|
18179 | if (floating == null) {
|
18180 | if (noMax && typeof min == 'boolean') {
|
18181 | floating = min;
|
18182 | min = 1;
|
18183 | }
|
18184 | else if (typeof max == 'boolean') {
|
18185 | floating = max;
|
18186 | noMax = true;
|
18187 | }
|
18188 | }
|
18189 | if (noMin && noMax) {
|
18190 | max = 1;
|
18191 | noMax = false;
|
18192 | }
|
18193 | min = +min || 0;
|
18194 | if (noMax) {
|
18195 | max = min;
|
18196 | min = 0;
|
18197 | } else {
|
18198 | max = +max || 0;
|
18199 | }
|
18200 | if (floating || min % 1 || max % 1) {
|
18201 | var rand = nativeRandom();
|
18202 | return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max);
|
18203 | }
|
18204 | return baseRandom(min, max);
|
18205 | }
|
18206 |
|
18207 |
|
18208 |
|
18209 | |
18210 |
|
18211 |
|
18212 |
|
18213 |
|
18214 |
|
18215 |
|
18216 |
|
18217 |
|
18218 |
|
18219 |
|
18220 |
|
18221 |
|
18222 |
|
18223 |
|
18224 |
|
18225 |
|
18226 |
|
18227 |
|
18228 | var camelCase = createCompounder(function(result, word, index) {
|
18229 | word = word.toLowerCase();
|
18230 | return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word);
|
18231 | });
|
18232 |
|
18233 | |
18234 |
|
18235 |
|
18236 |
|
18237 |
|
18238 |
|
18239 |
|
18240 |
|
18241 |
|
18242 |
|
18243 |
|
18244 |
|
18245 |
|
18246 | function capitalize(string) {
|
18247 | string = baseToString(string);
|
18248 | return string && (string.charAt(0).toUpperCase() + string.slice(1));
|
18249 | }
|
18250 |
|
18251 | |
18252 |
|
18253 |
|
18254 |
|
18255 |
|
18256 |
|
18257 |
|
18258 |
|
18259 |
|
18260 |
|
18261 |
|
18262 |
|
18263 |
|
18264 |
|
18265 | function deburr(string) {
|
18266 | string = baseToString(string);
|
18267 | return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, '');
|
18268 | }
|
18269 |
|
18270 | |
18271 |
|
18272 |
|
18273 |
|
18274 |
|
18275 |
|
18276 |
|
18277 |
|
18278 |
|
18279 |
|
18280 |
|
18281 |
|
18282 |
|
18283 |
|
18284 |
|
18285 |
|
18286 |
|
18287 |
|
18288 |
|
18289 |
|
18290 |
|
18291 | function endsWith(string, target, position) {
|
18292 | string = baseToString(string);
|
18293 | target = (target + '');
|
18294 |
|
18295 | var length = string.length;
|
18296 | position = position === undefined
|
18297 | ? length
|
18298 | : nativeMin(position < 0 ? 0 : (+position || 0), length);
|
18299 |
|
18300 | position -= target.length;
|
18301 | return position >= 0 && string.indexOf(target, position) == position;
|
18302 | }
|
18303 |
|
18304 | |
18305 |
|
18306 |
|
18307 |
|
18308 |
|
18309 |
|
18310 |
|
18311 |
|
18312 |
|
18313 |
|
18314 |
|
18315 |
|
18316 |
|
18317 |
|
18318 |
|
18319 |
|
18320 |
|
18321 |
|
18322 |
|
18323 |
|
18324 |
|
18325 |
|
18326 |
|
18327 |
|
18328 |
|
18329 |
|
18330 |
|
18331 |
|
18332 |
|
18333 |
|
18334 |
|
18335 |
|
18336 | function escape(string) {
|
18337 |
|
18338 | string = baseToString(string);
|
18339 | return (string && reHasUnescapedHtml.test(string))
|
18340 | ? string.replace(reUnescapedHtml, escapeHtmlChar)
|
18341 | : string;
|
18342 | }
|
18343 |
|
18344 | |
18345 |
|
18346 |
|
18347 |
|
18348 |
|
18349 |
|
18350 |
|
18351 |
|
18352 |
|
18353 |
|
18354 |
|
18355 |
|
18356 |
|
18357 |
|
18358 | function escapeRegExp(string) {
|
18359 | string = baseToString(string);
|
18360 | return (string && reHasRegExpChars.test(string))
|
18361 | ? string.replace(reRegExpChars, escapeRegExpChar)
|
18362 | : (string || '(?:)');
|
18363 | }
|
18364 |
|
18365 | |
18366 |
|
18367 |
|
18368 |
|
18369 |
|
18370 |
|
18371 |
|
18372 |
|
18373 |
|
18374 |
|
18375 |
|
18376 |
|
18377 |
|
18378 |
|
18379 |
|
18380 |
|
18381 |
|
18382 |
|
18383 |
|
18384 | var kebabCase = createCompounder(function(result, word, index) {
|
18385 | return result + (index ? '-' : '') + word.toLowerCase();
|
18386 | });
|
18387 |
|
18388 | |
18389 |
|
18390 |
|
18391 |
|
18392 |
|
18393 |
|
18394 |
|
18395 |
|
18396 |
|
18397 |
|
18398 |
|
18399 |
|
18400 |
|
18401 |
|
18402 |
|
18403 |
|
18404 |
|
18405 |
|
18406 |
|
18407 |
|
18408 |
|
18409 |
|
18410 | function pad(string, length, chars) {
|
18411 | string = baseToString(string);
|
18412 | length = +length;
|
18413 |
|
18414 | var strLength = string.length;
|
18415 | if (strLength >= length || !nativeIsFinite(length)) {
|
18416 | return string;
|
18417 | }
|
18418 | var mid = (length - strLength) / 2,
|
18419 | leftLength = nativeFloor(mid),
|
18420 | rightLength = nativeCeil(mid);
|
18421 |
|
18422 | chars = createPadding('', rightLength, chars);
|
18423 | return chars.slice(0, leftLength) + string + chars;
|
18424 | }
|
18425 |
|
18426 | |
18427 |
|
18428 |
|
18429 |
|
18430 |
|
18431 |
|
18432 |
|
18433 |
|
18434 |
|
18435 |
|
18436 |
|
18437 |
|
18438 |
|
18439 |
|
18440 |
|
18441 |
|
18442 |
|
18443 |
|
18444 |
|
18445 |
|
18446 |
|
18447 |
|
18448 | var padLeft = createPadDir();
|
18449 |
|
18450 | |
18451 |
|
18452 |
|
18453 |
|
18454 |
|
18455 |
|
18456 |
|
18457 |
|
18458 |
|
18459 |
|
18460 |
|
18461 |
|
18462 |
|
18463 |
|
18464 |
|
18465 |
|
18466 |
|
18467 |
|
18468 |
|
18469 |
|
18470 |
|
18471 |
|
18472 | var padRight = createPadDir(true);
|
18473 |
|
18474 | |
18475 |
|
18476 |
|
18477 |
|
18478 |
|
18479 |
|
18480 |
|
18481 |
|
18482 |
|
18483 |
|
18484 |
|
18485 |
|
18486 |
|
18487 |
|
18488 |
|
18489 |
|
18490 |
|
18491 |
|
18492 |
|
18493 |
|
18494 |
|
18495 |
|
18496 |
|
18497 | function parseInt(string, radix, guard) {
|
18498 |
|
18499 |
|
18500 |
|
18501 | if (guard ? isIterateeCall(string, radix, guard) : radix == null) {
|
18502 | radix = 0;
|
18503 | } else if (radix) {
|
18504 | radix = +radix;
|
18505 | }
|
18506 | string = trim(string);
|
18507 | return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
|
18508 | }
|
18509 |
|
18510 | |
18511 |
|
18512 |
|
18513 |
|
18514 |
|
18515 |
|
18516 |
|
18517 |
|
18518 |
|
18519 |
|
18520 |
|
18521 |
|
18522 |
|
18523 |
|
18524 |
|
18525 |
|
18526 |
|
18527 |
|
18528 |
|
18529 |
|
18530 | function repeat(string, n) {
|
18531 | var result = '';
|
18532 | string = baseToString(string);
|
18533 | n = +n;
|
18534 | if (n < 1 || !string || !nativeIsFinite(n)) {
|
18535 | return result;
|
18536 | }
|
18537 |
|
18538 |
|
18539 | do {
|
18540 | if (n % 2) {
|
18541 | result += string;
|
18542 | }
|
18543 | n = nativeFloor(n / 2);
|
18544 | string += string;
|
18545 | } while (n);
|
18546 |
|
18547 | return result;
|
18548 | }
|
18549 |
|
18550 | |
18551 |
|
18552 |
|
18553 |
|
18554 |
|
18555 |
|
18556 |
|
18557 |
|
18558 |
|
18559 |
|
18560 |
|
18561 |
|
18562 |
|
18563 |
|
18564 |
|
18565 |
|
18566 |
|
18567 |
|
18568 |
|
18569 | var snakeCase = createCompounder(function(result, word, index) {
|
18570 | return result + (index ? '_' : '') + word.toLowerCase();
|
18571 | });
|
18572 |
|
18573 | |
18574 |
|
18575 |
|
18576 |
|
18577 |
|
18578 |
|
18579 |
|
18580 |
|
18581 |
|
18582 |
|
18583 |
|
18584 |
|
18585 |
|
18586 |
|
18587 |
|
18588 |
|
18589 |
|
18590 |
|
18591 |
|
18592 | var startCase = createCompounder(function(result, word, index) {
|
18593 | return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1));
|
18594 | });
|
18595 |
|
18596 | |
18597 |
|
18598 |
|
18599 |
|
18600 |
|
18601 |
|
18602 |
|
18603 |
|
18604 |
|
18605 |
|
18606 |
|
18607 |
|
18608 |
|
18609 |
|
18610 |
|
18611 |
|
18612 |
|
18613 |
|
18614 |
|
18615 |
|
18616 |
|
18617 | function startsWith(string, target, position) {
|
18618 | string = baseToString(string);
|
18619 | position = position == null
|
18620 | ? 0
|
18621 | : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
|
18622 |
|
18623 | return string.lastIndexOf(target, position) == position;
|
18624 | }
|
18625 |
|
18626 | |
18627 |
|
18628 |
|
18629 |
|
18630 |
|
18631 |
|
18632 |
|
18633 |
|
18634 |
|
18635 |
|
18636 |
|
18637 |
|
18638 |
|
18639 |
|
18640 |
|
18641 |
|
18642 |
|
18643 |
|
18644 |
|
18645 |
|
18646 |
|
18647 |
|
18648 |
|
18649 |
|
18650 |
|
18651 |
|
18652 |
|
18653 |
|
18654 |
|
18655 |
|
18656 |
|
18657 |
|
18658 |
|
18659 |
|
18660 |
|
18661 |
|
18662 |
|
18663 |
|
18664 |
|
18665 |
|
18666 |
|
18667 |
|
18668 |
|
18669 |
|
18670 |
|
18671 |
|
18672 |
|
18673 |
|
18674 |
|
18675 |
|
18676 |
|
18677 |
|
18678 |
|
18679 |
|
18680 |
|
18681 |
|
18682 |
|
18683 |
|
18684 |
|
18685 |
|
18686 |
|
18687 |
|
18688 |
|
18689 |
|
18690 |
|
18691 |
|
18692 |
|
18693 |
|
18694 |
|
18695 |
|
18696 |
|
18697 |
|
18698 |
|
18699 |
|
18700 |
|
18701 |
|
18702 |
|
18703 |
|
18704 |
|
18705 |
|
18706 |
|
18707 |
|
18708 |
|
18709 |
|
18710 |
|
18711 |
|
18712 |
|
18713 |
|
18714 |
|
18715 |
|
18716 |
|
18717 |
|
18718 |
|
18719 |
|
18720 |
|
18721 |
|
18722 | function template(string, options, otherOptions) {
|
18723 |
|
18724 |
|
18725 | var settings = lodash.templateSettings;
|
18726 |
|
18727 | if (otherOptions && isIterateeCall(string, options, otherOptions)) {
|
18728 | options = otherOptions = undefined;
|
18729 | }
|
18730 | string = baseToString(string);
|
18731 | options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults);
|
18732 |
|
18733 | var imports = assignWith(baseAssign({}, options.imports), settings.imports, assignOwnDefaults),
|
18734 | importsKeys = keys(imports),
|
18735 | importsValues = baseValues(imports, importsKeys);
|
18736 |
|
18737 | var isEscaping,
|
18738 | isEvaluating,
|
18739 | index = 0,
|
18740 | interpolate = options.interpolate || reNoMatch,
|
18741 | source = "__p += '";
|
18742 |
|
18743 |
|
18744 | var reDelimiters = RegExp(
|
18745 | (options.escape || reNoMatch).source + '|' +
|
18746 | interpolate.source + '|' +
|
18747 | (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
|
18748 | (options.evaluate || reNoMatch).source + '|$'
|
18749 | , 'g');
|
18750 |
|
18751 |
|
18752 | var sourceURL = '//# sourceURL=' +
|
18753 | ('sourceURL' in options
|
18754 | ? options.sourceURL
|
18755 | : ('lodash.templateSources[' + (++templateCounter) + ']')
|
18756 | ) + '\n';
|
18757 |
|
18758 | string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
18759 | interpolateValue || (interpolateValue = esTemplateValue);
|
18760 |
|
18761 |
|
18762 | source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
|
18763 |
|
18764 |
|
18765 | if (escapeValue) {
|
18766 | isEscaping = true;
|
18767 | source += "' +\n__e(" + escapeValue + ") +\n'";
|
18768 | }
|
18769 | if (evaluateValue) {
|
18770 | isEvaluating = true;
|
18771 | source += "';\n" + evaluateValue + ";\n__p += '";
|
18772 | }
|
18773 | if (interpolateValue) {
|
18774 | source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
18775 | }
|
18776 | index = offset + match.length;
|
18777 |
|
18778 |
|
18779 |
|
18780 | return match;
|
18781 | });
|
18782 |
|
18783 | source += "';\n";
|
18784 |
|
18785 |
|
18786 |
|
18787 | var variable = options.variable;
|
18788 | if (!variable) {
|
18789 | source = 'with (obj) {\n' + source + '\n}\n';
|
18790 | }
|
18791 |
|
18792 | source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
18793 | .replace(reEmptyStringMiddle, '$1')
|
18794 | .replace(reEmptyStringTrailing, '$1;');
|
18795 |
|
18796 |
|
18797 | source = 'function(' + (variable || 'obj') + ') {\n' +
|
18798 | (variable
|
18799 | ? ''
|
18800 | : 'obj || (obj = {});\n'
|
18801 | ) +
|
18802 | "var __t, __p = ''" +
|
18803 | (isEscaping
|
18804 | ? ', __e = _.escape'
|
18805 | : ''
|
18806 | ) +
|
18807 | (isEvaluating
|
18808 | ? ', __j = Array.prototype.join;\n' +
|
18809 | "function print() { __p += __j.call(arguments, '') }\n"
|
18810 | : ';\n'
|
18811 | ) +
|
18812 | source +
|
18813 | 'return __p\n}';
|
18814 |
|
18815 | var result = attempt(function() {
|
18816 | return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues);
|
18817 | });
|
18818 |
|
18819 |
|
18820 |
|
18821 | result.source = source;
|
18822 | if (isError(result)) {
|
18823 | throw result;
|
18824 | }
|
18825 | return result;
|
18826 | }
|
18827 |
|
18828 | |
18829 |
|
18830 |
|
18831 |
|
18832 |
|
18833 |
|
18834 |
|
18835 |
|
18836 |
|
18837 |
|
18838 |
|
18839 |
|
18840 |
|
18841 |
|
18842 |
|
18843 |
|
18844 |
|
18845 |
|
18846 |
|
18847 |
|
18848 |
|
18849 | function trim(string, chars, guard) {
|
18850 | var value = string;
|
18851 | string = baseToString(string);
|
18852 | if (!string) {
|
18853 | return string;
|
18854 | }
|
18855 | if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
18856 | return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
18857 | }
|
18858 | chars = (chars + '');
|
18859 | return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
|
18860 | }
|
18861 |
|
18862 | |
18863 |
|
18864 |
|
18865 |
|
18866 |
|
18867 |
|
18868 |
|
18869 |
|
18870 |
|
18871 |
|
18872 |
|
18873 |
|
18874 |
|
18875 |
|
18876 |
|
18877 |
|
18878 |
|
18879 |
|
18880 | function trimLeft(string, chars, guard) {
|
18881 | var value = string;
|
18882 | string = baseToString(string);
|
18883 | if (!string) {
|
18884 | return string;
|
18885 | }
|
18886 | if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
18887 | return string.slice(trimmedLeftIndex(string));
|
18888 | }
|
18889 | return string.slice(charsLeftIndex(string, (chars + '')));
|
18890 | }
|
18891 |
|
18892 | |
18893 |
|
18894 |
|
18895 |
|
18896 |
|
18897 |
|
18898 |
|
18899 |
|
18900 |
|
18901 |
|
18902 |
|
18903 |
|
18904 |
|
18905 |
|
18906 |
|
18907 |
|
18908 |
|
18909 |
|
18910 | function trimRight(string, chars, guard) {
|
18911 | var value = string;
|
18912 | string = baseToString(string);
|
18913 | if (!string) {
|
18914 | return string;
|
18915 | }
|
18916 | if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
18917 | return string.slice(0, trimmedRightIndex(string) + 1);
|
18918 | }
|
18919 | return string.slice(0, charsRightIndex(string, (chars + '')) + 1);
|
18920 | }
|
18921 |
|
18922 | |
18923 |
|
18924 |
|
18925 |
|
18926 |
|
18927 |
|
18928 |
|
18929 |
|
18930 |
|
18931 |
|
18932 |
|
18933 |
|
18934 |
|
18935 |
|
18936 |
|
18937 |
|
18938 |
|
18939 |
|
18940 |
|
18941 |
|
18942 |
|
18943 |
|
18944 |
|
18945 |
|
18946 |
|
18947 |
|
18948 |
|
18949 |
|
18950 |
|
18951 |
|
18952 |
|
18953 |
|
18954 |
|
18955 |
|
18956 |
|
18957 |
|
18958 |
|
18959 |
|
18960 |
|
18961 |
|
18962 | function trunc(string, options, guard) {
|
18963 | if (guard && isIterateeCall(string, options, guard)) {
|
18964 | options = undefined;
|
18965 | }
|
18966 | var length = DEFAULT_TRUNC_LENGTH,
|
18967 | omission = DEFAULT_TRUNC_OMISSION;
|
18968 |
|
18969 | if (options != null) {
|
18970 | if (isObject(options)) {
|
18971 | var separator = 'separator' in options ? options.separator : separator;
|
18972 | length = 'length' in options ? (+options.length || 0) : length;
|
18973 | omission = 'omission' in options ? baseToString(options.omission) : omission;
|
18974 | } else {
|
18975 | length = +options || 0;
|
18976 | }
|
18977 | }
|
18978 | string = baseToString(string);
|
18979 | if (length >= string.length) {
|
18980 | return string;
|
18981 | }
|
18982 | var end = length - omission.length;
|
18983 | if (end < 1) {
|
18984 | return omission;
|
18985 | }
|
18986 | var result = string.slice(0, end);
|
18987 | if (separator == null) {
|
18988 | return result + omission;
|
18989 | }
|
18990 | if (isRegExp(separator)) {
|
18991 | if (string.slice(end).search(separator)) {
|
18992 | var match,
|
18993 | newEnd,
|
18994 | substring = string.slice(0, end);
|
18995 |
|
18996 | if (!separator.global) {
|
18997 | separator = RegExp(separator.source, (reFlags.exec(separator) || '') + 'g');
|
18998 | }
|
18999 | separator.lastIndex = 0;
|
19000 | while ((match = separator.exec(substring))) {
|
19001 | newEnd = match.index;
|
19002 | }
|
19003 | result = result.slice(0, newEnd == null ? end : newEnd);
|
19004 | }
|
19005 | } else if (string.indexOf(separator, end) != end) {
|
19006 | var index = result.lastIndexOf(separator);
|
19007 | if (index > -1) {
|
19008 | result = result.slice(0, index);
|
19009 | }
|
19010 | }
|
19011 | return result + omission;
|
19012 | }
|
19013 |
|
19014 | |
19015 |
|
19016 |
|
19017 |
|
19018 |
|
19019 |
|
19020 |
|
19021 |
|
19022 |
|
19023 |
|
19024 |
|
19025 |
|
19026 |
|
19027 |
|
19028 |
|
19029 |
|
19030 |
|
19031 |
|
19032 | function unescape(string) {
|
19033 | string = baseToString(string);
|
19034 | return (string && reHasEscapedHtml.test(string))
|
19035 | ? string.replace(reEscapedHtml, unescapeHtmlChar)
|
19036 | : string;
|
19037 | }
|
19038 |
|
19039 | |
19040 |
|
19041 |
|
19042 |
|
19043 |
|
19044 |
|
19045 |
|
19046 |
|
19047 |
|
19048 |
|
19049 |
|
19050 |
|
19051 |
|
19052 |
|
19053 |
|
19054 |
|
19055 |
|
19056 |
|
19057 | function words(string, pattern, guard) {
|
19058 | if (guard && isIterateeCall(string, pattern, guard)) {
|
19059 | pattern = undefined;
|
19060 | }
|
19061 | string = baseToString(string);
|
19062 | return string.match(pattern || reWords) || [];
|
19063 | }
|
19064 |
|
19065 |
|
19066 |
|
19067 | |
19068 |
|
19069 |
|
19070 |
|
19071 |
|
19072 |
|
19073 |
|
19074 |
|
19075 |
|
19076 |
|
19077 |
|
19078 |
|
19079 |
|
19080 |
|
19081 |
|
19082 |
|
19083 |
|
19084 |
|
19085 |
|
19086 |
|
19087 | var attempt = restParam(function(func, args) {
|
19088 | try {
|
19089 | return func.apply(undefined, args);
|
19090 | } catch(e) {
|
19091 | return isError(e) ? e : new Error(e);
|
19092 | }
|
19093 | });
|
19094 |
|
19095 | |
19096 |
|
19097 |
|
19098 |
|
19099 |
|
19100 |
|
19101 |
|
19102 |
|
19103 |
|
19104 |
|
19105 |
|
19106 |
|
19107 |
|
19108 |
|
19109 |
|
19110 |
|
19111 |
|
19112 |
|
19113 |
|
19114 |
|
19115 |
|
19116 |
|
19117 |
|
19118 |
|
19119 |
|
19120 |
|
19121 |
|
19122 |
|
19123 |
|
19124 |
|
19125 |
|
19126 |
|
19127 |
|
19128 |
|
19129 |
|
19130 |
|
19131 |
|
19132 |
|
19133 | function callback(func, thisArg, guard) {
|
19134 | if (guard && isIterateeCall(func, thisArg, guard)) {
|
19135 | thisArg = undefined;
|
19136 | }
|
19137 | return isObjectLike(func)
|
19138 | ? matches(func)
|
19139 | : baseCallback(func, thisArg);
|
19140 | }
|
19141 |
|
19142 | |
19143 |
|
19144 |
|
19145 |
|
19146 |
|
19147 |
|
19148 |
|
19149 |
|
19150 |
|
19151 |
|
19152 |
|
19153 |
|
19154 |
|
19155 |
|
19156 |
|
19157 |
|
19158 | function constant(value) {
|
19159 | return function() {
|
19160 | return value;
|
19161 | };
|
19162 | }
|
19163 |
|
19164 | |
19165 |
|
19166 |
|
19167 |
|
19168 |
|
19169 |
|
19170 |
|
19171 |
|
19172 |
|
19173 |
|
19174 |
|
19175 |
|
19176 |
|
19177 |
|
19178 |
|
19179 | function identity(value) {
|
19180 | return value;
|
19181 | }
|
19182 |
|
19183 | |
19184 |
|
19185 |
|
19186 |
|
19187 |
|
19188 |
|
19189 |
|
19190 |
|
19191 |
|
19192 |
|
19193 |
|
19194 |
|
19195 |
|
19196 |
|
19197 |
|
19198 |
|
19199 |
|
19200 |
|
19201 |
|
19202 |
|
19203 |
|
19204 |
|
19205 |
|
19206 |
|
19207 |
|
19208 | function matches(source) {
|
19209 | return baseMatches(baseClone(source, true));
|
19210 | }
|
19211 |
|
19212 | |
19213 |
|
19214 |
|
19215 |
|
19216 |
|
19217 |
|
19218 |
|
19219 |
|
19220 |
|
19221 |
|
19222 |
|
19223 |
|
19224 |
|
19225 |
|
19226 |
|
19227 |
|
19228 |
|
19229 |
|
19230 |
|
19231 |
|
19232 |
|
19233 |
|
19234 |
|
19235 |
|
19236 | function matchesProperty(path, srcValue) {
|
19237 | return baseMatchesProperty(path, baseClone(srcValue, true));
|
19238 | }
|
19239 |
|
19240 | |
19241 |
|
19242 |
|
19243 |
|
19244 |
|
19245 |
|
19246 |
|
19247 |
|
19248 |
|
19249 |
|
19250 |
|
19251 |
|
19252 |
|
19253 |
|
19254 |
|
19255 |
|
19256 |
|
19257 |
|
19258 |
|
19259 |
|
19260 |
|
19261 |
|
19262 |
|
19263 | var method = restParam(function(path, args) {
|
19264 | return function(object) {
|
19265 | return invokePath(object, path, args);
|
19266 | };
|
19267 | });
|
19268 |
|
19269 | |
19270 |
|
19271 |
|
19272 |
|
19273 |
|
19274 |
|
19275 |
|
19276 |
|
19277 |
|
19278 |
|
19279 |
|
19280 |
|
19281 |
|
19282 |
|
19283 |
|
19284 |
|
19285 |
|
19286 |
|
19287 |
|
19288 |
|
19289 |
|
19290 |
|
19291 | var methodOf = restParam(function(object, args) {
|
19292 | return function(path) {
|
19293 | return invokePath(object, path, args);
|
19294 | };
|
19295 | });
|
19296 |
|
19297 | |
19298 |
|
19299 |
|
19300 |
|
19301 |
|
19302 |
|
19303 |
|
19304 |
|
19305 |
|
19306 |
|
19307 |
|
19308 |
|
19309 |
|
19310 |
|
19311 |
|
19312 |
|
19313 |
|
19314 |
|
19315 |
|
19316 |
|
19317 |
|
19318 |
|
19319 |
|
19320 |
|
19321 |
|
19322 |
|
19323 |
|
19324 |
|
19325 |
|
19326 |
|
19327 |
|
19328 |
|
19329 |
|
19330 |
|
19331 |
|
19332 |
|
19333 | function mixin(object, source, options) {
|
19334 | if (options == null) {
|
19335 | var isObj = isObject(source),
|
19336 | props = isObj ? keys(source) : undefined,
|
19337 | methodNames = (props && props.length) ? baseFunctions(source, props) : undefined;
|
19338 |
|
19339 | if (!(methodNames ? methodNames.length : isObj)) {
|
19340 | methodNames = false;
|
19341 | options = source;
|
19342 | source = object;
|
19343 | object = this;
|
19344 | }
|
19345 | }
|
19346 | if (!methodNames) {
|
19347 | methodNames = baseFunctions(source, keys(source));
|
19348 | }
|
19349 | var chain = true,
|
19350 | index = -1,
|
19351 | isFunc = isFunction(object),
|
19352 | length = methodNames.length;
|
19353 |
|
19354 | if (options === false) {
|
19355 | chain = false;
|
19356 | } else if (isObject(options) && 'chain' in options) {
|
19357 | chain = options.chain;
|
19358 | }
|
19359 | while (++index < length) {
|
19360 | var methodName = methodNames[index],
|
19361 | func = source[methodName];
|
19362 |
|
19363 | object[methodName] = func;
|
19364 | if (isFunc) {
|
19365 | object.prototype[methodName] = (function(func) {
|
19366 | return function() {
|
19367 | var chainAll = this.__chain__;
|
19368 | if (chain || chainAll) {
|
19369 | var result = object(this.__wrapped__),
|
19370 | actions = result.__actions__ = arrayCopy(this.__actions__);
|
19371 |
|
19372 | actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
|
19373 | result.__chain__ = chainAll;
|
19374 | return result;
|
19375 | }
|
19376 | return func.apply(object, arrayPush([this.value()], arguments));
|
19377 | };
|
19378 | }(func));
|
19379 | }
|
19380 | }
|
19381 | return object;
|
19382 | }
|
19383 |
|
19384 | |
19385 |
|
19386 |
|
19387 |
|
19388 |
|
19389 |
|
19390 |
|
19391 |
|
19392 |
|
19393 |
|
19394 |
|
19395 |
|
19396 | function noConflict() {
|
19397 | root._ = oldDash;
|
19398 | return this;
|
19399 | }
|
19400 |
|
19401 | |
19402 |
|
19403 |
|
19404 |
|
19405 |
|
19406 |
|
19407 |
|
19408 |
|
19409 |
|
19410 |
|
19411 |
|
19412 |
|
19413 |
|
19414 |
|
19415 | function noop() {
|
19416 |
|
19417 | }
|
19418 |
|
19419 | |
19420 |
|
19421 |
|
19422 |
|
19423 |
|
19424 |
|
19425 |
|
19426 |
|
19427 |
|
19428 |
|
19429 |
|
19430 |
|
19431 |
|
19432 |
|
19433 |
|
19434 |
|
19435 |
|
19436 |
|
19437 |
|
19438 |
|
19439 |
|
19440 |
|
19441 | function property(path) {
|
19442 | return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
|
19443 | }
|
19444 |
|
19445 | |
19446 |
|
19447 |
|
19448 |
|
19449 |
|
19450 |
|
19451 |
|
19452 |
|
19453 |
|
19454 |
|
19455 |
|
19456 |
|
19457 |
|
19458 |
|
19459 |
|
19460 |
|
19461 |
|
19462 |
|
19463 |
|
19464 |
|
19465 | function propertyOf(object) {
|
19466 | return function(path) {
|
19467 | return baseGet(object, toPath(path), path + '');
|
19468 | };
|
19469 | }
|
19470 |
|
19471 | |
19472 |
|
19473 |
|
19474 |
|
19475 |
|
19476 |
|
19477 |
|
19478 |
|
19479 |
|
19480 |
|
19481 |
|
19482 |
|
19483 |
|
19484 |
|
19485 |
|
19486 |
|
19487 |
|
19488 |
|
19489 |
|
19490 |
|
19491 |
|
19492 |
|
19493 |
|
19494 |
|
19495 |
|
19496 |
|
19497 |
|
19498 |
|
19499 |
|
19500 |
|
19501 |
|
19502 |
|
19503 |
|
19504 | function range(start, end, step) {
|
19505 | if (step && isIterateeCall(start, end, step)) {
|
19506 | end = step = undefined;
|
19507 | }
|
19508 | start = +start || 0;
|
19509 | step = step == null ? 1 : (+step || 0);
|
19510 |
|
19511 | if (end == null) {
|
19512 | end = start;
|
19513 | start = 0;
|
19514 | } else {
|
19515 | end = +end || 0;
|
19516 | }
|
19517 |
|
19518 |
|
19519 | var index = -1,
|
19520 | length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
|
19521 | result = Array(length);
|
19522 |
|
19523 | while (++index < length) {
|
19524 | result[index] = start;
|
19525 | start += step;
|
19526 | }
|
19527 | return result;
|
19528 | }
|
19529 |
|
19530 | |
19531 |
|
19532 |
|
19533 |
|
19534 |
|
19535 |
|
19536 |
|
19537 |
|
19538 |
|
19539 |
|
19540 |
|
19541 |
|
19542 |
|
19543 |
|
19544 |
|
19545 |
|
19546 |
|
19547 |
|
19548 |
|
19549 |
|
19550 |
|
19551 |
|
19552 |
|
19553 |
|
19554 |
|
19555 |
|
19556 |
|
19557 | function times(n, iteratee, thisArg) {
|
19558 | n = nativeFloor(n);
|
19559 |
|
19560 |
|
19561 |
|
19562 | if (n < 1 || !nativeIsFinite(n)) {
|
19563 | return [];
|
19564 | }
|
19565 | var index = -1,
|
19566 | result = Array(nativeMin(n, MAX_ARRAY_LENGTH));
|
19567 |
|
19568 | iteratee = bindCallback(iteratee, thisArg, 1);
|
19569 | while (++index < n) {
|
19570 | if (index < MAX_ARRAY_LENGTH) {
|
19571 | result[index] = iteratee(index);
|
19572 | } else {
|
19573 | iteratee(index);
|
19574 | }
|
19575 | }
|
19576 | return result;
|
19577 | }
|
19578 |
|
19579 | |
19580 |
|
19581 |
|
19582 |
|
19583 |
|
19584 |
|
19585 |
|
19586 |
|
19587 |
|
19588 |
|
19589 |
|
19590 |
|
19591 |
|
19592 |
|
19593 |
|
19594 |
|
19595 | function uniqueId(prefix) {
|
19596 | var id = ++idCounter;
|
19597 | return baseToString(prefix) + id;
|
19598 | }
|
19599 |
|
19600 |
|
19601 |
|
19602 | |
19603 |
|
19604 |
|
19605 |
|
19606 |
|
19607 |
|
19608 |
|
19609 |
|
19610 |
|
19611 |
|
19612 |
|
19613 |
|
19614 |
|
19615 |
|
19616 | function add(augend, addend) {
|
19617 | return (+augend || 0) + (+addend || 0);
|
19618 | }
|
19619 |
|
19620 | |
19621 |
|
19622 |
|
19623 |
|
19624 |
|
19625 |
|
19626 |
|
19627 |
|
19628 |
|
19629 |
|
19630 |
|
19631 |
|
19632 |
|
19633 |
|
19634 |
|
19635 |
|
19636 |
|
19637 |
|
19638 |
|
19639 |
|
19640 | var ceil = createRound('ceil');
|
19641 |
|
19642 | |
19643 |
|
19644 |
|
19645 |
|
19646 |
|
19647 |
|
19648 |
|
19649 |
|
19650 |
|
19651 |
|
19652 |
|
19653 |
|
19654 |
|
19655 |
|
19656 |
|
19657 |
|
19658 |
|
19659 |
|
19660 |
|
19661 |
|
19662 | var floor = createRound('floor');
|
19663 |
|
19664 | |
19665 |
|
19666 |
|
19667 |
|
19668 |
|
19669 |
|
19670 |
|
19671 |
|
19672 |
|
19673 |
|
19674 |
|
19675 |
|
19676 |
|
19677 |
|
19678 |
|
19679 |
|
19680 |
|
19681 |
|
19682 |
|
19683 |
|
19684 |
|
19685 |
|
19686 |
|
19687 |
|
19688 |
|
19689 |
|
19690 |
|
19691 |
|
19692 |
|
19693 |
|
19694 |
|
19695 |
|
19696 |
|
19697 |
|
19698 |
|
19699 |
|
19700 |
|
19701 |
|
19702 |
|
19703 |
|
19704 |
|
19705 |
|
19706 |
|
19707 |
|
19708 |
|
19709 |
|
19710 |
|
19711 | var max = createExtremum(gt, NEGATIVE_INFINITY);
|
19712 |
|
19713 | |
19714 |
|
19715 |
|
19716 |
|
19717 |
|
19718 |
|
19719 |
|
19720 |
|
19721 |
|
19722 |
|
19723 |
|
19724 |
|
19725 |
|
19726 |
|
19727 |
|
19728 |
|
19729 |
|
19730 |
|
19731 |
|
19732 |
|
19733 |
|
19734 |
|
19735 |
|
19736 |
|
19737 |
|
19738 |
|
19739 |
|
19740 |
|
19741 |
|
19742 |
|
19743 |
|
19744 |
|
19745 |
|
19746 |
|
19747 |
|
19748 |
|
19749 |
|
19750 |
|
19751 |
|
19752 |
|
19753 |
|
19754 |
|
19755 |
|
19756 |
|
19757 |
|
19758 |
|
19759 |
|
19760 | var min = createExtremum(lt, POSITIVE_INFINITY);
|
19761 |
|
19762 | |
19763 |
|
19764 |
|
19765 |
|
19766 |
|
19767 |
|
19768 |
|
19769 |
|
19770 |
|
19771 |
|
19772 |
|
19773 |
|
19774 |
|
19775 |
|
19776 |
|
19777 |
|
19778 |
|
19779 |
|
19780 |
|
19781 |
|
19782 | var round = createRound('round');
|
19783 |
|
19784 | |
19785 |
|
19786 |
|
19787 |
|
19788 |
|
19789 |
|
19790 |
|
19791 |
|
19792 |
|
19793 |
|
19794 |
|
19795 |
|
19796 |
|
19797 |
|
19798 |
|
19799 |
|
19800 |
|
19801 |
|
19802 |
|
19803 |
|
19804 |
|
19805 |
|
19806 |
|
19807 |
|
19808 |
|
19809 |
|
19810 |
|
19811 |
|
19812 |
|
19813 |
|
19814 |
|
19815 |
|
19816 | function sum(collection, iteratee, thisArg) {
|
19817 | if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
19818 | iteratee = undefined;
|
19819 | }
|
19820 | iteratee = getCallback(iteratee, thisArg, 3);
|
19821 | return iteratee.length == 1
|
19822 | ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee)
|
19823 | : baseSum(collection, iteratee);
|
19824 | }
|
19825 |
|
19826 |
|
19827 |
|
19828 |
|
19829 | lodash.prototype = baseLodash.prototype;
|
19830 |
|
19831 | LodashWrapper.prototype = baseCreate(baseLodash.prototype);
|
19832 | LodashWrapper.prototype.constructor = LodashWrapper;
|
19833 |
|
19834 | LazyWrapper.prototype = baseCreate(baseLodash.prototype);
|
19835 | LazyWrapper.prototype.constructor = LazyWrapper;
|
19836 |
|
19837 |
|
19838 | MapCache.prototype['delete'] = mapDelete;
|
19839 | MapCache.prototype.get = mapGet;
|
19840 | MapCache.prototype.has = mapHas;
|
19841 | MapCache.prototype.set = mapSet;
|
19842 |
|
19843 |
|
19844 | SetCache.prototype.push = cachePush;
|
19845 |
|
19846 |
|
19847 | memoize.Cache = MapCache;
|
19848 |
|
19849 |
|
19850 | lodash.after = after;
|
19851 | lodash.ary = ary;
|
19852 | lodash.assign = assign;
|
19853 | lodash.at = at;
|
19854 | lodash.before = before;
|
19855 | lodash.bind = bind;
|
19856 | lodash.bindAll = bindAll;
|
19857 | lodash.bindKey = bindKey;
|
19858 | lodash.callback = callback;
|
19859 | lodash.chain = chain;
|
19860 | lodash.chunk = chunk;
|
19861 | lodash.compact = compact;
|
19862 | lodash.constant = constant;
|
19863 | lodash.countBy = countBy;
|
19864 | lodash.create = create;
|
19865 | lodash.curry = curry;
|
19866 | lodash.curryRight = curryRight;
|
19867 | lodash.debounce = debounce;
|
19868 | lodash.defaults = defaults;
|
19869 | lodash.defaultsDeep = defaultsDeep;
|
19870 | lodash.defer = defer;
|
19871 | lodash.delay = delay;
|
19872 | lodash.difference = difference;
|
19873 | lodash.drop = drop;
|
19874 | lodash.dropRight = dropRight;
|
19875 | lodash.dropRightWhile = dropRightWhile;
|
19876 | lodash.dropWhile = dropWhile;
|
19877 | lodash.fill = fill;
|
19878 | lodash.filter = filter;
|
19879 | lodash.flatten = flatten;
|
19880 | lodash.flattenDeep = flattenDeep;
|
19881 | lodash.flow = flow;
|
19882 | lodash.flowRight = flowRight;
|
19883 | lodash.forEach = forEach;
|
19884 | lodash.forEachRight = forEachRight;
|
19885 | lodash.forIn = forIn;
|
19886 | lodash.forInRight = forInRight;
|
19887 | lodash.forOwn = forOwn;
|
19888 | lodash.forOwnRight = forOwnRight;
|
19889 | lodash.functions = functions;
|
19890 | lodash.groupBy = groupBy;
|
19891 | lodash.indexBy = indexBy;
|
19892 | lodash.initial = initial;
|
19893 | lodash.intersection = intersection;
|
19894 | lodash.invert = invert;
|
19895 | lodash.invoke = invoke;
|
19896 | lodash.keys = keys;
|
19897 | lodash.keysIn = keysIn;
|
19898 | lodash.map = map;
|
19899 | lodash.mapKeys = mapKeys;
|
19900 | lodash.mapValues = mapValues;
|
19901 | lodash.matches = matches;
|
19902 | lodash.matchesProperty = matchesProperty;
|
19903 | lodash.memoize = memoize;
|
19904 | lodash.merge = merge;
|
19905 | lodash.method = method;
|
19906 | lodash.methodOf = methodOf;
|
19907 | lodash.mixin = mixin;
|
19908 | lodash.modArgs = modArgs;
|
19909 | lodash.negate = negate;
|
19910 | lodash.omit = omit;
|
19911 | lodash.once = once;
|
19912 | lodash.pairs = pairs;
|
19913 | lodash.partial = partial;
|
19914 | lodash.partialRight = partialRight;
|
19915 | lodash.partition = partition;
|
19916 | lodash.pick = pick;
|
19917 | lodash.pluck = pluck;
|
19918 | lodash.property = property;
|
19919 | lodash.propertyOf = propertyOf;
|
19920 | lodash.pull = pull;
|
19921 | lodash.pullAt = pullAt;
|
19922 | lodash.range = range;
|
19923 | lodash.rearg = rearg;
|
19924 | lodash.reject = reject;
|
19925 | lodash.remove = remove;
|
19926 | lodash.rest = rest;
|
19927 | lodash.restParam = restParam;
|
19928 | lodash.set = set;
|
19929 | lodash.shuffle = shuffle;
|
19930 | lodash.slice = slice;
|
19931 | lodash.sortBy = sortBy;
|
19932 | lodash.sortByAll = sortByAll;
|
19933 | lodash.sortByOrder = sortByOrder;
|
19934 | lodash.spread = spread;
|
19935 | lodash.take = take;
|
19936 | lodash.takeRight = takeRight;
|
19937 | lodash.takeRightWhile = takeRightWhile;
|
19938 | lodash.takeWhile = takeWhile;
|
19939 | lodash.tap = tap;
|
19940 | lodash.throttle = throttle;
|
19941 | lodash.thru = thru;
|
19942 | lodash.times = times;
|
19943 | lodash.toArray = toArray;
|
19944 | lodash.toPlainObject = toPlainObject;
|
19945 | lodash.transform = transform;
|
19946 | lodash.union = union;
|
19947 | lodash.uniq = uniq;
|
19948 | lodash.unzip = unzip;
|
19949 | lodash.unzipWith = unzipWith;
|
19950 | lodash.values = values;
|
19951 | lodash.valuesIn = valuesIn;
|
19952 | lodash.where = where;
|
19953 | lodash.without = without;
|
19954 | lodash.wrap = wrap;
|
19955 | lodash.xor = xor;
|
19956 | lodash.zip = zip;
|
19957 | lodash.zipObject = zipObject;
|
19958 | lodash.zipWith = zipWith;
|
19959 |
|
19960 | // Add aliases.
|
19961 | lodash.backflow = flowRight;
|
19962 | lodash.collect = map;
|
19963 | lodash.compose = flowRight;
|
19964 | lodash.each = forEach;
|
19965 | lodash.eachRight = forEachRight;
|
19966 | lodash.extend = assign;
|
19967 | lodash.iteratee = callback;
|
19968 | lodash.methods = functions;
|
19969 | lodash.object = zipObject;
|
19970 | lodash.select = filter;
|
19971 | lodash.tail = rest;
|
19972 | lodash.unique = uniq;
|
19973 |
|
19974 | // Add functions to `lodash.prototype`.
|
19975 | mixin(lodash, lodash);
|
19976 |
|
19977 | /*------------------------------------------------------------------------*/
|
19978 |
|
19979 | // Add functions that return unwrapped values when chaining.
|
19980 | lodash.add = add;
|
19981 | lodash.attempt = attempt;
|
19982 | lodash.camelCase = camelCase;
|
19983 | lodash.capitalize = capitalize;
|
19984 | lodash.ceil = ceil;
|
19985 | lodash.clone = clone;
|
19986 | lodash.cloneDeep = cloneDeep;
|
19987 | lodash.deburr = deburr;
|
19988 | lodash.endsWith = endsWith;
|
19989 | lodash.escape = escape;
|
19990 | lodash.escapeRegExp = escapeRegExp;
|
19991 | lodash.every = every;
|
19992 | lodash.find = find;
|
19993 | lodash.findIndex = findIndex;
|
19994 | lodash.findKey = findKey;
|
19995 | lodash.findLast = findLast;
|
19996 | lodash.findLastIndex = findLastIndex;
|
19997 | lodash.findLastKey = findLastKey;
|
19998 | lodash.findWhere = findWhere;
|
19999 | lodash.first = first;
|
20000 | lodash.floor = floor;
|
20001 | lodash.get = get;
|
20002 | lodash.gt = gt;
|
20003 | lodash.gte = gte;
|
20004 | lodash.has = has;
|
20005 | lodash.identity = identity;
|
20006 | lodash.includes = includes;
|
20007 | lodash.indexOf = indexOf;
|
20008 | lodash.inRange = inRange;
|
20009 | lodash.isArguments = isArguments;
|
20010 | lodash.isArray = isArray;
|
20011 | lodash.isBoolean = isBoolean;
|
20012 | lodash.isDate = isDate;
|
20013 | lodash.isElement = isElement;
|
20014 | lodash.isEmpty = isEmpty;
|
20015 | lodash.isEqual = isEqual;
|
20016 | lodash.isError = isError;
|
20017 | lodash.isFinite = isFinite;
|
20018 | lodash.isFunction = isFunction;
|
20019 | lodash.isMatch = isMatch;
|
20020 | lodash.isNaN = isNaN;
|
20021 | lodash.isNative = isNative;
|
20022 | lodash.isNull = isNull;
|
20023 | lodash.isNumber = isNumber;
|
20024 | lodash.isObject = isObject;
|
20025 | lodash.isPlainObject = isPlainObject;
|
20026 | lodash.isRegExp = isRegExp;
|
20027 | lodash.isString = isString;
|
20028 | lodash.isTypedArray = isTypedArray;
|
20029 | lodash.isUndefined = isUndefined;
|
20030 | lodash.kebabCase = kebabCase;
|
20031 | lodash.last = last;
|
20032 | lodash.lastIndexOf = lastIndexOf;
|
20033 | lodash.lt = lt;
|
20034 | lodash.lte = lte;
|
20035 | lodash.max = max;
|
20036 | lodash.min = min;
|
20037 | lodash.noConflict = noConflict;
|
20038 | lodash.noop = noop;
|
20039 | lodash.now = now;
|
20040 | lodash.pad = pad;
|
20041 | lodash.padLeft = padLeft;
|
20042 | lodash.padRight = padRight;
|
20043 | lodash.parseInt = parseInt;
|
20044 | lodash.random = random;
|
20045 | lodash.reduce = reduce;
|
20046 | lodash.reduceRight = reduceRight;
|
20047 | lodash.repeat = repeat;
|
20048 | lodash.result = result;
|
20049 | lodash.round = round;
|
20050 | lodash.runInContext = runInContext;
|
20051 | lodash.size = size;
|
20052 | lodash.snakeCase = snakeCase;
|
20053 | lodash.some = some;
|
20054 | lodash.sortedIndex = sortedIndex;
|
20055 | lodash.sortedLastIndex = sortedLastIndex;
|
20056 | lodash.startCase = startCase;
|
20057 | lodash.startsWith = startsWith;
|
20058 | lodash.sum = sum;
|
20059 | lodash.template = template;
|
20060 | lodash.trim = trim;
|
20061 | lodash.trimLeft = trimLeft;
|
20062 | lodash.trimRight = trimRight;
|
20063 | lodash.trunc = trunc;
|
20064 | lodash.unescape = unescape;
|
20065 | lodash.uniqueId = uniqueId;
|
20066 | lodash.words = words;
|
20067 |
|
20068 | // Add aliases.
|
20069 | lodash.all = every;
|
20070 | lodash.any = some;
|
20071 | lodash.contains = includes;
|
20072 | lodash.eq = isEqual;
|
20073 | lodash.detect = find;
|
20074 | lodash.foldl = reduce;
|
20075 | lodash.foldr = reduceRight;
|
20076 | lodash.head = first;
|
20077 | lodash.include = includes;
|
20078 | lodash.inject = reduce;
|
20079 |
|
20080 | mixin(lodash, (function() {
|
20081 | var source = {};
|
20082 | baseForOwn(lodash, function(func, methodName) {
|
20083 | if (!lodash.prototype[methodName]) {
|
20084 | source[methodName] = func;
|
20085 | }
|
20086 | });
|
20087 | return source;
|
20088 | }()), false);
|
20089 |
|
20090 |
|
20091 |
|
20092 |
|
20093 | lodash.sample = sample;
|
20094 |
|
20095 | lodash.prototype.sample = function(n) {
|
20096 | if (!this.__chain__ && n == null) {
|
20097 | return sample(this.value());
|
20098 | }
|
20099 | return this.thru(function(value) {
|
20100 | return sample(value, n);
|
20101 | });
|
20102 | };
|
20103 |
|
20104 |
|
20105 |
|
20106 | |
20107 |
|
20108 |
|
20109 |
|
20110 |
|
20111 |
|
20112 |
|
20113 | lodash.VERSION = VERSION;
|
20114 |
|
20115 |
|
20116 | arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
|
20117 | lodash[methodName].placeholder = lodash;
|
20118 | });
|
20119 |
|
20120 |
|
20121 | arrayEach(['drop', 'take'], function(methodName, index) {
|
20122 | LazyWrapper.prototype[methodName] = function(n) {
|
20123 | var filtered = this.__filtered__;
|
20124 | if (filtered && !index) {
|
20125 | return new LazyWrapper(this);
|
20126 | }
|
20127 | n = n == null ? 1 : nativeMax(nativeFloor(n) || 0, 0);
|
20128 |
|
20129 | var result = this.clone();
|
20130 | if (filtered) {
|
20131 | result.__takeCount__ = nativeMin(result.__takeCount__, n);
|
20132 | } else {
|
20133 | result.__views__.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });
|
20134 | }
|
20135 | return result;
|
20136 | };
|
20137 |
|
20138 | LazyWrapper.prototype[methodName + 'Right'] = function(n) {
|
20139 | return this.reverse()[methodName](n).reverse();
|
20140 | };
|
20141 | });
|
20142 |
|
20143 |
|
20144 | arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
|
20145 | var type = index + 1,
|
20146 | isFilter = type != LAZY_MAP_FLAG;
|
20147 |
|
20148 | LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
|
20149 | var result = this.clone();
|
20150 | result.__iteratees__.push({ 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type });
|
20151 | result.__filtered__ = result.__filtered__ || isFilter;
|
20152 | return result;
|
20153 | };
|
20154 | });
|
20155 |
|
20156 |
|
20157 | arrayEach(['first', 'last'], function(methodName, index) {
|
20158 | var takeName = 'take' + (index ? 'Right' : '');
|
20159 |
|
20160 | LazyWrapper.prototype[methodName] = function() {
|
20161 | return this[takeName](1).value()[0];
|
20162 | };
|
20163 | });
|
20164 |
|
20165 |
|
20166 | arrayEach(['initial', 'rest'], function(methodName, index) {
|
20167 | var dropName = 'drop' + (index ? '' : 'Right');
|
20168 |
|
20169 | LazyWrapper.prototype[methodName] = function() {
|
20170 | return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
|
20171 | };
|
20172 | });
|
20173 |
|
20174 |
|
20175 | arrayEach(['pluck', 'where'], function(methodName, index) {
|
20176 | var operationName = index ? 'filter' : 'map',
|
20177 | createCallback = index ? baseMatches : property;
|
20178 |
|
20179 | LazyWrapper.prototype[methodName] = function(value) {
|
20180 | return this[operationName](createCallback(value));
|
20181 | };
|
20182 | });
|
20183 |
|
20184 | LazyWrapper.prototype.compact = function() {
|
20185 | return this.filter(identity);
|
20186 | };
|
20187 |
|
20188 | LazyWrapper.prototype.reject = function(predicate, thisArg) {
|
20189 | predicate = getCallback(predicate, thisArg, 1);
|
20190 | return this.filter(function(value) {
|
20191 | return !predicate(value);
|
20192 | });
|
20193 | };
|
20194 |
|
20195 | LazyWrapper.prototype.slice = function(start, end) {
|
20196 | start = start == null ? 0 : (+start || 0);
|
20197 |
|
20198 | var result = this;
|
20199 | if (result.__filtered__ && (start > 0 || end < 0)) {
|
20200 | return new LazyWrapper(result);
|
20201 | }
|
20202 | if (start < 0) {
|
20203 | result = result.takeRight(-start);
|
20204 | } else if (start) {
|
20205 | result = result.drop(start);
|
20206 | }
|
20207 | if (end !== undefined) {
|
20208 | end = (+end || 0);
|
20209 | result = end < 0 ? result.dropRight(-end) : result.take(end - start);
|
20210 | }
|
20211 | return result;
|
20212 | };
|
20213 |
|
20214 | LazyWrapper.prototype.takeRightWhile = function(predicate, thisArg) {
|
20215 | return this.reverse().takeWhile(predicate, thisArg).reverse();
|
20216 | };
|
20217 |
|
20218 | LazyWrapper.prototype.toArray = function() {
|
20219 | return this.take(POSITIVE_INFINITY);
|
20220 | };
|
20221 |
|
20222 |
|
20223 | baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
20224 | var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),
|
20225 | retUnwrapped = /^(?:first|last)$/.test(methodName),
|
20226 | lodashFunc = lodash[retUnwrapped ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName];
|
20227 |
|
20228 | if (!lodashFunc) {
|
20229 | return;
|
20230 | }
|
20231 | lodash.prototype[methodName] = function() {
|
20232 | var args = retUnwrapped ? [1] : arguments,
|
20233 | chainAll = this.__chain__,
|
20234 | value = this.__wrapped__,
|
20235 | isHybrid = !!this.__actions__.length,
|
20236 | isLazy = value instanceof LazyWrapper,
|
20237 | iteratee = args[0],
|
20238 | useLazy = isLazy || isArray(value);
|
20239 |
|
20240 | if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
|
20241 |
|
20242 | isLazy = useLazy = false;
|
20243 | }
|
20244 | var interceptor = function(value) {
|
20245 | return (retUnwrapped && chainAll)
|
20246 | ? lodashFunc(value, 1)[0]
|
20247 | : lodashFunc.apply(undefined, arrayPush([value], args));
|
20248 | };
|
20249 |
|
20250 | var action = { 'func': thru, 'args': [interceptor], 'thisArg': undefined },
|
20251 | onlyLazy = isLazy && !isHybrid;
|
20252 |
|
20253 | if (retUnwrapped && !chainAll) {
|
20254 | if (onlyLazy) {
|
20255 | value = value.clone();
|
20256 | value.__actions__.push(action);
|
20257 | return func.call(value);
|
20258 | }
|
20259 | return lodashFunc.call(undefined, this.value())[0];
|
20260 | }
|
20261 | if (!retUnwrapped && useLazy) {
|
20262 | value = onlyLazy ? value : new LazyWrapper(this);
|
20263 | var result = func.apply(value, args);
|
20264 | result.__actions__.push(action);
|
20265 | return new LodashWrapper(result, chainAll);
|
20266 | }
|
20267 | return this.thru(interceptor);
|
20268 | };
|
20269 | });
|
20270 |
|
20271 |
|
20272 | arrayEach(['join', 'pop', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) {
|
20273 | var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName],
|
20274 | chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
|
20275 | retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName);
|
20276 |
|
20277 | lodash.prototype[methodName] = function() {
|
20278 | var args = arguments;
|
20279 | if (retUnwrapped && !this.__chain__) {
|
20280 | return func.apply(this.value(), args);
|
20281 | }
|
20282 | return this[chainName](function(value) {
|
20283 | return func.apply(value, args);
|
20284 | });
|
20285 | };
|
20286 | });
|
20287 |
|
20288 |
|
20289 | baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
20290 | var lodashFunc = lodash[methodName];
|
20291 | if (lodashFunc) {
|
20292 | var key = lodashFunc.name,
|
20293 | names = realNames[key] || (realNames[key] = []);
|
20294 |
|
20295 | names.push({ 'name': methodName, 'func': lodashFunc });
|
20296 | }
|
20297 | });
|
20298 |
|
20299 | realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': undefined }];
|
20300 |
|
20301 |
|
20302 | LazyWrapper.prototype.clone = lazyClone;
|
20303 | LazyWrapper.prototype.reverse = lazyReverse;
|
20304 | LazyWrapper.prototype.value = lazyValue;
|
20305 |
|
20306 |
|
20307 | lodash.prototype.chain = wrapperChain;
|
20308 | lodash.prototype.commit = wrapperCommit;
|
20309 | lodash.prototype.concat = wrapperConcat;
|
20310 | lodash.prototype.plant = wrapperPlant;
|
20311 | lodash.prototype.reverse = wrapperReverse;
|
20312 | lodash.prototype.toString = wrapperToString;
|
20313 | lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
|
20314 |
|
20315 |
|
20316 | lodash.prototype.collect = lodash.prototype.map;
|
20317 | lodash.prototype.head = lodash.prototype.first;
|
20318 | lodash.prototype.select = lodash.prototype.filter;
|
20319 | lodash.prototype.tail = lodash.prototype.rest;
|
20320 |
|
20321 | return lodash;
|
20322 | }
|
20323 |
|
20324 |
|
20325 |
|
20326 |
|
20327 | var _ = runInContext();
|
20328 |
|
20329 |
|
20330 | if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
20331 |
|
20332 |
|
20333 |
|
20334 |
|
20335 | root._ = _;
|
20336 |
|
20337 |
|
20338 |
|
20339 | define(function() {
|
20340 | return _;
|
20341 | });
|
20342 | }
|
20343 |
|
20344 | else if (freeExports && freeModule) {
|
20345 |
|
20346 | if (moduleExports) {
|
20347 | (freeModule.exports = _)._ = _;
|
20348 | }
|
20349 |
|
20350 | else {
|
20351 | freeExports._ = _;
|
20352 | }
|
20353 | }
|
20354 | else {
|
20355 |
|
20356 | root._ = _;
|
20357 | }
|
20358 | }.call(this));
|
20359 |
|
20360 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
20361 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/index.js":[function(require,module,exports){
|
20362 |
|
20363 |
|
20364 |
|
20365 |
|
20366 |
|
20367 | var url = require('./url');
|
20368 | var parser = require('socket.io-parser');
|
20369 | var Manager = require('./manager');
|
20370 | var debug = require('debug')('socket.io-client');
|
20371 |
|
20372 |
|
20373 |
|
20374 |
|
20375 |
|
20376 | module.exports = exports = lookup;
|
20377 |
|
20378 |
|
20379 |
|
20380 |
|
20381 |
|
20382 | var cache = exports.managers = {};
|
20383 |
|
20384 |
|
20385 |
|
20386 |
|
20387 |
|
20388 |
|
20389 |
|
20390 |
|
20391 |
|
20392 |
|
20393 |
|
20394 |
|
20395 |
|
20396 |
|
20397 | function lookup(uri, opts) {
|
20398 | if (typeof uri == 'object') {
|
20399 | opts = uri;
|
20400 | uri = undefined;
|
20401 | }
|
20402 |
|
20403 | opts = opts || {};
|
20404 |
|
20405 | var parsed = url(uri);
|
20406 | var source = parsed.source;
|
20407 | var id = parsed.id;
|
20408 | var path = parsed.path;
|
20409 | var sameNamespace = cache[id] && path in cache[id].nsps;
|
20410 | var newConnection = opts.forceNew || opts['force new connection'] ||
|
20411 | false === opts.multiplex || sameNamespace;
|
20412 |
|
20413 | var io;
|
20414 |
|
20415 | if (newConnection) {
|
20416 | debug('ignoring socket cache for %s', source);
|
20417 | io = Manager(source, opts);
|
20418 | } else {
|
20419 | if (!cache[id]) {
|
20420 | debug('new io instance for %s', source);
|
20421 | cache[id] = Manager(source, opts);
|
20422 | }
|
20423 | io = cache[id];
|
20424 | }
|
20425 |
|
20426 | return io.socket(parsed.path);
|
20427 | }
|
20428 |
|
20429 |
|
20430 |
|
20431 |
|
20432 |
|
20433 |
|
20434 |
|
20435 | exports.protocol = parser.protocol;
|
20436 |
|
20437 |
|
20438 |
|
20439 |
|
20440 |
|
20441 |
|
20442 |
|
20443 |
|
20444 | exports.connect = lookup;
|
20445 |
|
20446 |
|
20447 |
|
20448 |
|
20449 |
|
20450 |
|
20451 |
|
20452 | exports.Manager = require('./manager');
|
20453 | exports.Socket = require('./socket');
|
20454 |
|
20455 | },{"./manager":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/manager.js","./socket":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/socket.js","./url":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/url.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","socket.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/manager.js":[function(require,module,exports){
|
20456 |
|
20457 |
|
20458 |
|
20459 |
|
20460 |
|
20461 | var eio = require('engine.io-client');
|
20462 | var Socket = require('./socket');
|
20463 | var Emitter = require('component-emitter');
|
20464 | var parser = require('socket.io-parser');
|
20465 | var on = require('./on');
|
20466 | var bind = require('component-bind');
|
20467 | var debug = require('debug')('socket.io-client:manager');
|
20468 | var indexOf = require('indexof');
|
20469 | var Backoff = require('backo2');
|
20470 |
|
20471 |
|
20472 |
|
20473 |
|
20474 |
|
20475 | var has = Object.prototype.hasOwnProperty;
|
20476 |
|
20477 |
|
20478 |
|
20479 |
|
20480 |
|
20481 | module.exports = Manager;
|
20482 |
|
20483 |
|
20484 |
|
20485 |
|
20486 |
|
20487 |
|
20488 |
|
20489 |
|
20490 |
|
20491 | function Manager(uri, opts){
|
20492 | if (!(this instanceof Manager)) return new Manager(uri, opts);
|
20493 | if (uri && ('object' == typeof uri)) {
|
20494 | opts = uri;
|
20495 | uri = undefined;
|
20496 | }
|
20497 | opts = opts || {};
|
20498 |
|
20499 | opts.path = opts.path || '/socket.io';
|
20500 | this.nsps = {};
|
20501 | this.subs = [];
|
20502 | this.opts = opts;
|
20503 | this.reconnection(opts.reconnection !== false);
|
20504 | this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
|
20505 | this.reconnectionDelay(opts.reconnectionDelay || 1000);
|
20506 | this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
|
20507 | this.randomizationFactor(opts.randomizationFactor || 0.5);
|
20508 | this.backoff = new Backoff({
|
20509 | min: this.reconnectionDelay(),
|
20510 | max: this.reconnectionDelayMax(),
|
20511 | jitter: this.randomizationFactor()
|
20512 | });
|
20513 | this.timeout(null == opts.timeout ? 20000 : opts.timeout);
|
20514 | this.readyState = 'closed';
|
20515 | this.uri = uri;
|
20516 | this.connecting = [];
|
20517 | this.lastPing = null;
|
20518 | this.encoding = false;
|
20519 | this.packetBuffer = [];
|
20520 | this.encoder = new parser.Encoder();
|
20521 | this.decoder = new parser.Decoder();
|
20522 | this.autoConnect = opts.autoConnect !== false;
|
20523 | if (this.autoConnect) this.open();
|
20524 | }
|
20525 |
|
20526 |
|
20527 |
|
20528 |
|
20529 |
|
20530 |
|
20531 |
|
20532 | Manager.prototype.emitAll = function() {
|
20533 | this.emit.apply(this, arguments);
|
20534 | for (var nsp in this.nsps) {
|
20535 | if (has.call(this.nsps, nsp)) {
|
20536 | this.nsps[nsp].emit.apply(this.nsps[nsp], arguments);
|
20537 | }
|
20538 | }
|
20539 | };
|
20540 |
|
20541 |
|
20542 |
|
20543 |
|
20544 |
|
20545 |
|
20546 |
|
20547 | Manager.prototype.updateSocketIds = function(){
|
20548 | for (var nsp in this.nsps) {
|
20549 | if (has.call(this.nsps, nsp)) {
|
20550 | this.nsps[nsp].id = this.engine.id;
|
20551 | }
|
20552 | }
|
20553 | };
|
20554 |
|
20555 |
|
20556 |
|
20557 |
|
20558 |
|
20559 | Emitter(Manager.prototype);
|
20560 |
|
20561 |
|
20562 |
|
20563 |
|
20564 |
|
20565 |
|
20566 |
|
20567 |
|
20568 |
|
20569 | Manager.prototype.reconnection = function(v){
|
20570 | if (!arguments.length) return this._reconnection;
|
20571 | this._reconnection = !!v;
|
20572 | return this;
|
20573 | };
|
20574 |
|
20575 |
|
20576 |
|
20577 |
|
20578 |
|
20579 |
|
20580 |
|
20581 |
|
20582 |
|
20583 | Manager.prototype.reconnectionAttempts = function(v){
|
20584 | if (!arguments.length) return this._reconnectionAttempts;
|
20585 | this._reconnectionAttempts = v;
|
20586 | return this;
|
20587 | };
|
20588 |
|
20589 |
|
20590 |
|
20591 |
|
20592 |
|
20593 |
|
20594 |
|
20595 |
|
20596 |
|
20597 | Manager.prototype.reconnectionDelay = function(v){
|
20598 | if (!arguments.length) return this._reconnectionDelay;
|
20599 | this._reconnectionDelay = v;
|
20600 | this.backoff && this.backoff.setMin(v);
|
20601 | return this;
|
20602 | };
|
20603 |
|
20604 | Manager.prototype.randomizationFactor = function(v){
|
20605 | if (!arguments.length) return this._randomizationFactor;
|
20606 | this._randomizationFactor = v;
|
20607 | this.backoff && this.backoff.setJitter(v);
|
20608 | return this;
|
20609 | };
|
20610 |
|
20611 |
|
20612 |
|
20613 |
|
20614 |
|
20615 |
|
20616 |
|
20617 |
|
20618 |
|
20619 | Manager.prototype.reconnectionDelayMax = function(v){
|
20620 | if (!arguments.length) return this._reconnectionDelayMax;
|
20621 | this._reconnectionDelayMax = v;
|
20622 | this.backoff && this.backoff.setMax(v);
|
20623 | return this;
|
20624 | };
|
20625 |
|
20626 |
|
20627 |
|
20628 |
|
20629 |
|
20630 |
|
20631 |
|
20632 |
|
20633 | Manager.prototype.timeout = function(v){
|
20634 | if (!arguments.length) return this._timeout;
|
20635 | this._timeout = v;
|
20636 | return this;
|
20637 | };
|
20638 |
|
20639 |
|
20640 |
|
20641 |
|
20642 |
|
20643 |
|
20644 |
|
20645 |
|
20646 | Manager.prototype.maybeReconnectOnOpen = function() {
|
20647 |
|
20648 | if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) {
|
20649 |
|
20650 | this.reconnect();
|
20651 | }
|
20652 | };
|
20653 |
|
20654 |
|
20655 |
|
20656 |
|
20657 |
|
20658 |
|
20659 |
|
20660 |
|
20661 |
|
20662 |
|
20663 | Manager.prototype.open =
|
20664 | Manager.prototype.connect = function(fn){
|
20665 | debug('readyState %s', this.readyState);
|
20666 | if (~this.readyState.indexOf('open')) return this;
|
20667 |
|
20668 | debug('opening %s', this.uri);
|
20669 | this.engine = eio(this.uri, this.opts);
|
20670 | var socket = this.engine;
|
20671 | var self = this;
|
20672 | this.readyState = 'opening';
|
20673 | this.skipReconnect = false;
|
20674 |
|
20675 |
|
20676 | var openSub = on(socket, 'open', function() {
|
20677 | self.onopen();
|
20678 | fn && fn();
|
20679 | });
|
20680 |
|
20681 |
|
20682 | var errorSub = on(socket, 'error', function(data){
|
20683 | debug('connect_error');
|
20684 | self.cleanup();
|
20685 | self.readyState = 'closed';
|
20686 | self.emitAll('connect_error', data);
|
20687 | if (fn) {
|
20688 | var err = new Error('Connection error');
|
20689 | err.data = data;
|
20690 | fn(err);
|
20691 | } else {
|
20692 |
|
20693 | self.maybeReconnectOnOpen();
|
20694 | }
|
20695 | });
|
20696 |
|
20697 |
|
20698 | if (false !== this._timeout) {
|
20699 | var timeout = this._timeout;
|
20700 | debug('connect attempt will timeout after %d', timeout);
|
20701 |
|
20702 |
|
20703 | var timer = setTimeout(function(){
|
20704 | debug('connect attempt timed out after %d', timeout);
|
20705 | openSub.destroy();
|
20706 | socket.close();
|
20707 | socket.emit('error', 'timeout');
|
20708 | self.emitAll('connect_timeout', timeout);
|
20709 | }, timeout);
|
20710 |
|
20711 | this.subs.push({
|
20712 | destroy: function(){
|
20713 | clearTimeout(timer);
|
20714 | }
|
20715 | });
|
20716 | }
|
20717 |
|
20718 | this.subs.push(openSub);
|
20719 | this.subs.push(errorSub);
|
20720 |
|
20721 | return this;
|
20722 | };
|
20723 |
|
20724 |
|
20725 |
|
20726 |
|
20727 |
|
20728 |
|
20729 |
|
20730 | Manager.prototype.onopen = function(){
|
20731 | debug('open');
|
20732 |
|
20733 |
|
20734 | this.cleanup();
|
20735 |
|
20736 |
|
20737 | this.readyState = 'open';
|
20738 | this.emit('open');
|
20739 |
|
20740 |
|
20741 | var socket = this.engine;
|
20742 | this.subs.push(on(socket, 'data', bind(this, 'ondata')));
|
20743 | this.subs.push(on(socket, 'ping', bind(this, 'onping')));
|
20744 | this.subs.push(on(socket, 'pong', bind(this, 'onpong')));
|
20745 | this.subs.push(on(socket, 'error', bind(this, 'onerror')));
|
20746 | this.subs.push(on(socket, 'close', bind(this, 'onclose')));
|
20747 | this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded')));
|
20748 | };
|
20749 |
|
20750 |
|
20751 |
|
20752 |
|
20753 |
|
20754 |
|
20755 |
|
20756 | Manager.prototype.onping = function(){
|
20757 | this.lastPing = new Date;
|
20758 | this.emitAll('ping');
|
20759 | };
|
20760 |
|
20761 |
|
20762 |
|
20763 |
|
20764 |
|
20765 |
|
20766 |
|
20767 | Manager.prototype.onpong = function(){
|
20768 | this.emitAll('pong', new Date - this.lastPing);
|
20769 | };
|
20770 |
|
20771 |
|
20772 |
|
20773 |
|
20774 |
|
20775 |
|
20776 |
|
20777 | Manager.prototype.ondata = function(data){
|
20778 | this.decoder.add(data);
|
20779 | };
|
20780 |
|
20781 |
|
20782 |
|
20783 |
|
20784 |
|
20785 |
|
20786 |
|
20787 | Manager.prototype.ondecoded = function(packet) {
|
20788 | this.emit('packet', packet);
|
20789 | };
|
20790 |
|
20791 |
|
20792 |
|
20793 |
|
20794 |
|
20795 |
|
20796 |
|
20797 | Manager.prototype.onerror = function(err){
|
20798 | debug('error', err);
|
20799 | this.emitAll('error', err);
|
20800 | };
|
20801 |
|
20802 |
|
20803 |
|
20804 |
|
20805 |
|
20806 |
|
20807 |
|
20808 |
|
20809 | Manager.prototype.socket = function(nsp){
|
20810 | var socket = this.nsps[nsp];
|
20811 | if (!socket) {
|
20812 | socket = new Socket(this, nsp);
|
20813 | this.nsps[nsp] = socket;
|
20814 | var self = this;
|
20815 | socket.on('connecting', onConnecting);
|
20816 | socket.on('connect', function(){
|
20817 | socket.id = self.engine.id;
|
20818 | });
|
20819 |
|
20820 | if (this.autoConnect) {
|
20821 |
|
20822 | onConnecting();
|
20823 | }
|
20824 | }
|
20825 |
|
20826 | function onConnecting() {
|
20827 | if (!~indexOf(self.connecting, socket)) {
|
20828 | self.connecting.push(socket);
|
20829 | }
|
20830 | }
|
20831 |
|
20832 | return socket;
|
20833 | };
|
20834 |
|
20835 |
|
20836 |
|
20837 |
|
20838 |
|
20839 |
|
20840 |
|
20841 | Manager.prototype.destroy = function(socket){
|
20842 | var index = indexOf(this.connecting, socket);
|
20843 | if (~index) this.connecting.splice(index, 1);
|
20844 | if (this.connecting.length) return;
|
20845 |
|
20846 | this.close();
|
20847 | };
|
20848 |
|
20849 |
|
20850 |
|
20851 |
|
20852 |
|
20853 |
|
20854 |
|
20855 |
|
20856 | Manager.prototype.packet = function(packet){
|
20857 | debug('writing packet %j', packet);
|
20858 | var self = this;
|
20859 |
|
20860 | if (!self.encoding) {
|
20861 |
|
20862 | self.encoding = true;
|
20863 | this.encoder.encode(packet, function(encodedPackets) {
|
20864 | for (var i = 0; i < encodedPackets.length; i++) {
|
20865 | self.engine.write(encodedPackets[i], packet.options);
|
20866 | }
|
20867 | self.encoding = false;
|
20868 | self.processPacketQueue();
|
20869 | });
|
20870 | } else {
|
20871 | self.packetBuffer.push(packet);
|
20872 | }
|
20873 | };
|
20874 |
|
20875 |
|
20876 |
|
20877 |
|
20878 |
|
20879 |
|
20880 |
|
20881 |
|
20882 | Manager.prototype.processPacketQueue = function() {
|
20883 | if (this.packetBuffer.length > 0 && !this.encoding) {
|
20884 | var pack = this.packetBuffer.shift();
|
20885 | this.packet(pack);
|
20886 | }
|
20887 | };
|
20888 |
|
20889 |
|
20890 |
|
20891 |
|
20892 |
|
20893 |
|
20894 |
|
20895 | Manager.prototype.cleanup = function(){
|
20896 | debug('cleanup');
|
20897 |
|
20898 | var sub;
|
20899 | while (sub = this.subs.shift()) sub.destroy();
|
20900 |
|
20901 | this.packetBuffer = [];
|
20902 | this.encoding = false;
|
20903 | this.lastPing = null;
|
20904 |
|
20905 | this.decoder.destroy();
|
20906 | };
|
20907 |
|
20908 |
|
20909 |
|
20910 |
|
20911 |
|
20912 |
|
20913 |
|
20914 | Manager.prototype.close =
|
20915 | Manager.prototype.disconnect = function(){
|
20916 | debug('disconnect');
|
20917 | this.skipReconnect = true;
|
20918 | this.reconnecting = false;
|
20919 | if ('opening' == this.readyState) {
|
20920 |
|
20921 |
|
20922 | this.cleanup();
|
20923 | }
|
20924 | this.backoff.reset();
|
20925 | this.readyState = 'closed';
|
20926 | if (this.engine) this.engine.close();
|
20927 | };
|
20928 |
|
20929 |
|
20930 |
|
20931 |
|
20932 |
|
20933 |
|
20934 |
|
20935 | Manager.prototype.onclose = function(reason){
|
20936 | debug('onclose');
|
20937 |
|
20938 | this.cleanup();
|
20939 | this.backoff.reset();
|
20940 | this.readyState = 'closed';
|
20941 | this.emit('close', reason);
|
20942 |
|
20943 | if (this._reconnection && !this.skipReconnect) {
|
20944 | this.reconnect();
|
20945 | }
|
20946 | };
|
20947 |
|
20948 |
|
20949 |
|
20950 |
|
20951 |
|
20952 |
|
20953 |
|
20954 | Manager.prototype.reconnect = function(){
|
20955 | if (this.reconnecting || this.skipReconnect) return this;
|
20956 |
|
20957 | var self = this;
|
20958 |
|
20959 | if (this.backoff.attempts >= this._reconnectionAttempts) {
|
20960 | debug('reconnect failed');
|
20961 | this.backoff.reset();
|
20962 | this.emitAll('reconnect_failed');
|
20963 | this.reconnecting = false;
|
20964 | } else {
|
20965 | var delay = this.backoff.duration();
|
20966 | debug('will wait %dms before reconnect attempt', delay);
|
20967 |
|
20968 | this.reconnecting = true;
|
20969 | var timer = setTimeout(function(){
|
20970 | if (self.skipReconnect) return;
|
20971 |
|
20972 | debug('attempting reconnect');
|
20973 | self.emitAll('reconnect_attempt', self.backoff.attempts);
|
20974 | self.emitAll('reconnecting', self.backoff.attempts);
|
20975 |
|
20976 |
|
20977 | if (self.skipReconnect) return;
|
20978 |
|
20979 | self.open(function(err){
|
20980 | if (err) {
|
20981 | debug('reconnect attempt error');
|
20982 | self.reconnecting = false;
|
20983 | self.reconnect();
|
20984 | self.emitAll('reconnect_error', err.data);
|
20985 | } else {
|
20986 | debug('reconnect success');
|
20987 | self.onreconnect();
|
20988 | }
|
20989 | });
|
20990 | }, delay);
|
20991 |
|
20992 | this.subs.push({
|
20993 | destroy: function(){
|
20994 | clearTimeout(timer);
|
20995 | }
|
20996 | });
|
20997 | }
|
20998 | };
|
20999 |
|
21000 |
|
21001 |
|
21002 |
|
21003 |
|
21004 |
|
21005 |
|
21006 | Manager.prototype.onreconnect = function(){
|
21007 | var attempt = this.backoff.attempts;
|
21008 | this.reconnecting = false;
|
21009 | this.backoff.reset();
|
21010 | this.updateSocketIds();
|
21011 | this.emitAll('reconnect', attempt);
|
21012 | };
|
21013 |
|
21014 | },{"./on":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/on.js","./socket":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/socket.js","backo2":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/backo2/index.js","component-bind":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/component-bind/index.js","component-emitter":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/component-emitter/index.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","engine.io-client":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/index.js","indexof":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/indexof/index.js","socket.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/on.js":[function(require,module,exports){
|
21015 |
|
21016 |
|
21017 |
|
21018 |
|
21019 |
|
21020 | module.exports = on;
|
21021 |
|
21022 |
|
21023 |
|
21024 |
|
21025 |
|
21026 |
|
21027 |
|
21028 |
|
21029 |
|
21030 |
|
21031 | function on(obj, ev, fn) {
|
21032 | obj.on(ev, fn);
|
21033 | return {
|
21034 | destroy: function(){
|
21035 | obj.removeListener(ev, fn);
|
21036 | }
|
21037 | };
|
21038 | }
|
21039 |
|
21040 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/socket.js":[function(require,module,exports){
|
21041 |
|
21042 |
|
21043 |
|
21044 |
|
21045 |
|
21046 | var parser = require('socket.io-parser');
|
21047 | var Emitter = require('component-emitter');
|
21048 | var toArray = require('to-array');
|
21049 | var on = require('./on');
|
21050 | var bind = require('component-bind');
|
21051 | var debug = require('debug')('socket.io-client:socket');
|
21052 | var hasBin = require('has-binary');
|
21053 |
|
21054 |
|
21055 |
|
21056 |
|
21057 |
|
21058 | module.exports = exports = Socket;
|
21059 |
|
21060 |
|
21061 |
|
21062 |
|
21063 |
|
21064 |
|
21065 |
|
21066 |
|
21067 | var events = {
|
21068 | connect: 1,
|
21069 | connect_error: 1,
|
21070 | connect_timeout: 1,
|
21071 | connecting: 1,
|
21072 | disconnect: 1,
|
21073 | error: 1,
|
21074 | reconnect: 1,
|
21075 | reconnect_attempt: 1,
|
21076 | reconnect_failed: 1,
|
21077 | reconnect_error: 1,
|
21078 | reconnecting: 1,
|
21079 | ping: 1,
|
21080 | pong: 1
|
21081 | };
|
21082 |
|
21083 |
|
21084 |
|
21085 |
|
21086 |
|
21087 | var emit = Emitter.prototype.emit;
|
21088 |
|
21089 |
|
21090 |
|
21091 |
|
21092 |
|
21093 |
|
21094 |
|
21095 | function Socket(io, nsp){
|
21096 | this.io = io;
|
21097 | this.nsp = nsp;
|
21098 | this.json = this;
|
21099 | this.ids = 0;
|
21100 | this.acks = {};
|
21101 | this.receiveBuffer = [];
|
21102 | this.sendBuffer = [];
|
21103 | this.connected = false;
|
21104 | this.disconnected = true;
|
21105 | if (this.io.autoConnect) this.open();
|
21106 | }
|
21107 |
|
21108 |
|
21109 |
|
21110 |
|
21111 |
|
21112 | Emitter(Socket.prototype);
|
21113 |
|
21114 |
|
21115 |
|
21116 |
|
21117 |
|
21118 |
|
21119 |
|
21120 | Socket.prototype.subEvents = function() {
|
21121 | if (this.subs) return;
|
21122 |
|
21123 | var io = this.io;
|
21124 | this.subs = [
|
21125 | on(io, 'open', bind(this, 'onopen')),
|
21126 | on(io, 'packet', bind(this, 'onpacket')),
|
21127 | on(io, 'close', bind(this, 'onclose'))
|
21128 | ];
|
21129 | };
|
21130 |
|
21131 |
|
21132 |
|
21133 |
|
21134 |
|
21135 |
|
21136 |
|
21137 | Socket.prototype.open =
|
21138 | Socket.prototype.connect = function(){
|
21139 | if (this.connected) return this;
|
21140 |
|
21141 | this.subEvents();
|
21142 | this.io.open();
|
21143 | if ('open' == this.io.readyState) this.onopen();
|
21144 | this.emit('connecting');
|
21145 | return this;
|
21146 | };
|
21147 |
|
21148 |
|
21149 |
|
21150 |
|
21151 |
|
21152 |
|
21153 |
|
21154 |
|
21155 | Socket.prototype.send = function(){
|
21156 | var args = toArray(arguments);
|
21157 | args.unshift('message');
|
21158 | this.emit.apply(this, args);
|
21159 | return this;
|
21160 | };
|
21161 |
|
21162 |
|
21163 |
|
21164 |
|
21165 |
|
21166 |
|
21167 |
|
21168 |
|
21169 |
|
21170 |
|
21171 | Socket.prototype.emit = function(ev){
|
21172 | if (events.hasOwnProperty(ev)) {
|
21173 | emit.apply(this, arguments);
|
21174 | return this;
|
21175 | }
|
21176 |
|
21177 | var args = toArray(arguments);
|
21178 | var parserType = parser.EVENT;
|
21179 | if (hasBin(args)) { parserType = parser.BINARY_EVENT; }
|
21180 | var packet = { type: parserType, data: args };
|
21181 |
|
21182 | packet.options = {};
|
21183 | packet.options.compress = !this.flags || false !== this.flags.compress;
|
21184 |
|
21185 |
|
21186 | if ('function' == typeof args[args.length - 1]) {
|
21187 | debug('emitting packet with ack id %d', this.ids);
|
21188 | this.acks[this.ids] = args.pop();
|
21189 | packet.id = this.ids++;
|
21190 | }
|
21191 |
|
21192 | if (this.connected) {
|
21193 | this.packet(packet);
|
21194 | } else {
|
21195 | this.sendBuffer.push(packet);
|
21196 | }
|
21197 |
|
21198 | delete this.flags;
|
21199 |
|
21200 | return this;
|
21201 | };
|
21202 |
|
21203 |
|
21204 |
|
21205 |
|
21206 |
|
21207 |
|
21208 |
|
21209 |
|
21210 | Socket.prototype.packet = function(packet){
|
21211 | packet.nsp = this.nsp;
|
21212 | this.io.packet(packet);
|
21213 | };
|
21214 |
|
21215 |
|
21216 |
|
21217 |
|
21218 |
|
21219 |
|
21220 |
|
21221 | Socket.prototype.onopen = function(){
|
21222 | debug('transport is open - connecting');
|
21223 |
|
21224 |
|
21225 | if ('/' != this.nsp) {
|
21226 | this.packet({ type: parser.CONNECT });
|
21227 | }
|
21228 | };
|
21229 |
|
21230 |
|
21231 |
|
21232 |
|
21233 |
|
21234 |
|
21235 |
|
21236 |
|
21237 | Socket.prototype.onclose = function(reason){
|
21238 | debug('close (%s)', reason);
|
21239 | this.connected = false;
|
21240 | this.disconnected = true;
|
21241 | delete this.id;
|
21242 | this.emit('disconnect', reason);
|
21243 | };
|
21244 |
|
21245 |
|
21246 |
|
21247 |
|
21248 |
|
21249 |
|
21250 |
|
21251 |
|
21252 | Socket.prototype.onpacket = function(packet){
|
21253 | if (packet.nsp != this.nsp) return;
|
21254 |
|
21255 | switch (packet.type) {
|
21256 | case parser.CONNECT:
|
21257 | this.onconnect();
|
21258 | break;
|
21259 |
|
21260 | case parser.EVENT:
|
21261 | this.onevent(packet);
|
21262 | break;
|
21263 |
|
21264 | case parser.BINARY_EVENT:
|
21265 | this.onevent(packet);
|
21266 | break;
|
21267 |
|
21268 | case parser.ACK:
|
21269 | this.onack(packet);
|
21270 | break;
|
21271 |
|
21272 | case parser.BINARY_ACK:
|
21273 | this.onack(packet);
|
21274 | break;
|
21275 |
|
21276 | case parser.DISCONNECT:
|
21277 | this.ondisconnect();
|
21278 | break;
|
21279 |
|
21280 | case parser.ERROR:
|
21281 | this.emit('error', packet.data);
|
21282 | break;
|
21283 | }
|
21284 | };
|
21285 |
|
21286 |
|
21287 |
|
21288 |
|
21289 |
|
21290 |
|
21291 |
|
21292 |
|
21293 | Socket.prototype.onevent = function(packet){
|
21294 | var args = packet.data || [];
|
21295 | debug('emitting event %j', args);
|
21296 |
|
21297 | if (null != packet.id) {
|
21298 | debug('attaching ack callback to event');
|
21299 | args.push(this.ack(packet.id));
|
21300 | }
|
21301 |
|
21302 | if (this.connected) {
|
21303 | emit.apply(this, args);
|
21304 | } else {
|
21305 | this.receiveBuffer.push(args);
|
21306 | }
|
21307 | };
|
21308 |
|
21309 |
|
21310 |
|
21311 |
|
21312 |
|
21313 |
|
21314 |
|
21315 | Socket.prototype.ack = function(id){
|
21316 | var self = this;
|
21317 | var sent = false;
|
21318 | return function(){
|
21319 |
|
21320 | if (sent) return;
|
21321 | sent = true;
|
21322 | var args = toArray(arguments);
|
21323 | debug('sending ack %j', args);
|
21324 |
|
21325 | var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK;
|
21326 | self.packet({
|
21327 | type: type,
|
21328 | id: id,
|
21329 | data: args
|
21330 | });
|
21331 | };
|
21332 | };
|
21333 |
|
21334 |
|
21335 |
|
21336 |
|
21337 |
|
21338 |
|
21339 |
|
21340 |
|
21341 | Socket.prototype.onack = function(packet){
|
21342 | var ack = this.acks[packet.id];
|
21343 | if ('function' == typeof ack) {
|
21344 | debug('calling ack %s with %j', packet.id, packet.data);
|
21345 | ack.apply(this, packet.data);
|
21346 | delete this.acks[packet.id];
|
21347 | } else {
|
21348 | debug('bad ack %s', packet.id);
|
21349 | }
|
21350 | };
|
21351 |
|
21352 |
|
21353 |
|
21354 |
|
21355 |
|
21356 |
|
21357 |
|
21358 | Socket.prototype.onconnect = function(){
|
21359 | this.connected = true;
|
21360 | this.disconnected = false;
|
21361 | this.emit('connect');
|
21362 | this.emitBuffered();
|
21363 | };
|
21364 |
|
21365 |
|
21366 |
|
21367 |
|
21368 |
|
21369 |
|
21370 |
|
21371 | Socket.prototype.emitBuffered = function(){
|
21372 | var i;
|
21373 | for (i = 0; i < this.receiveBuffer.length; i++) {
|
21374 | emit.apply(this, this.receiveBuffer[i]);
|
21375 | }
|
21376 | this.receiveBuffer = [];
|
21377 |
|
21378 | for (i = 0; i < this.sendBuffer.length; i++) {
|
21379 | this.packet(this.sendBuffer[i]);
|
21380 | }
|
21381 | this.sendBuffer = [];
|
21382 | };
|
21383 |
|
21384 |
|
21385 |
|
21386 |
|
21387 |
|
21388 |
|
21389 |
|
21390 | Socket.prototype.ondisconnect = function(){
|
21391 | debug('server disconnect (%s)', this.nsp);
|
21392 | this.destroy();
|
21393 | this.onclose('io server disconnect');
|
21394 | };
|
21395 |
|
21396 |
|
21397 |
|
21398 |
|
21399 |
|
21400 |
|
21401 |
|
21402 |
|
21403 |
|
21404 | Socket.prototype.destroy = function(){
|
21405 | if (this.subs) {
|
21406 |
|
21407 | for (var i = 0; i < this.subs.length; i++) {
|
21408 | this.subs[i].destroy();
|
21409 | }
|
21410 | this.subs = null;
|
21411 | }
|
21412 |
|
21413 | this.io.destroy(this);
|
21414 | };
|
21415 |
|
21416 |
|
21417 |
|
21418 |
|
21419 |
|
21420 |
|
21421 |
|
21422 |
|
21423 | Socket.prototype.close =
|
21424 | Socket.prototype.disconnect = function(){
|
21425 | if (this.connected) {
|
21426 | debug('performing disconnect (%s)', this.nsp);
|
21427 | this.packet({ type: parser.DISCONNECT });
|
21428 | }
|
21429 |
|
21430 |
|
21431 | this.destroy();
|
21432 |
|
21433 | if (this.connected) {
|
21434 |
|
21435 | this.onclose('io client disconnect');
|
21436 | }
|
21437 | return this;
|
21438 | };
|
21439 |
|
21440 |
|
21441 |
|
21442 |
|
21443 |
|
21444 |
|
21445 |
|
21446 |
|
21447 |
|
21448 | Socket.prototype.compress = function(compress){
|
21449 | this.flags = this.flags || {};
|
21450 | this.flags.compress = compress;
|
21451 | return this;
|
21452 | };
|
21453 |
|
21454 | },{"./on":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/on.js","component-bind":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/component-bind/index.js","component-emitter":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/component-emitter/index.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","has-binary":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/has-binary/index.js","socket.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/index.js","to-array":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/to-array/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/url.js":[function(require,module,exports){
|
21455 | (function (global){
|
21456 |
|
21457 |
|
21458 |
|
21459 |
|
21460 |
|
21461 | var parseuri = require('parseuri');
|
21462 | var debug = require('debug')('socket.io-client:url');
|
21463 |
|
21464 |
|
21465 |
|
21466 |
|
21467 |
|
21468 | module.exports = url;
|
21469 |
|
21470 |
|
21471 |
|
21472 |
|
21473 |
|
21474 |
|
21475 |
|
21476 |
|
21477 |
|
21478 |
|
21479 | function url(uri, loc){
|
21480 | var obj = uri;
|
21481 |
|
21482 |
|
21483 | var loc = loc || global.location;
|
21484 | if (null == uri) uri = loc.protocol + '//' + loc.host;
|
21485 |
|
21486 |
|
21487 | if ('string' == typeof uri) {
|
21488 | if ('/' == uri.charAt(0)) {
|
21489 | if ('/' == uri.charAt(1)) {
|
21490 | uri = loc.protocol + uri;
|
21491 | } else {
|
21492 | uri = loc.host + uri;
|
21493 | }
|
21494 | }
|
21495 |
|
21496 | if (!/^(https?|wss?):\/\//.test(uri)) {
|
21497 | debug('protocol-less url %s', uri);
|
21498 | if ('undefined' != typeof loc) {
|
21499 | uri = loc.protocol + '//' + uri;
|
21500 | } else {
|
21501 | uri = 'https://' + uri;
|
21502 | }
|
21503 | }
|
21504 |
|
21505 |
|
21506 | debug('parse %s', uri);
|
21507 | obj = parseuri(uri);
|
21508 | }
|
21509 |
|
21510 |
|
21511 | if (!obj.port) {
|
21512 | if (/^(http|ws)$/.test(obj.protocol)) {
|
21513 | obj.port = '80';
|
21514 | }
|
21515 | else if (/^(http|ws)s$/.test(obj.protocol)) {
|
21516 | obj.port = '443';
|
21517 | }
|
21518 | }
|
21519 |
|
21520 | obj.path = obj.path || '/';
|
21521 |
|
21522 | var ipv6 = obj.host.indexOf(':') !== -1;
|
21523 | var host = ipv6 ? '[' + obj.host + ']' : obj.host;
|
21524 |
|
21525 |
|
21526 | obj.id = obj.protocol + '://' + host + ':' + obj.port;
|
21527 |
|
21528 | obj.href = obj.protocol + '://' + host + (loc && loc.port == obj.port ? '' : (':' + obj.port));
|
21529 |
|
21530 | return obj;
|
21531 | }
|
21532 |
|
21533 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
21534 | },{"debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","parseuri":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/parseuri/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/backo2/index.js":[function(require,module,exports){
|
21535 |
|
21536 |
|
21537 |
|
21538 |
|
21539 |
|
21540 | module.exports = Backoff;
|
21541 |
|
21542 |
|
21543 |
|
21544 |
|
21545 |
|
21546 |
|
21547 |
|
21548 |
|
21549 |
|
21550 |
|
21551 |
|
21552 |
|
21553 |
|
21554 | function Backoff(opts) {
|
21555 | opts = opts || {};
|
21556 | this.ms = opts.min || 100;
|
21557 | this.max = opts.max || 10000;
|
21558 | this.factor = opts.factor || 2;
|
21559 | this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
|
21560 | this.attempts = 0;
|
21561 | }
|
21562 |
|
21563 |
|
21564 |
|
21565 |
|
21566 |
|
21567 |
|
21568 |
|
21569 |
|
21570 | Backoff.prototype.duration = function(){
|
21571 | var ms = this.ms * Math.pow(this.factor, this.attempts++);
|
21572 | if (this.jitter) {
|
21573 | var rand = Math.random();
|
21574 | var deviation = Math.floor(rand * this.jitter * ms);
|
21575 | ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
|
21576 | }
|
21577 | return Math.min(ms, this.max) | 0;
|
21578 | };
|
21579 |
|
21580 |
|
21581 |
|
21582 |
|
21583 |
|
21584 |
|
21585 |
|
21586 | Backoff.prototype.reset = function(){
|
21587 | this.attempts = 0;
|
21588 | };
|
21589 |
|
21590 |
|
21591 |
|
21592 |
|
21593 |
|
21594 |
|
21595 |
|
21596 | Backoff.prototype.setMin = function(min){
|
21597 | this.ms = min;
|
21598 | };
|
21599 |
|
21600 |
|
21601 |
|
21602 |
|
21603 |
|
21604 |
|
21605 |
|
21606 | Backoff.prototype.setMax = function(max){
|
21607 | this.max = max;
|
21608 | };
|
21609 |
|
21610 |
|
21611 |
|
21612 |
|
21613 |
|
21614 |
|
21615 |
|
21616 | Backoff.prototype.setJitter = function(jitter){
|
21617 | this.jitter = jitter;
|
21618 | };
|
21619 |
|
21620 |
|
21621 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/component-bind/index.js":[function(require,module,exports){
|
21622 |
|
21623 |
|
21624 |
|
21625 |
|
21626 | var slice = [].slice;
|
21627 |
|
21628 |
|
21629 |
|
21630 |
|
21631 |
|
21632 |
|
21633 |
|
21634 |
|
21635 |
|
21636 |
|
21637 | module.exports = function(obj, fn){
|
21638 | if ('string' == typeof fn) fn = obj[fn];
|
21639 | if ('function' != typeof fn) throw new Error('bind() requires a function');
|
21640 | var args = slice.call(arguments, 2);
|
21641 | return function(){
|
21642 | return fn.apply(obj, args.concat(slice.call(arguments)));
|
21643 | }
|
21644 | };
|
21645 |
|
21646 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/component-emitter/index.js":[function(require,module,exports){
|
21647 |
|
21648 |
|
21649 |
|
21650 |
|
21651 |
|
21652 | module.exports = Emitter;
|
21653 |
|
21654 |
|
21655 |
|
21656 |
|
21657 |
|
21658 |
|
21659 |
|
21660 | function Emitter(obj) {
|
21661 | if (obj) return mixin(obj);
|
21662 | };
|
21663 |
|
21664 |
|
21665 |
|
21666 |
|
21667 |
|
21668 |
|
21669 |
|
21670 |
|
21671 |
|
21672 | function mixin(obj) {
|
21673 | for (var key in Emitter.prototype) {
|
21674 | obj[key] = Emitter.prototype[key];
|
21675 | }
|
21676 | return obj;
|
21677 | }
|
21678 |
|
21679 |
|
21680 |
|
21681 |
|
21682 |
|
21683 |
|
21684 |
|
21685 |
|
21686 |
|
21687 |
|
21688 | Emitter.prototype.on =
|
21689 | Emitter.prototype.addEventListener = function(event, fn){
|
21690 | this._callbacks = this._callbacks || {};
|
21691 | (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
|
21692 | .push(fn);
|
21693 | return this;
|
21694 | };
|
21695 |
|
21696 |
|
21697 |
|
21698 |
|
21699 |
|
21700 |
|
21701 |
|
21702 |
|
21703 |
|
21704 |
|
21705 |
|
21706 | Emitter.prototype.once = function(event, fn){
|
21707 | function on() {
|
21708 | this.off(event, on);
|
21709 | fn.apply(this, arguments);
|
21710 | }
|
21711 |
|
21712 | on.fn = fn;
|
21713 | this.on(event, on);
|
21714 | return this;
|
21715 | };
|
21716 |
|
21717 |
|
21718 |
|
21719 |
|
21720 |
|
21721 |
|
21722 |
|
21723 |
|
21724 |
|
21725 |
|
21726 |
|
21727 | Emitter.prototype.off =
|
21728 | Emitter.prototype.removeListener =
|
21729 | Emitter.prototype.removeAllListeners =
|
21730 | Emitter.prototype.removeEventListener = function(event, fn){
|
21731 | this._callbacks = this._callbacks || {};
|
21732 |
|
21733 |
|
21734 | if (0 == arguments.length) {
|
21735 | this._callbacks = {};
|
21736 | return this;
|
21737 | }
|
21738 |
|
21739 |
|
21740 | var callbacks = this._callbacks['$' + event];
|
21741 | if (!callbacks) return this;
|
21742 |
|
21743 |
|
21744 | if (1 == arguments.length) {
|
21745 | delete this._callbacks['$' + event];
|
21746 | return this;
|
21747 | }
|
21748 |
|
21749 |
|
21750 | var cb;
|
21751 | for (var i = 0; i < callbacks.length; i++) {
|
21752 | cb = callbacks[i];
|
21753 | if (cb === fn || cb.fn === fn) {
|
21754 | callbacks.splice(i, 1);
|
21755 | break;
|
21756 | }
|
21757 | }
|
21758 | return this;
|
21759 | };
|
21760 |
|
21761 |
|
21762 |
|
21763 |
|
21764 |
|
21765 |
|
21766 |
|
21767 |
|
21768 |
|
21769 | Emitter.prototype.emit = function(event){
|
21770 | this._callbacks = this._callbacks || {};
|
21771 | var args = [].slice.call(arguments, 1)
|
21772 | , callbacks = this._callbacks['$' + event];
|
21773 |
|
21774 | if (callbacks) {
|
21775 | callbacks = callbacks.slice(0);
|
21776 | for (var i = 0, len = callbacks.length; i < len; ++i) {
|
21777 | callbacks[i].apply(this, args);
|
21778 | }
|
21779 | }
|
21780 |
|
21781 | return this;
|
21782 | };
|
21783 |
|
21784 |
|
21785 |
|
21786 |
|
21787 |
|
21788 |
|
21789 |
|
21790 |
|
21791 |
|
21792 | Emitter.prototype.listeners = function(event){
|
21793 | this._callbacks = this._callbacks || {};
|
21794 | return this._callbacks['$' + event] || [];
|
21795 | };
|
21796 |
|
21797 |
|
21798 |
|
21799 |
|
21800 |
|
21801 |
|
21802 |
|
21803 |
|
21804 |
|
21805 | Emitter.prototype.hasListeners = function(event){
|
21806 | return !! this.listeners(event).length;
|
21807 | };
|
21808 |
|
21809 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js":[function(require,module,exports){
|
21810 |
|
21811 |
|
21812 |
|
21813 |
|
21814 |
|
21815 |
|
21816 |
|
21817 | exports = module.exports = require('./debug');
|
21818 | exports.log = log;
|
21819 | exports.formatArgs = formatArgs;
|
21820 | exports.save = save;
|
21821 | exports.load = load;
|
21822 | exports.useColors = useColors;
|
21823 | exports.storage = 'undefined' != typeof chrome
|
21824 | && 'undefined' != typeof chrome.storage
|
21825 | ? chrome.storage.local
|
21826 | : localstorage();
|
21827 |
|
21828 |
|
21829 |
|
21830 |
|
21831 |
|
21832 | exports.colors = [
|
21833 | 'lightseagreen',
|
21834 | 'forestgreen',
|
21835 | 'goldenrod',
|
21836 | 'dodgerblue',
|
21837 | 'darkorchid',
|
21838 | 'crimson'
|
21839 | ];
|
21840 |
|
21841 |
|
21842 |
|
21843 |
|
21844 |
|
21845 |
|
21846 |
|
21847 |
|
21848 |
|
21849 | function useColors() {
|
21850 |
|
21851 | return ('WebkitAppearance' in document.documentElement.style) ||
|
21852 |
|
21853 | (window.console && (console.firebug || (console.exception && console.table))) ||
|
21854 |
|
21855 |
|
21856 | (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
|
21857 | }
|
21858 |
|
21859 |
|
21860 |
|
21861 |
|
21862 |
|
21863 | exports.formatters.j = function(v) {
|
21864 | return JSON.stringify(v);
|
21865 | };
|
21866 |
|
21867 |
|
21868 |
|
21869 |
|
21870 |
|
21871 |
|
21872 |
|
21873 |
|
21874 | function formatArgs() {
|
21875 | var args = arguments;
|
21876 | var useColors = this.useColors;
|
21877 |
|
21878 | args[0] = (useColors ? '%c' : '')
|
21879 | + this.namespace
|
21880 | + (useColors ? ' %c' : ' ')
|
21881 | + args[0]
|
21882 | + (useColors ? '%c ' : ' ')
|
21883 | + '+' + exports.humanize(this.diff);
|
21884 |
|
21885 | if (!useColors) return args;
|
21886 |
|
21887 | var c = 'color: ' + this.color;
|
21888 | args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
|
21889 |
|
21890 |
|
21891 |
|
21892 |
|
21893 | var index = 0;
|
21894 | var lastC = 0;
|
21895 | args[0].replace(/%[a-z%]/g, function(match) {
|
21896 | if ('%%' === match) return;
|
21897 | index++;
|
21898 | if ('%c' === match) {
|
21899 |
|
21900 |
|
21901 | lastC = index;
|
21902 | }
|
21903 | });
|
21904 |
|
21905 | args.splice(lastC, 0, c);
|
21906 | return args;
|
21907 | }
|
21908 |
|
21909 |
|
21910 |
|
21911 |
|
21912 |
|
21913 |
|
21914 |
|
21915 |
|
21916 | function log() {
|
21917 |
|
21918 |
|
21919 | return 'object' === typeof console
|
21920 | && console.log
|
21921 | && Function.prototype.apply.call(console.log, console, arguments);
|
21922 | }
|
21923 |
|
21924 |
|
21925 |
|
21926 |
|
21927 |
|
21928 |
|
21929 |
|
21930 |
|
21931 | function save(namespaces) {
|
21932 | try {
|
21933 | if (null == namespaces) {
|
21934 | exports.storage.removeItem('debug');
|
21935 | } else {
|
21936 | exports.storage.debug = namespaces;
|
21937 | }
|
21938 | } catch(e) {}
|
21939 | }
|
21940 |
|
21941 |
|
21942 |
|
21943 |
|
21944 |
|
21945 |
|
21946 |
|
21947 |
|
21948 | function load() {
|
21949 | var r;
|
21950 | try {
|
21951 | r = exports.storage.debug;
|
21952 | } catch(e) {}
|
21953 | return r;
|
21954 | }
|
21955 |
|
21956 |
|
21957 |
|
21958 |
|
21959 |
|
21960 | exports.enable(load());
|
21961 |
|
21962 |
|
21963 |
|
21964 |
|
21965 |
|
21966 |
|
21967 |
|
21968 |
|
21969 |
|
21970 |
|
21971 |
|
21972 |
|
21973 | function localstorage(){
|
21974 | try {
|
21975 | return window.localStorage;
|
21976 | } catch (e) {}
|
21977 | }
|
21978 |
|
21979 | },{"./debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/debug.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/debug.js":[function(require,module,exports){
|
21980 |
|
21981 |
|
21982 |
|
21983 |
|
21984 |
|
21985 |
|
21986 |
|
21987 |
|
21988 | exports = module.exports = debug;
|
21989 | exports.coerce = coerce;
|
21990 | exports.disable = disable;
|
21991 | exports.enable = enable;
|
21992 | exports.enabled = enabled;
|
21993 | exports.humanize = require('ms');
|
21994 |
|
21995 |
|
21996 |
|
21997 |
|
21998 |
|
21999 | exports.names = [];
|
22000 | exports.skips = [];
|
22001 |
|
22002 |
|
22003 |
|
22004 |
|
22005 |
|
22006 |
|
22007 |
|
22008 | exports.formatters = {};
|
22009 |
|
22010 |
|
22011 |
|
22012 |
|
22013 |
|
22014 | var prevColor = 0;
|
22015 |
|
22016 |
|
22017 |
|
22018 |
|
22019 |
|
22020 | var prevTime;
|
22021 |
|
22022 |
|
22023 |
|
22024 |
|
22025 |
|
22026 |
|
22027 |
|
22028 |
|
22029 | function selectColor() {
|
22030 | return exports.colors[prevColor++ % exports.colors.length];
|
22031 | }
|
22032 |
|
22033 |
|
22034 |
|
22035 |
|
22036 |
|
22037 |
|
22038 |
|
22039 |
|
22040 |
|
22041 | function debug(namespace) {
|
22042 |
|
22043 |
|
22044 | function disabled() {
|
22045 | }
|
22046 | disabled.enabled = false;
|
22047 |
|
22048 |
|
22049 | function enabled() {
|
22050 |
|
22051 | var self = enabled;
|
22052 |
|
22053 |
|
22054 | var curr = +new Date();
|
22055 | var ms = curr - (prevTime || curr);
|
22056 | self.diff = ms;
|
22057 | self.prev = prevTime;
|
22058 | self.curr = curr;
|
22059 | prevTime = curr;
|
22060 |
|
22061 |
|
22062 | if (null == self.useColors) self.useColors = exports.useColors();
|
22063 | if (null == self.color && self.useColors) self.color = selectColor();
|
22064 |
|
22065 | var args = Array.prototype.slice.call(arguments);
|
22066 |
|
22067 | args[0] = exports.coerce(args[0]);
|
22068 |
|
22069 | if ('string' !== typeof args[0]) {
|
22070 |
|
22071 | args = ['%o'].concat(args);
|
22072 | }
|
22073 |
|
22074 |
|
22075 | var index = 0;
|
22076 | args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
|
22077 |
|
22078 | if (match === '%%') return match;
|
22079 | index++;
|
22080 | var formatter = exports.formatters[format];
|
22081 | if ('function' === typeof formatter) {
|
22082 | var val = args[index];
|
22083 | match = formatter.call(self, val);
|
22084 |
|
22085 |
|
22086 | args.splice(index, 1);
|
22087 | index--;
|
22088 | }
|
22089 | return match;
|
22090 | });
|
22091 |
|
22092 | if ('function' === typeof exports.formatArgs) {
|
22093 | args = exports.formatArgs.apply(self, args);
|
22094 | }
|
22095 | var logFn = enabled.log || exports.log || console.log.bind(console);
|
22096 | logFn.apply(self, args);
|
22097 | }
|
22098 | enabled.enabled = true;
|
22099 |
|
22100 | var fn = exports.enabled(namespace) ? enabled : disabled;
|
22101 |
|
22102 | fn.namespace = namespace;
|
22103 |
|
22104 | return fn;
|
22105 | }
|
22106 |
|
22107 |
|
22108 |
|
22109 |
|
22110 |
|
22111 |
|
22112 |
|
22113 |
|
22114 |
|
22115 | function enable(namespaces) {
|
22116 | exports.save(namespaces);
|
22117 |
|
22118 | var split = (namespaces || '').split(/[\s,]+/);
|
22119 | var len = split.length;
|
22120 |
|
22121 | for (var i = 0; i < len; i++) {
|
22122 | if (!split[i]) continue;
|
22123 | namespaces = split[i].replace(/\*/g, '.*?');
|
22124 | if (namespaces[0] === '-') {
|
22125 | exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
22126 | } else {
|
22127 | exports.names.push(new RegExp('^' + namespaces + '$'));
|
22128 | }
|
22129 | }
|
22130 | }
|
22131 |
|
22132 |
|
22133 |
|
22134 |
|
22135 |
|
22136 |
|
22137 |
|
22138 | function disable() {
|
22139 | exports.enable('');
|
22140 | }
|
22141 |
|
22142 |
|
22143 |
|
22144 |
|
22145 |
|
22146 |
|
22147 |
|
22148 |
|
22149 |
|
22150 | function enabled(name) {
|
22151 | var i, len;
|
22152 | for (i = 0, len = exports.skips.length; i < len; i++) {
|
22153 | if (exports.skips[i].test(name)) {
|
22154 | return false;
|
22155 | }
|
22156 | }
|
22157 | for (i = 0, len = exports.names.length; i < len; i++) {
|
22158 | if (exports.names[i].test(name)) {
|
22159 | return true;
|
22160 | }
|
22161 | }
|
22162 | return false;
|
22163 | }
|
22164 |
|
22165 |
|
22166 |
|
22167 |
|
22168 |
|
22169 |
|
22170 |
|
22171 |
|
22172 |
|
22173 | function coerce(val) {
|
22174 | if (val instanceof Error) return val.stack || val.message;
|
22175 | return val;
|
22176 | }
|
22177 |
|
22178 | },{"ms":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/node_modules/ms/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/node_modules/ms/index.js":[function(require,module,exports){
|
22179 |
|
22180 |
|
22181 |
|
22182 |
|
22183 | var s = 1000;
|
22184 | var m = s * 60;
|
22185 | var h = m * 60;
|
22186 | var d = h * 24;
|
22187 | var y = d * 365.25;
|
22188 |
|
22189 |
|
22190 |
|
22191 |
|
22192 |
|
22193 |
|
22194 |
|
22195 |
|
22196 |
|
22197 |
|
22198 |
|
22199 |
|
22200 |
|
22201 |
|
22202 | module.exports = function(val, options){
|
22203 | options = options || {};
|
22204 | if ('string' == typeof val) return parse(val);
|
22205 | return options.long
|
22206 | ? long(val)
|
22207 | : short(val);
|
22208 | };
|
22209 |
|
22210 |
|
22211 |
|
22212 |
|
22213 |
|
22214 |
|
22215 |
|
22216 |
|
22217 |
|
22218 | function parse(str) {
|
22219 | str = '' + str;
|
22220 | if (str.length > 10000) return;
|
22221 | var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
|
22222 | if (!match) return;
|
22223 | var n = parseFloat(match[1]);
|
22224 | var type = (match[2] || 'ms').toLowerCase();
|
22225 | switch (type) {
|
22226 | case 'years':
|
22227 | case 'year':
|
22228 | case 'yrs':
|
22229 | case 'yr':
|
22230 | case 'y':
|
22231 | return n * y;
|
22232 | case 'days':
|
22233 | case 'day':
|
22234 | case 'd':
|
22235 | return n * d;
|
22236 | case 'hours':
|
22237 | case 'hour':
|
22238 | case 'hrs':
|
22239 | case 'hr':
|
22240 | case 'h':
|
22241 | return n * h;
|
22242 | case 'minutes':
|
22243 | case 'minute':
|
22244 | case 'mins':
|
22245 | case 'min':
|
22246 | case 'm':
|
22247 | return n * m;
|
22248 | case 'seconds':
|
22249 | case 'second':
|
22250 | case 'secs':
|
22251 | case 'sec':
|
22252 | case 's':
|
22253 | return n * s;
|
22254 | case 'milliseconds':
|
22255 | case 'millisecond':
|
22256 | case 'msecs':
|
22257 | case 'msec':
|
22258 | case 'ms':
|
22259 | return n;
|
22260 | }
|
22261 | }
|
22262 |
|
22263 |
|
22264 |
|
22265 |
|
22266 |
|
22267 |
|
22268 |
|
22269 |
|
22270 |
|
22271 | function short(ms) {
|
22272 | if (ms >= d) return Math.round(ms / d) + 'd';
|
22273 | if (ms >= h) return Math.round(ms / h) + 'h';
|
22274 | if (ms >= m) return Math.round(ms / m) + 'm';
|
22275 | if (ms >= s) return Math.round(ms / s) + 's';
|
22276 | return ms + 'ms';
|
22277 | }
|
22278 |
|
22279 |
|
22280 |
|
22281 |
|
22282 |
|
22283 |
|
22284 |
|
22285 |
|
22286 |
|
22287 | function long(ms) {
|
22288 | return plural(ms, d, 'day')
|
22289 | || plural(ms, h, 'hour')
|
22290 | || plural(ms, m, 'minute')
|
22291 | || plural(ms, s, 'second')
|
22292 | || ms + ' ms';
|
22293 | }
|
22294 |
|
22295 |
|
22296 |
|
22297 |
|
22298 |
|
22299 | function plural(ms, n, name) {
|
22300 | if (ms < n) return;
|
22301 | if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
|
22302 | return Math.ceil(ms / n) + ' ' + name + 's';
|
22303 | }
|
22304 |
|
22305 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/index.js":[function(require,module,exports){
|
22306 |
|
22307 | module.exports = require('./lib/');
|
22308 |
|
22309 | },{"./lib/":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/index.js":[function(require,module,exports){
|
22310 |
|
22311 | module.exports = require('./socket');
|
22312 |
|
22313 |
|
22314 |
|
22315 |
|
22316 |
|
22317 |
|
22318 |
|
22319 | module.exports.parser = require('engine.io-parser');
|
22320 |
|
22321 | },{"./socket":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/socket.js","engine.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/browser.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/socket.js":[function(require,module,exports){
|
22322 | (function (global){
|
22323 |
|
22324 |
|
22325 |
|
22326 |
|
22327 | var transports = require('./transports');
|
22328 | var Emitter = require('component-emitter');
|
22329 | var debug = require('debug')('engine.io-client:socket');
|
22330 | var index = require('indexof');
|
22331 | var parser = require('engine.io-parser');
|
22332 | var parseuri = require('parseuri');
|
22333 | var parsejson = require('parsejson');
|
22334 | var parseqs = require('parseqs');
|
22335 |
|
22336 |
|
22337 |
|
22338 |
|
22339 |
|
22340 | module.exports = Socket;
|
22341 |
|
22342 |
|
22343 |
|
22344 |
|
22345 |
|
22346 |
|
22347 |
|
22348 | function noop(){}
|
22349 |
|
22350 |
|
22351 |
|
22352 |
|
22353 |
|
22354 |
|
22355 |
|
22356 |
|
22357 |
|
22358 | function Socket(uri, opts){
|
22359 | if (!(this instanceof Socket)) return new Socket(uri, opts);
|
22360 |
|
22361 | opts = opts || {};
|
22362 |
|
22363 | if (uri && 'object' == typeof uri) {
|
22364 | opts = uri;
|
22365 | uri = null;
|
22366 | }
|
22367 |
|
22368 | if (uri) {
|
22369 | uri = parseuri(uri);
|
22370 | opts.hostname = uri.host;
|
22371 | opts.secure = uri.protocol == 'https' || uri.protocol == 'wss';
|
22372 | opts.port = uri.port;
|
22373 | if (uri.query) opts.query = uri.query;
|
22374 | } else if (opts.host) {
|
22375 | opts.hostname = parseuri(opts.host).host;
|
22376 | }
|
22377 |
|
22378 | this.secure = null != opts.secure ? opts.secure :
|
22379 | (global.location && 'https:' == location.protocol);
|
22380 |
|
22381 | if (opts.hostname && !opts.port) {
|
22382 |
|
22383 | opts.port = this.secure ? '443' : '80';
|
22384 | }
|
22385 |
|
22386 | this.agent = opts.agent || false;
|
22387 | this.hostname = opts.hostname ||
|
22388 | (global.location ? location.hostname : 'localhost');
|
22389 | this.port = opts.port || (global.location && location.port ?
|
22390 | location.port :
|
22391 | (this.secure ? 443 : 80));
|
22392 | this.query = opts.query || {};
|
22393 | if ('string' == typeof this.query) this.query = parseqs.decode(this.query);
|
22394 | this.upgrade = false !== opts.upgrade;
|
22395 | this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
|
22396 | this.forceJSONP = !!opts.forceJSONP;
|
22397 | this.jsonp = false !== opts.jsonp;
|
22398 | this.forceBase64 = !!opts.forceBase64;
|
22399 | this.enablesXDR = !!opts.enablesXDR;
|
22400 | this.timestampParam = opts.timestampParam || 't';
|
22401 | this.timestampRequests = opts.timestampRequests;
|
22402 | this.transports = opts.transports || ['polling', 'websocket'];
|
22403 | this.readyState = '';
|
22404 | this.writeBuffer = [];
|
22405 | this.policyPort = opts.policyPort || 843;
|
22406 | this.rememberUpgrade = opts.rememberUpgrade || false;
|
22407 | this.binaryType = null;
|
22408 | this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
|
22409 | this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;
|
22410 |
|
22411 | if (true === this.perMessageDeflate) this.perMessageDeflate = {};
|
22412 | if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
|
22413 | this.perMessageDeflate.threshold = 1024;
|
22414 | }
|
22415 |
|
22416 |
|
22417 | this.pfx = opts.pfx || null;
|
22418 | this.key = opts.key || null;
|
22419 | this.passphrase = opts.passphrase || null;
|
22420 | this.cert = opts.cert || null;
|
22421 | this.ca = opts.ca || null;
|
22422 | this.ciphers = opts.ciphers || null;
|
22423 | this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? null : opts.rejectUnauthorized;
|
22424 |
|
22425 |
|
22426 | var freeGlobal = typeof global == 'object' && global;
|
22427 | if (freeGlobal.global === freeGlobal) {
|
22428 | if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
|
22429 | this.extraHeaders = opts.extraHeaders;
|
22430 | }
|
22431 | }
|
22432 |
|
22433 | this.open();
|
22434 | }
|
22435 |
|
22436 | Socket.priorWebsocketSuccess = false;
|
22437 |
|
22438 |
|
22439 |
|
22440 |
|
22441 |
|
22442 | Emitter(Socket.prototype);
|
22443 |
|
22444 |
|
22445 |
|
22446 |
|
22447 |
|
22448 |
|
22449 |
|
22450 | Socket.protocol = parser.protocol;
|
22451 |
|
22452 |
|
22453 |
|
22454 |
|
22455 |
|
22456 |
|
22457 | Socket.Socket = Socket;
|
22458 | Socket.Transport = require('./transport');
|
22459 | Socket.transports = require('./transports');
|
22460 | Socket.parser = require('engine.io-parser');
|
22461 |
|
22462 |
|
22463 |
|
22464 |
|
22465 |
|
22466 |
|
22467 |
|
22468 |
|
22469 |
|
22470 | Socket.prototype.createTransport = function (name) {
|
22471 | debug('creating transport "%s"', name);
|
22472 | var query = clone(this.query);
|
22473 |
|
22474 |
|
22475 | query.EIO = parser.protocol;
|
22476 |
|
22477 |
|
22478 | query.transport = name;
|
22479 |
|
22480 |
|
22481 | if (this.id) query.sid = this.id;
|
22482 |
|
22483 | var transport = new transports[name]({
|
22484 | agent: this.agent,
|
22485 | hostname: this.hostname,
|
22486 | port: this.port,
|
22487 | secure: this.secure,
|
22488 | path: this.path,
|
22489 | query: query,
|
22490 | forceJSONP: this.forceJSONP,
|
22491 | jsonp: this.jsonp,
|
22492 | forceBase64: this.forceBase64,
|
22493 | enablesXDR: this.enablesXDR,
|
22494 | timestampRequests: this.timestampRequests,
|
22495 | timestampParam: this.timestampParam,
|
22496 | policyPort: this.policyPort,
|
22497 | socket: this,
|
22498 | pfx: this.pfx,
|
22499 | key: this.key,
|
22500 | passphrase: this.passphrase,
|
22501 | cert: this.cert,
|
22502 | ca: this.ca,
|
22503 | ciphers: this.ciphers,
|
22504 | rejectUnauthorized: this.rejectUnauthorized,
|
22505 | perMessageDeflate: this.perMessageDeflate,
|
22506 | extraHeaders: this.extraHeaders
|
22507 | });
|
22508 |
|
22509 | return transport;
|
22510 | };
|
22511 |
|
22512 | function clone (obj) {
|
22513 | var o = {};
|
22514 | for (var i in obj) {
|
22515 | if (obj.hasOwnProperty(i)) {
|
22516 | o[i] = obj[i];
|
22517 | }
|
22518 | }
|
22519 | return o;
|
22520 | }
|
22521 |
|
22522 |
|
22523 |
|
22524 |
|
22525 |
|
22526 |
|
22527 | Socket.prototype.open = function () {
|
22528 | var transport;
|
22529 | if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
|
22530 | transport = 'websocket';
|
22531 | } else if (0 === this.transports.length) {
|
22532 |
|
22533 | var self = this;
|
22534 | setTimeout(function() {
|
22535 | self.emit('error', 'No transports available');
|
22536 | }, 0);
|
22537 | return;
|
22538 | } else {
|
22539 | transport = this.transports[0];
|
22540 | }
|
22541 | this.readyState = 'opening';
|
22542 |
|
22543 |
|
22544 | try {
|
22545 | transport = this.createTransport(transport);
|
22546 | } catch (e) {
|
22547 | this.transports.shift();
|
22548 | this.open();
|
22549 | return;
|
22550 | }
|
22551 |
|
22552 | transport.open();
|
22553 | this.setTransport(transport);
|
22554 | };
|
22555 |
|
22556 |
|
22557 |
|
22558 |
|
22559 |
|
22560 |
|
22561 |
|
22562 | Socket.prototype.setTransport = function(transport){
|
22563 | debug('setting transport %s', transport.name);
|
22564 | var self = this;
|
22565 |
|
22566 | if (this.transport) {
|
22567 | debug('clearing existing transport %s', this.transport.name);
|
22568 | this.transport.removeAllListeners();
|
22569 | }
|
22570 |
|
22571 |
|
22572 | this.transport = transport;
|
22573 |
|
22574 |
|
22575 | transport
|
22576 | .on('drain', function(){
|
22577 | self.onDrain();
|
22578 | })
|
22579 | .on('packet', function(packet){
|
22580 | self.onPacket(packet);
|
22581 | })
|
22582 | .on('error', function(e){
|
22583 | self.onError(e);
|
22584 | })
|
22585 | .on('close', function(){
|
22586 | self.onClose('transport close');
|
22587 | });
|
22588 | };
|
22589 |
|
22590 |
|
22591 |
|
22592 |
|
22593 |
|
22594 |
|
22595 |
|
22596 |
|
22597 | Socket.prototype.probe = function (name) {
|
22598 | debug('probing transport "%s"', name);
|
22599 | var transport = this.createTransport(name, { probe: 1 })
|
22600 | , failed = false
|
22601 | , self = this;
|
22602 |
|
22603 | Socket.priorWebsocketSuccess = false;
|
22604 |
|
22605 | function onTransportOpen(){
|
22606 | if (self.onlyBinaryUpgrades) {
|
22607 | var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
|
22608 | failed = failed || upgradeLosesBinary;
|
22609 | }
|
22610 | if (failed) return;
|
22611 |
|
22612 | debug('probe transport "%s" opened', name);
|
22613 | transport.send([{ type: 'ping', data: 'probe' }]);
|
22614 | transport.once('packet', function (msg) {
|
22615 | if (failed) return;
|
22616 | if ('pong' == msg.type && 'probe' == msg.data) {
|
22617 | debug('probe transport "%s" pong', name);
|
22618 | self.upgrading = true;
|
22619 | self.emit('upgrading', transport);
|
22620 | if (!transport) return;
|
22621 | Socket.priorWebsocketSuccess = 'websocket' == transport.name;
|
22622 |
|
22623 | debug('pausing current transport "%s"', self.transport.name);
|
22624 | self.transport.pause(function () {
|
22625 | if (failed) return;
|
22626 | if ('closed' == self.readyState) return;
|
22627 | debug('changing transport and sending upgrade packet');
|
22628 |
|
22629 | cleanup();
|
22630 |
|
22631 | self.setTransport(transport);
|
22632 | transport.send([{ type: 'upgrade' }]);
|
22633 | self.emit('upgrade', transport);
|
22634 | transport = null;
|
22635 | self.upgrading = false;
|
22636 | self.flush();
|
22637 | });
|
22638 | } else {
|
22639 | debug('probe transport "%s" failed', name);
|
22640 | var err = new Error('probe error');
|
22641 | err.transport = transport.name;
|
22642 | self.emit('upgradeError', err);
|
22643 | }
|
22644 | });
|
22645 | }
|
22646 |
|
22647 | function freezeTransport() {
|
22648 | if (failed) return;
|
22649 |
|
22650 |
|
22651 | failed = true;
|
22652 |
|
22653 | cleanup();
|
22654 |
|
22655 | transport.close();
|
22656 | transport = null;
|
22657 | }
|
22658 |
|
22659 |
|
22660 | function onerror(err) {
|
22661 | var error = new Error('probe error: ' + err);
|
22662 | error.transport = transport.name;
|
22663 |
|
22664 | freezeTransport();
|
22665 |
|
22666 | debug('probe transport "%s" failed because of error: %s', name, err);
|
22667 |
|
22668 | self.emit('upgradeError', error);
|
22669 | }
|
22670 |
|
22671 | function onTransportClose(){
|
22672 | onerror("transport closed");
|
22673 | }
|
22674 |
|
22675 |
|
22676 | function onclose(){
|
22677 | onerror("socket closed");
|
22678 | }
|
22679 |
|
22680 |
|
22681 | function onupgrade(to){
|
22682 | if (transport && to.name != transport.name) {
|
22683 | debug('"%s" works - aborting "%s"', to.name, transport.name);
|
22684 | freezeTransport();
|
22685 | }
|
22686 | }
|
22687 |
|
22688 |
|
22689 | function cleanup(){
|
22690 | transport.removeListener('open', onTransportOpen);
|
22691 | transport.removeListener('error', onerror);
|
22692 | transport.removeListener('close', onTransportClose);
|
22693 | self.removeListener('close', onclose);
|
22694 | self.removeListener('upgrading', onupgrade);
|
22695 | }
|
22696 |
|
22697 | transport.once('open', onTransportOpen);
|
22698 | transport.once('error', onerror);
|
22699 | transport.once('close', onTransportClose);
|
22700 |
|
22701 | this.once('close', onclose);
|
22702 | this.once('upgrading', onupgrade);
|
22703 |
|
22704 | transport.open();
|
22705 |
|
22706 | };
|
22707 |
|
22708 |
|
22709 |
|
22710 |
|
22711 |
|
22712 |
|
22713 |
|
22714 | Socket.prototype.onOpen = function () {
|
22715 | debug('socket open');
|
22716 | this.readyState = 'open';
|
22717 | Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;
|
22718 | this.emit('open');
|
22719 | this.flush();
|
22720 |
|
22721 |
|
22722 |
|
22723 | if ('open' == this.readyState && this.upgrade && this.transport.pause) {
|
22724 | debug('starting upgrade probes');
|
22725 | for (var i = 0, l = this.upgrades.length; i < l; i++) {
|
22726 | this.probe(this.upgrades[i]);
|
22727 | }
|
22728 | }
|
22729 | };
|
22730 |
|
22731 |
|
22732 |
|
22733 |
|
22734 |
|
22735 |
|
22736 |
|
22737 | Socket.prototype.onPacket = function (packet) {
|
22738 | if ('opening' == this.readyState || 'open' == this.readyState) {
|
22739 | debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
|
22740 |
|
22741 | this.emit('packet', packet);
|
22742 |
|
22743 |
|
22744 | this.emit('heartbeat');
|
22745 |
|
22746 | switch (packet.type) {
|
22747 | case 'open':
|
22748 | this.onHandshake(parsejson(packet.data));
|
22749 | break;
|
22750 |
|
22751 | case 'pong':
|
22752 | this.setPing();
|
22753 | this.emit('pong');
|
22754 | break;
|
22755 |
|
22756 | case 'error':
|
22757 | var err = new Error('server error');
|
22758 | err.code = packet.data;
|
22759 | this.onError(err);
|
22760 | break;
|
22761 |
|
22762 | case 'message':
|
22763 | this.emit('data', packet.data);
|
22764 | this.emit('message', packet.data);
|
22765 | break;
|
22766 | }
|
22767 | } else {
|
22768 | debug('packet received with socket readyState "%s"', this.readyState);
|
22769 | }
|
22770 | };
|
22771 |
|
22772 |
|
22773 |
|
22774 |
|
22775 |
|
22776 |
|
22777 |
|
22778 |
|
22779 | Socket.prototype.onHandshake = function (data) {
|
22780 | this.emit('handshake', data);
|
22781 | this.id = data.sid;
|
22782 | this.transport.query.sid = data.sid;
|
22783 | this.upgrades = this.filterUpgrades(data.upgrades);
|
22784 | this.pingInterval = data.pingInterval;
|
22785 | this.pingTimeout = data.pingTimeout;
|
22786 | this.onOpen();
|
22787 |
|
22788 | if ('closed' == this.readyState) return;
|
22789 | this.setPing();
|
22790 |
|
22791 |
|
22792 | this.removeListener('heartbeat', this.onHeartbeat);
|
22793 | this.on('heartbeat', this.onHeartbeat);
|
22794 | };
|
22795 |
|
22796 |
|
22797 |
|
22798 |
|
22799 |
|
22800 |
|
22801 |
|
22802 | Socket.prototype.onHeartbeat = function (timeout) {
|
22803 | clearTimeout(this.pingTimeoutTimer);
|
22804 | var self = this;
|
22805 | self.pingTimeoutTimer = setTimeout(function () {
|
22806 | if ('closed' == self.readyState) return;
|
22807 | self.onClose('ping timeout');
|
22808 | }, timeout || (self.pingInterval + self.pingTimeout));
|
22809 | };
|
22810 |
|
22811 |
|
22812 |
|
22813 |
|
22814 |
|
22815 |
|
22816 |
|
22817 |
|
22818 | Socket.prototype.setPing = function () {
|
22819 | var self = this;
|
22820 | clearTimeout(self.pingIntervalTimer);
|
22821 | self.pingIntervalTimer = setTimeout(function () {
|
22822 | debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
|
22823 | self.ping();
|
22824 | self.onHeartbeat(self.pingTimeout);
|
22825 | }, self.pingInterval);
|
22826 | };
|
22827 |
|
22828 |
|
22829 |
|
22830 |
|
22831 |
|
22832 |
|
22833 |
|
22834 | Socket.prototype.ping = function () {
|
22835 | var self = this;
|
22836 | this.sendPacket('ping', function(){
|
22837 | self.emit('ping');
|
22838 | });
|
22839 | };
|
22840 |
|
22841 |
|
22842 |
|
22843 |
|
22844 |
|
22845 |
|
22846 |
|
22847 | Socket.prototype.onDrain = function() {
|
22848 | this.writeBuffer.splice(0, this.prevBufferLen);
|
22849 |
|
22850 |
|
22851 |
|
22852 |
|
22853 | this.prevBufferLen = 0;
|
22854 |
|
22855 | if (0 === this.writeBuffer.length) {
|
22856 | this.emit('drain');
|
22857 | } else {
|
22858 | this.flush();
|
22859 | }
|
22860 | };
|
22861 |
|
22862 |
|
22863 |
|
22864 |
|
22865 |
|
22866 |
|
22867 |
|
22868 | Socket.prototype.flush = function () {
|
22869 | if ('closed' != this.readyState && this.transport.writable &&
|
22870 | !this.upgrading && this.writeBuffer.length) {
|
22871 | debug('flushing %d packets in socket', this.writeBuffer.length);
|
22872 | this.transport.send(this.writeBuffer);
|
22873 |
|
22874 |
|
22875 | this.prevBufferLen = this.writeBuffer.length;
|
22876 | this.emit('flush');
|
22877 | }
|
22878 | };
|
22879 |
|
22880 |
|
22881 |
|
22882 |
|
22883 |
|
22884 |
|
22885 |
|
22886 |
|
22887 |
|
22888 |
|
22889 |
|
22890 | Socket.prototype.write =
|
22891 | Socket.prototype.send = function (msg, options, fn) {
|
22892 | this.sendPacket('message', msg, options, fn);
|
22893 | return this;
|
22894 | };
|
22895 |
|
22896 |
|
22897 |
|
22898 |
|
22899 |
|
22900 |
|
22901 |
|
22902 |
|
22903 |
|
22904 |
|
22905 |
|
22906 | Socket.prototype.sendPacket = function (type, data, options, fn) {
|
22907 | if('function' == typeof data) {
|
22908 | fn = data;
|
22909 | data = undefined;
|
22910 | }
|
22911 |
|
22912 | if ('function' == typeof options) {
|
22913 | fn = options;
|
22914 | options = null;
|
22915 | }
|
22916 |
|
22917 | if ('closing' == this.readyState || 'closed' == this.readyState) {
|
22918 | return;
|
22919 | }
|
22920 |
|
22921 | options = options || {};
|
22922 | options.compress = false !== options.compress;
|
22923 |
|
22924 | var packet = {
|
22925 | type: type,
|
22926 | data: data,
|
22927 | options: options
|
22928 | };
|
22929 | this.emit('packetCreate', packet);
|
22930 | this.writeBuffer.push(packet);
|
22931 | if (fn) this.once('flush', fn);
|
22932 | this.flush();
|
22933 | };
|
22934 |
|
22935 |
|
22936 |
|
22937 |
|
22938 |
|
22939 |
|
22940 |
|
22941 | Socket.prototype.close = function () {
|
22942 | if ('opening' == this.readyState || 'open' == this.readyState) {
|
22943 | this.readyState = 'closing';
|
22944 |
|
22945 | var self = this;
|
22946 |
|
22947 | if (this.writeBuffer.length) {
|
22948 | this.once('drain', function() {
|
22949 | if (this.upgrading) {
|
22950 | waitForUpgrade();
|
22951 | } else {
|
22952 | close();
|
22953 | }
|
22954 | });
|
22955 | } else if (this.upgrading) {
|
22956 | waitForUpgrade();
|
22957 | } else {
|
22958 | close();
|
22959 | }
|
22960 | }
|
22961 |
|
22962 | function close() {
|
22963 | self.onClose('forced close');
|
22964 | debug('socket closing - telling transport to close');
|
22965 | self.transport.close();
|
22966 | }
|
22967 |
|
22968 | function cleanupAndClose() {
|
22969 | self.removeListener('upgrade', cleanupAndClose);
|
22970 | self.removeListener('upgradeError', cleanupAndClose);
|
22971 | close();
|
22972 | }
|
22973 |
|
22974 | function waitForUpgrade() {
|
22975 |
|
22976 | self.once('upgrade', cleanupAndClose);
|
22977 | self.once('upgradeError', cleanupAndClose);
|
22978 | }
|
22979 |
|
22980 | return this;
|
22981 | };
|
22982 |
|
22983 |
|
22984 |
|
22985 |
|
22986 |
|
22987 |
|
22988 |
|
22989 | Socket.prototype.onError = function (err) {
|
22990 | debug('socket error %j', err);
|
22991 | Socket.priorWebsocketSuccess = false;
|
22992 | this.emit('error', err);
|
22993 | this.onClose('transport error', err);
|
22994 | };
|
22995 |
|
22996 |
|
22997 |
|
22998 |
|
22999 |
|
23000 |
|
23001 |
|
23002 | Socket.prototype.onClose = function (reason, desc) {
|
23003 | if ('opening' == this.readyState || 'open' == this.readyState || 'closing' == this.readyState) {
|
23004 | debug('socket close with reason: "%s"', reason);
|
23005 | var self = this;
|
23006 |
|
23007 |
|
23008 | clearTimeout(this.pingIntervalTimer);
|
23009 | clearTimeout(this.pingTimeoutTimer);
|
23010 |
|
23011 |
|
23012 | this.transport.removeAllListeners('close');
|
23013 |
|
23014 |
|
23015 | this.transport.close();
|
23016 |
|
23017 |
|
23018 | this.transport.removeAllListeners();
|
23019 |
|
23020 |
|
23021 | this.readyState = 'closed';
|
23022 |
|
23023 |
|
23024 | this.id = null;
|
23025 |
|
23026 |
|
23027 | this.emit('close', reason, desc);
|
23028 |
|
23029 |
|
23030 |
|
23031 | self.writeBuffer = [];
|
23032 | self.prevBufferLen = 0;
|
23033 | }
|
23034 | };
|
23035 |
|
23036 |
|
23037 |
|
23038 |
|
23039 |
|
23040 |
|
23041 |
|
23042 |
|
23043 |
|
23044 | Socket.prototype.filterUpgrades = function (upgrades) {
|
23045 | var filteredUpgrades = [];
|
23046 | for (var i = 0, j = upgrades.length; i<j; i++) {
|
23047 | if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
|
23048 | }
|
23049 | return filteredUpgrades;
|
23050 | };
|
23051 |
|
23052 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
23053 | },{"./transport":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transport.js","./transports":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/index.js","component-emitter":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-emitter/index.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","engine.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/browser.js","indexof":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/indexof/index.js","parsejson":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/parsejson/index.js","parseqs":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/parseqs/index.js","parseuri":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/parseuri/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transport.js":[function(require,module,exports){
|
23054 |
|
23055 |
|
23056 |
|
23057 |
|
23058 | var parser = require('engine.io-parser');
|
23059 | var Emitter = require('component-emitter');
|
23060 |
|
23061 |
|
23062 |
|
23063 |
|
23064 |
|
23065 | module.exports = Transport;
|
23066 |
|
23067 |
|
23068 |
|
23069 |
|
23070 |
|
23071 |
|
23072 |
|
23073 |
|
23074 | function Transport (opts) {
|
23075 | this.path = opts.path;
|
23076 | this.hostname = opts.hostname;
|
23077 | this.port = opts.port;
|
23078 | this.secure = opts.secure;
|
23079 | this.query = opts.query;
|
23080 | this.timestampParam = opts.timestampParam;
|
23081 | this.timestampRequests = opts.timestampRequests;
|
23082 | this.readyState = '';
|
23083 | this.agent = opts.agent || false;
|
23084 | this.socket = opts.socket;
|
23085 | this.enablesXDR = opts.enablesXDR;
|
23086 |
|
23087 |
|
23088 | this.pfx = opts.pfx;
|
23089 | this.key = opts.key;
|
23090 | this.passphrase = opts.passphrase;
|
23091 | this.cert = opts.cert;
|
23092 | this.ca = opts.ca;
|
23093 | this.ciphers = opts.ciphers;
|
23094 | this.rejectUnauthorized = opts.rejectUnauthorized;
|
23095 |
|
23096 |
|
23097 | this.extraHeaders = opts.extraHeaders;
|
23098 | }
|
23099 |
|
23100 |
|
23101 |
|
23102 |
|
23103 |
|
23104 | Emitter(Transport.prototype);
|
23105 |
|
23106 |
|
23107 |
|
23108 |
|
23109 |
|
23110 |
|
23111 |
|
23112 |
|
23113 |
|
23114 | Transport.prototype.onError = function (msg, desc) {
|
23115 | var err = new Error(msg);
|
23116 | err.type = 'TransportError';
|
23117 | err.description = desc;
|
23118 | this.emit('error', err);
|
23119 | return this;
|
23120 | };
|
23121 |
|
23122 |
|
23123 |
|
23124 |
|
23125 |
|
23126 |
|
23127 |
|
23128 | Transport.prototype.open = function () {
|
23129 | if ('closed' == this.readyState || '' == this.readyState) {
|
23130 | this.readyState = 'opening';
|
23131 | this.doOpen();
|
23132 | }
|
23133 |
|
23134 | return this;
|
23135 | };
|
23136 |
|
23137 |
|
23138 |
|
23139 |
|
23140 |
|
23141 |
|
23142 |
|
23143 | Transport.prototype.close = function () {
|
23144 | if ('opening' == this.readyState || 'open' == this.readyState) {
|
23145 | this.doClose();
|
23146 | this.onClose();
|
23147 | }
|
23148 |
|
23149 | return this;
|
23150 | };
|
23151 |
|
23152 |
|
23153 |
|
23154 |
|
23155 |
|
23156 |
|
23157 |
|
23158 |
|
23159 | Transport.prototype.send = function(packets){
|
23160 | if ('open' == this.readyState) {
|
23161 | this.write(packets);
|
23162 | } else {
|
23163 | throw new Error('Transport not open');
|
23164 | }
|
23165 | };
|
23166 |
|
23167 |
|
23168 |
|
23169 |
|
23170 |
|
23171 |
|
23172 |
|
23173 | Transport.prototype.onOpen = function () {
|
23174 | this.readyState = 'open';
|
23175 | this.writable = true;
|
23176 | this.emit('open');
|
23177 | };
|
23178 |
|
23179 |
|
23180 |
|
23181 |
|
23182 |
|
23183 |
|
23184 |
|
23185 |
|
23186 | Transport.prototype.onData = function(data){
|
23187 | var packet = parser.decodePacket(data, this.socket.binaryType);
|
23188 | this.onPacket(packet);
|
23189 | };
|
23190 |
|
23191 |
|
23192 |
|
23193 |
|
23194 |
|
23195 | Transport.prototype.onPacket = function (packet) {
|
23196 | this.emit('packet', packet);
|
23197 | };
|
23198 |
|
23199 |
|
23200 |
|
23201 |
|
23202 |
|
23203 |
|
23204 |
|
23205 | Transport.prototype.onClose = function () {
|
23206 | this.readyState = 'closed';
|
23207 | this.emit('close');
|
23208 | };
|
23209 |
|
23210 | },{"component-emitter":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-emitter/index.js","engine.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/browser.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/index.js":[function(require,module,exports){
|
23211 | (function (global){
|
23212 |
|
23213 |
|
23214 |
|
23215 |
|
23216 | var XMLHttpRequest = require('xmlhttprequest-ssl');
|
23217 | var XHR = require('./polling-xhr');
|
23218 | var JSONP = require('./polling-jsonp');
|
23219 | var websocket = require('./websocket');
|
23220 |
|
23221 |
|
23222 |
|
23223 |
|
23224 |
|
23225 | exports.polling = polling;
|
23226 | exports.websocket = websocket;
|
23227 |
|
23228 |
|
23229 |
|
23230 |
|
23231 |
|
23232 |
|
23233 |
|
23234 |
|
23235 | function polling(opts){
|
23236 | var xhr;
|
23237 | var xd = false;
|
23238 | var xs = false;
|
23239 | var jsonp = false !== opts.jsonp;
|
23240 |
|
23241 | if (global.location) {
|
23242 | var isSSL = 'https:' == location.protocol;
|
23243 | var port = location.port;
|
23244 |
|
23245 |
|
23246 | if (!port) {
|
23247 | port = isSSL ? 443 : 80;
|
23248 | }
|
23249 |
|
23250 | xd = opts.hostname != location.hostname || port != opts.port;
|
23251 | xs = opts.secure != isSSL;
|
23252 | }
|
23253 |
|
23254 | opts.xdomain = xd;
|
23255 | opts.xscheme = xs;
|
23256 | xhr = new XMLHttpRequest(opts);
|
23257 |
|
23258 | if ('open' in xhr && !opts.forceJSONP) {
|
23259 | return new XHR(opts);
|
23260 | } else {
|
23261 | if (!jsonp) throw new Error('JSONP disabled');
|
23262 | return new JSONP(opts);
|
23263 | }
|
23264 | }
|
23265 |
|
23266 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
23267 | },{"./polling-jsonp":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-jsonp.js","./polling-xhr":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js","./websocket":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/websocket.js","xmlhttprequest-ssl":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/xmlhttprequest.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-jsonp.js":[function(require,module,exports){
|
23268 | (function (global){
|
23269 |
|
23270 |
|
23271 |
|
23272 |
|
23273 |
|
23274 | var Polling = require('./polling');
|
23275 | var inherit = require('component-inherit');
|
23276 |
|
23277 |
|
23278 |
|
23279 |
|
23280 |
|
23281 | module.exports = JSONPPolling;
|
23282 |
|
23283 |
|
23284 |
|
23285 |
|
23286 |
|
23287 | var rNewline = /\n/g;
|
23288 | var rEscapedNewline = /\\n/g;
|
23289 |
|
23290 |
|
23291 |
|
23292 |
|
23293 |
|
23294 | var callbacks;
|
23295 |
|
23296 |
|
23297 |
|
23298 |
|
23299 |
|
23300 | var index = 0;
|
23301 |
|
23302 |
|
23303 |
|
23304 |
|
23305 |
|
23306 | function empty () { }
|
23307 |
|
23308 |
|
23309 |
|
23310 |
|
23311 |
|
23312 |
|
23313 |
|
23314 |
|
23315 | function JSONPPolling (opts) {
|
23316 | Polling.call(this, opts);
|
23317 |
|
23318 | this.query = this.query || {};
|
23319 |
|
23320 |
|
23321 |
|
23322 | if (!callbacks) {
|
23323 |
|
23324 | if (!global.___eio) global.___eio = [];
|
23325 | callbacks = global.___eio;
|
23326 | }
|
23327 |
|
23328 |
|
23329 | this.index = callbacks.length;
|
23330 |
|
23331 |
|
23332 | var self = this;
|
23333 | callbacks.push(function (msg) {
|
23334 | self.onData(msg);
|
23335 | });
|
23336 |
|
23337 |
|
23338 | this.query.j = this.index;
|
23339 |
|
23340 |
|
23341 | if (global.document && global.addEventListener) {
|
23342 | global.addEventListener('beforeunload', function () {
|
23343 | if (self.script) self.script.onerror = empty;
|
23344 | }, false);
|
23345 | }
|
23346 | }
|
23347 |
|
23348 |
|
23349 |
|
23350 |
|
23351 |
|
23352 | inherit(JSONPPolling, Polling);
|
23353 |
|
23354 |
|
23355 |
|
23356 |
|
23357 |
|
23358 | JSONPPolling.prototype.supportsBinary = false;
|
23359 |
|
23360 |
|
23361 |
|
23362 |
|
23363 |
|
23364 |
|
23365 |
|
23366 | JSONPPolling.prototype.doClose = function () {
|
23367 | if (this.script) {
|
23368 | this.script.parentNode.removeChild(this.script);
|
23369 | this.script = null;
|
23370 | }
|
23371 |
|
23372 | if (this.form) {
|
23373 | this.form.parentNode.removeChild(this.form);
|
23374 | this.form = null;
|
23375 | this.iframe = null;
|
23376 | }
|
23377 |
|
23378 | Polling.prototype.doClose.call(this);
|
23379 | };
|
23380 |
|
23381 |
|
23382 |
|
23383 |
|
23384 |
|
23385 |
|
23386 |
|
23387 | JSONPPolling.prototype.doPoll = function () {
|
23388 | var self = this;
|
23389 | var script = document.createElement('script');
|
23390 |
|
23391 | if (this.script) {
|
23392 | this.script.parentNode.removeChild(this.script);
|
23393 | this.script = null;
|
23394 | }
|
23395 |
|
23396 | script.async = true;
|
23397 | script.src = this.uri();
|
23398 | script.onerror = function(e){
|
23399 | self.onError('jsonp poll error',e);
|
23400 | };
|
23401 |
|
23402 | var insertAt = document.getElementsByTagName('script')[0];
|
23403 | insertAt.parentNode.insertBefore(script, insertAt);
|
23404 | this.script = script;
|
23405 |
|
23406 | var isUAgecko = 'undefined' != typeof navigator && /gecko/i.test(navigator.userAgent);
|
23407 |
|
23408 | if (isUAgecko) {
|
23409 | setTimeout(function () {
|
23410 | var iframe = document.createElement('iframe');
|
23411 | document.body.appendChild(iframe);
|
23412 | document.body.removeChild(iframe);
|
23413 | }, 100);
|
23414 | }
|
23415 | };
|
23416 |
|
23417 |
|
23418 |
|
23419 |
|
23420 |
|
23421 |
|
23422 |
|
23423 |
|
23424 |
|
23425 | JSONPPolling.prototype.doWrite = function (data, fn) {
|
23426 | var self = this;
|
23427 |
|
23428 | if (!this.form) {
|
23429 | var form = document.createElement('form');
|
23430 | var area = document.createElement('textarea');
|
23431 | var id = this.iframeId = 'eio_iframe_' + this.index;
|
23432 | var iframe;
|
23433 |
|
23434 | form.className = 'socketio';
|
23435 | form.style.position = 'absolute';
|
23436 | form.style.top = '-1000px';
|
23437 | form.style.left = '-1000px';
|
23438 | form.target = id;
|
23439 | form.method = 'POST';
|
23440 | form.setAttribute('accept-charset', 'utf-8');
|
23441 | area.name = 'd';
|
23442 | form.appendChild(area);
|
23443 | document.body.appendChild(form);
|
23444 |
|
23445 | this.form = form;
|
23446 | this.area = area;
|
23447 | }
|
23448 |
|
23449 | this.form.action = this.uri();
|
23450 |
|
23451 | function complete () {
|
23452 | initIframe();
|
23453 | fn();
|
23454 | }
|
23455 |
|
23456 | function initIframe () {
|
23457 | if (self.iframe) {
|
23458 | try {
|
23459 | self.form.removeChild(self.iframe);
|
23460 | } catch (e) {
|
23461 | self.onError('jsonp polling iframe removal error', e);
|
23462 | }
|
23463 | }
|
23464 |
|
23465 | try {
|
23466 |
|
23467 | var html = '<iframe src="javascript:0" name="'+ self.iframeId +'">';
|
23468 | iframe = document.createElement(html);
|
23469 | } catch (e) {
|
23470 | iframe = document.createElement('iframe');
|
23471 | iframe.name = self.iframeId;
|
23472 | iframe.src = 'javascript:0';
|
23473 | }
|
23474 |
|
23475 | iframe.id = self.iframeId;
|
23476 |
|
23477 | self.form.appendChild(iframe);
|
23478 | self.iframe = iframe;
|
23479 | }
|
23480 |
|
23481 | initIframe();
|
23482 |
|
23483 |
|
23484 |
|
23485 | data = data.replace(rEscapedNewline, '\\\n');
|
23486 | this.area.value = data.replace(rNewline, '\\n');
|
23487 |
|
23488 | try {
|
23489 | this.form.submit();
|
23490 | } catch(e) {}
|
23491 |
|
23492 | if (this.iframe.attachEvent) {
|
23493 | this.iframe.onreadystatechange = function(){
|
23494 | if (self.iframe.readyState == 'complete') {
|
23495 | complete();
|
23496 | }
|
23497 | };
|
23498 | } else {
|
23499 | this.iframe.onload = complete;
|
23500 | }
|
23501 | };
|
23502 |
|
23503 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
23504 | },{"./polling":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js","component-inherit":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-inherit/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js":[function(require,module,exports){
|
23505 | (function (global){
|
23506 |
|
23507 |
|
23508 |
|
23509 |
|
23510 | var XMLHttpRequest = require('xmlhttprequest-ssl');
|
23511 | var Polling = require('./polling');
|
23512 | var Emitter = require('component-emitter');
|
23513 | var inherit = require('component-inherit');
|
23514 | var debug = require('debug')('engine.io-client:polling-xhr');
|
23515 |
|
23516 |
|
23517 |
|
23518 |
|
23519 |
|
23520 | module.exports = XHR;
|
23521 | module.exports.Request = Request;
|
23522 |
|
23523 |
|
23524 |
|
23525 |
|
23526 |
|
23527 | function empty(){}
|
23528 |
|
23529 |
|
23530 |
|
23531 |
|
23532 |
|
23533 |
|
23534 |
|
23535 |
|
23536 | function XHR(opts){
|
23537 | Polling.call(this, opts);
|
23538 |
|
23539 | if (global.location) {
|
23540 | var isSSL = 'https:' == location.protocol;
|
23541 | var port = location.port;
|
23542 |
|
23543 |
|
23544 | if (!port) {
|
23545 | port = isSSL ? 443 : 80;
|
23546 | }
|
23547 |
|
23548 | this.xd = opts.hostname != global.location.hostname ||
|
23549 | port != opts.port;
|
23550 | this.xs = opts.secure != isSSL;
|
23551 | } else {
|
23552 | this.extraHeaders = opts.extraHeaders;
|
23553 | }
|
23554 | }
|
23555 |
|
23556 |
|
23557 |
|
23558 |
|
23559 |
|
23560 | inherit(XHR, Polling);
|
23561 |
|
23562 |
|
23563 |
|
23564 |
|
23565 |
|
23566 | XHR.prototype.supportsBinary = true;
|
23567 |
|
23568 |
|
23569 |
|
23570 |
|
23571 |
|
23572 |
|
23573 |
|
23574 |
|
23575 | XHR.prototype.request = function(opts){
|
23576 | opts = opts || {};
|
23577 | opts.uri = this.uri();
|
23578 | opts.xd = this.xd;
|
23579 | opts.xs = this.xs;
|
23580 | opts.agent = this.agent || false;
|
23581 | opts.supportsBinary = this.supportsBinary;
|
23582 | opts.enablesXDR = this.enablesXDR;
|
23583 |
|
23584 |
|
23585 | opts.pfx = this.pfx;
|
23586 | opts.key = this.key;
|
23587 | opts.passphrase = this.passphrase;
|
23588 | opts.cert = this.cert;
|
23589 | opts.ca = this.ca;
|
23590 | opts.ciphers = this.ciphers;
|
23591 | opts.rejectUnauthorized = this.rejectUnauthorized;
|
23592 |
|
23593 |
|
23594 | opts.extraHeaders = this.extraHeaders;
|
23595 |
|
23596 | return new Request(opts);
|
23597 | };
|
23598 |
|
23599 |
|
23600 |
|
23601 |
|
23602 |
|
23603 |
|
23604 |
|
23605 |
|
23606 |
|
23607 | XHR.prototype.doWrite = function(data, fn){
|
23608 | var isBinary = typeof data !== 'string' && data !== undefined;
|
23609 | var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
|
23610 | var self = this;
|
23611 | req.on('success', fn);
|
23612 | req.on('error', function(err){
|
23613 | self.onError('xhr post error', err);
|
23614 | });
|
23615 | this.sendXhr = req;
|
23616 | };
|
23617 |
|
23618 |
|
23619 |
|
23620 |
|
23621 |
|
23622 |
|
23623 |
|
23624 | XHR.prototype.doPoll = function(){
|
23625 | debug('xhr poll');
|
23626 | var req = this.request();
|
23627 | var self = this;
|
23628 | req.on('data', function(data){
|
23629 | self.onData(data);
|
23630 | });
|
23631 | req.on('error', function(err){
|
23632 | self.onError('xhr poll error', err);
|
23633 | });
|
23634 | this.pollXhr = req;
|
23635 | };
|
23636 |
|
23637 |
|
23638 |
|
23639 |
|
23640 |
|
23641 |
|
23642 |
|
23643 |
|
23644 | function Request(opts){
|
23645 | this.method = opts.method || 'GET';
|
23646 | this.uri = opts.uri;
|
23647 | this.xd = !!opts.xd;
|
23648 | this.xs = !!opts.xs;
|
23649 | this.async = false !== opts.async;
|
23650 | this.data = undefined != opts.data ? opts.data : null;
|
23651 | this.agent = opts.agent;
|
23652 | this.isBinary = opts.isBinary;
|
23653 | this.supportsBinary = opts.supportsBinary;
|
23654 | this.enablesXDR = opts.enablesXDR;
|
23655 |
|
23656 |
|
23657 | this.pfx = opts.pfx;
|
23658 | this.key = opts.key;
|
23659 | this.passphrase = opts.passphrase;
|
23660 | this.cert = opts.cert;
|
23661 | this.ca = opts.ca;
|
23662 | this.ciphers = opts.ciphers;
|
23663 | this.rejectUnauthorized = opts.rejectUnauthorized;
|
23664 |
|
23665 |
|
23666 | this.extraHeaders = opts.extraHeaders;
|
23667 |
|
23668 | this.create();
|
23669 | }
|
23670 |
|
23671 |
|
23672 |
|
23673 |
|
23674 |
|
23675 | Emitter(Request.prototype);
|
23676 |
|
23677 |
|
23678 |
|
23679 |
|
23680 |
|
23681 |
|
23682 |
|
23683 | Request.prototype.create = function(){
|
23684 | var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
|
23685 |
|
23686 |
|
23687 | opts.pfx = this.pfx;
|
23688 | opts.key = this.key;
|
23689 | opts.passphrase = this.passphrase;
|
23690 | opts.cert = this.cert;
|
23691 | opts.ca = this.ca;
|
23692 | opts.ciphers = this.ciphers;
|
23693 | opts.rejectUnauthorized = this.rejectUnauthorized;
|
23694 |
|
23695 | var xhr = this.xhr = new XMLHttpRequest(opts);
|
23696 | var self = this;
|
23697 |
|
23698 | try {
|
23699 | debug('xhr open %s: %s', this.method, this.uri);
|
23700 | xhr.open(this.method, this.uri, this.async);
|
23701 | try {
|
23702 | if (this.extraHeaders) {
|
23703 | xhr.setDisableHeaderCheck(true);
|
23704 | for (var i in this.extraHeaders) {
|
23705 | if (this.extraHeaders.hasOwnProperty(i)) {
|
23706 | xhr.setRequestHeader(i, this.extraHeaders[i]);
|
23707 | }
|
23708 | }
|
23709 | }
|
23710 | } catch (e) {}
|
23711 | if (this.supportsBinary) {
|
23712 |
|
23713 |
|
23714 | xhr.responseType = 'arraybuffer';
|
23715 | }
|
23716 |
|
23717 | if ('POST' == this.method) {
|
23718 | try {
|
23719 | if (this.isBinary) {
|
23720 | xhr.setRequestHeader('Content-type', 'application/octet-stream');
|
23721 | } else {
|
23722 | xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
|
23723 | }
|
23724 | } catch (e) {}
|
23725 | }
|
23726 |
|
23727 |
|
23728 | if ('withCredentials' in xhr) {
|
23729 | xhr.withCredentials = true;
|
23730 | }
|
23731 |
|
23732 | if (this.hasXDR()) {
|
23733 | xhr.onload = function(){
|
23734 | self.onLoad();
|
23735 | };
|
23736 | xhr.onerror = function(){
|
23737 | self.onError(xhr.responseText);
|
23738 | };
|
23739 | } else {
|
23740 | xhr.onreadystatechange = function(){
|
23741 | if (4 != xhr.readyState) return;
|
23742 | if (200 == xhr.status || 1223 == xhr.status) {
|
23743 | self.onLoad();
|
23744 | } else {
|
23745 |
|
23746 |
|
23747 | setTimeout(function(){
|
23748 | self.onError(xhr.status);
|
23749 | }, 0);
|
23750 | }
|
23751 | };
|
23752 | }
|
23753 |
|
23754 | debug('xhr data %s', this.data);
|
23755 | xhr.send(this.data);
|
23756 | } catch (e) {
|
23757 |
|
23758 |
|
23759 |
|
23760 | setTimeout(function() {
|
23761 | self.onError(e);
|
23762 | }, 0);
|
23763 | return;
|
23764 | }
|
23765 |
|
23766 | if (global.document) {
|
23767 | this.index = Request.requestsCount++;
|
23768 | Request.requests[this.index] = this;
|
23769 | }
|
23770 | };
|
23771 |
|
23772 |
|
23773 |
|
23774 |
|
23775 |
|
23776 |
|
23777 |
|
23778 | Request.prototype.onSuccess = function(){
|
23779 | this.emit('success');
|
23780 | this.cleanup();
|
23781 | };
|
23782 |
|
23783 |
|
23784 |
|
23785 |
|
23786 |
|
23787 |
|
23788 |
|
23789 | Request.prototype.onData = function(data){
|
23790 | this.emit('data', data);
|
23791 | this.onSuccess();
|
23792 | };
|
23793 |
|
23794 |
|
23795 |
|
23796 |
|
23797 |
|
23798 |
|
23799 |
|
23800 | Request.prototype.onError = function(err){
|
23801 | this.emit('error', err);
|
23802 | this.cleanup(true);
|
23803 | };
|
23804 |
|
23805 |
|
23806 |
|
23807 |
|
23808 |
|
23809 |
|
23810 |
|
23811 | Request.prototype.cleanup = function(fromError){
|
23812 | if ('undefined' == typeof this.xhr || null === this.xhr) {
|
23813 | return;
|
23814 | }
|
23815 |
|
23816 | if (this.hasXDR()) {
|
23817 | this.xhr.onload = this.xhr.onerror = empty;
|
23818 | } else {
|
23819 | this.xhr.onreadystatechange = empty;
|
23820 | }
|
23821 |
|
23822 | if (fromError) {
|
23823 | try {
|
23824 | this.xhr.abort();
|
23825 | } catch(e) {}
|
23826 | }
|
23827 |
|
23828 | if (global.document) {
|
23829 | delete Request.requests[this.index];
|
23830 | }
|
23831 |
|
23832 | this.xhr = null;
|
23833 | };
|
23834 |
|
23835 |
|
23836 |
|
23837 |
|
23838 |
|
23839 |
|
23840 |
|
23841 | Request.prototype.onLoad = function(){
|
23842 | var data;
|
23843 | try {
|
23844 | var contentType;
|
23845 | try {
|
23846 | contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0];
|
23847 | } catch (e) {}
|
23848 | if (contentType === 'application/octet-stream') {
|
23849 | data = this.xhr.response;
|
23850 | } else {
|
23851 | if (!this.supportsBinary) {
|
23852 | data = this.xhr.responseText;
|
23853 | } else {
|
23854 | try {
|
23855 | data = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response));
|
23856 | } catch (e) {
|
23857 | var ui8Arr = new Uint8Array(this.xhr.response);
|
23858 | var dataArray = [];
|
23859 | for (var idx = 0, length = ui8Arr.length; idx < length; idx++) {
|
23860 | dataArray.push(ui8Arr[idx]);
|
23861 | }
|
23862 |
|
23863 | data = String.fromCharCode.apply(null, dataArray);
|
23864 | }
|
23865 | }
|
23866 | }
|
23867 | } catch (e) {
|
23868 | this.onError(e);
|
23869 | }
|
23870 | if (null != data) {
|
23871 | this.onData(data);
|
23872 | }
|
23873 | };
|
23874 |
|
23875 |
|
23876 |
|
23877 |
|
23878 |
|
23879 |
|
23880 |
|
23881 | Request.prototype.hasXDR = function(){
|
23882 | return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR;
|
23883 | };
|
23884 |
|
23885 |
|
23886 |
|
23887 |
|
23888 |
|
23889 |
|
23890 |
|
23891 | Request.prototype.abort = function(){
|
23892 | this.cleanup();
|
23893 | };
|
23894 |
|
23895 |
|
23896 |
|
23897 |
|
23898 |
|
23899 |
|
23900 |
|
23901 | if (global.document) {
|
23902 | Request.requestsCount = 0;
|
23903 | Request.requests = {};
|
23904 | if (global.attachEvent) {
|
23905 | global.attachEvent('onunload', unloadHandler);
|
23906 | } else if (global.addEventListener) {
|
23907 | global.addEventListener('beforeunload', unloadHandler, false);
|
23908 | }
|
23909 | }
|
23910 |
|
23911 | function unloadHandler() {
|
23912 | for (var i in Request.requests) {
|
23913 | if (Request.requests.hasOwnProperty(i)) {
|
23914 | Request.requests[i].abort();
|
23915 | }
|
23916 | }
|
23917 | }
|
23918 |
|
23919 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
23920 | },{"./polling":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js","component-emitter":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-emitter/index.js","component-inherit":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-inherit/index.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","xmlhttprequest-ssl":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/xmlhttprequest.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js":[function(require,module,exports){
|
23921 |
|
23922 |
|
23923 |
|
23924 |
|
23925 | var Transport = require('../transport');
|
23926 | var parseqs = require('parseqs');
|
23927 | var parser = require('engine.io-parser');
|
23928 | var inherit = require('component-inherit');
|
23929 | var yeast = require('yeast');
|
23930 | var debug = require('debug')('engine.io-client:polling');
|
23931 |
|
23932 |
|
23933 |
|
23934 |
|
23935 |
|
23936 | module.exports = Polling;
|
23937 |
|
23938 |
|
23939 |
|
23940 |
|
23941 |
|
23942 | var hasXHR2 = (function() {
|
23943 | var XMLHttpRequest = require('xmlhttprequest-ssl');
|
23944 | var xhr = new XMLHttpRequest({ xdomain: false });
|
23945 | return null != xhr.responseType;
|
23946 | })();
|
23947 |
|
23948 |
|
23949 |
|
23950 |
|
23951 |
|
23952 |
|
23953 |
|
23954 |
|
23955 | function Polling(opts){
|
23956 | var forceBase64 = (opts && opts.forceBase64);
|
23957 | if (!hasXHR2 || forceBase64) {
|
23958 | this.supportsBinary = false;
|
23959 | }
|
23960 | Transport.call(this, opts);
|
23961 | }
|
23962 |
|
23963 |
|
23964 |
|
23965 |
|
23966 |
|
23967 | inherit(Polling, Transport);
|
23968 |
|
23969 |
|
23970 |
|
23971 |
|
23972 |
|
23973 | Polling.prototype.name = 'polling';
|
23974 |
|
23975 |
|
23976 |
|
23977 |
|
23978 |
|
23979 |
|
23980 |
|
23981 |
|
23982 | Polling.prototype.doOpen = function(){
|
23983 | this.poll();
|
23984 | };
|
23985 |
|
23986 |
|
23987 |
|
23988 |
|
23989 |
|
23990 |
|
23991 |
|
23992 |
|
23993 | Polling.prototype.pause = function(onPause){
|
23994 | var pending = 0;
|
23995 | var self = this;
|
23996 |
|
23997 | this.readyState = 'pausing';
|
23998 |
|
23999 | function pause(){
|
24000 | debug('paused');
|
24001 | self.readyState = 'paused';
|
24002 | onPause();
|
24003 | }
|
24004 |
|
24005 | if (this.polling || !this.writable) {
|
24006 | var total = 0;
|
24007 |
|
24008 | if (this.polling) {
|
24009 | debug('we are currently polling - waiting to pause');
|
24010 | total++;
|
24011 | this.once('pollComplete', function(){
|
24012 | debug('pre-pause polling complete');
|
24013 | --total || pause();
|
24014 | });
|
24015 | }
|
24016 |
|
24017 | if (!this.writable) {
|
24018 | debug('we are currently writing - waiting to pause');
|
24019 | total++;
|
24020 | this.once('drain', function(){
|
24021 | debug('pre-pause writing complete');
|
24022 | --total || pause();
|
24023 | });
|
24024 | }
|
24025 | } else {
|
24026 | pause();
|
24027 | }
|
24028 | };
|
24029 |
|
24030 |
|
24031 |
|
24032 |
|
24033 |
|
24034 |
|
24035 |
|
24036 | Polling.prototype.poll = function(){
|
24037 | debug('polling');
|
24038 | this.polling = true;
|
24039 | this.doPoll();
|
24040 | this.emit('poll');
|
24041 | };
|
24042 |
|
24043 |
|
24044 |
|
24045 |
|
24046 |
|
24047 |
|
24048 |
|
24049 | Polling.prototype.onData = function(data){
|
24050 | var self = this;
|
24051 | debug('polling got data %s', data);
|
24052 | var callback = function(packet, index, total) {
|
24053 |
|
24054 | if ('opening' == self.readyState) {
|
24055 | self.onOpen();
|
24056 | }
|
24057 |
|
24058 |
|
24059 | if ('close' == packet.type) {
|
24060 | self.onClose();
|
24061 | return false;
|
24062 | }
|
24063 |
|
24064 |
|
24065 | self.onPacket(packet);
|
24066 | };
|
24067 |
|
24068 |
|
24069 | parser.decodePayload(data, this.socket.binaryType, callback);
|
24070 |
|
24071 |
|
24072 | if ('closed' != this.readyState) {
|
24073 |
|
24074 | this.polling = false;
|
24075 | this.emit('pollComplete');
|
24076 |
|
24077 | if ('open' == this.readyState) {
|
24078 | this.poll();
|
24079 | } else {
|
24080 | debug('ignoring poll - transport state "%s"', this.readyState);
|
24081 | }
|
24082 | }
|
24083 | };
|
24084 |
|
24085 |
|
24086 |
|
24087 |
|
24088 |
|
24089 |
|
24090 |
|
24091 | Polling.prototype.doClose = function(){
|
24092 | var self = this;
|
24093 |
|
24094 | function close(){
|
24095 | debug('writing close packet');
|
24096 | self.write([{ type: 'close' }]);
|
24097 | }
|
24098 |
|
24099 | if ('open' == this.readyState) {
|
24100 | debug('transport open - closing');
|
24101 | close();
|
24102 | } else {
|
24103 |
|
24104 |
|
24105 | debug('transport not open - deferring close');
|
24106 | this.once('open', close);
|
24107 | }
|
24108 | };
|
24109 |
|
24110 |
|
24111 |
|
24112 |
|
24113 |
|
24114 |
|
24115 |
|
24116 |
|
24117 |
|
24118 | Polling.prototype.write = function(packets){
|
24119 | var self = this;
|
24120 | this.writable = false;
|
24121 | var callbackfn = function() {
|
24122 | self.writable = true;
|
24123 | self.emit('drain');
|
24124 | };
|
24125 |
|
24126 | var self = this;
|
24127 | parser.encodePayload(packets, this.supportsBinary, function(data) {
|
24128 | self.doWrite(data, callbackfn);
|
24129 | });
|
24130 | };
|
24131 |
|
24132 |
|
24133 |
|
24134 |
|
24135 |
|
24136 |
|
24137 |
|
24138 | Polling.prototype.uri = function(){
|
24139 | var query = this.query || {};
|
24140 | var schema = this.secure ? 'https' : 'http';
|
24141 | var port = '';
|
24142 |
|
24143 |
|
24144 | if (false !== this.timestampRequests) {
|
24145 | query[this.timestampParam] = yeast();
|
24146 | }
|
24147 |
|
24148 | if (!this.supportsBinary && !query.sid) {
|
24149 | query.b64 = 1;
|
24150 | }
|
24151 |
|
24152 | query = parseqs.encode(query);
|
24153 |
|
24154 |
|
24155 | if (this.port && (('https' == schema && this.port != 443) ||
|
24156 | ('http' == schema && this.port != 80))) {
|
24157 | port = ':' + this.port;
|
24158 | }
|
24159 |
|
24160 |
|
24161 | if (query.length) {
|
24162 | query = '?' + query;
|
24163 | }
|
24164 |
|
24165 | var ipv6 = this.hostname.indexOf(':') !== -1;
|
24166 | return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
|
24167 | };
|
24168 |
|
24169 | },{"../transport":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transport.js","component-inherit":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-inherit/index.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","engine.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/browser.js","parseqs":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/parseqs/index.js","xmlhttprequest-ssl":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/xmlhttprequest.js","yeast":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/yeast/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/websocket.js":[function(require,module,exports){
|
24170 | (function (global){
|
24171 |
|
24172 |
|
24173 |
|
24174 |
|
24175 | var Transport = require('../transport');
|
24176 | var parser = require('engine.io-parser');
|
24177 | var parseqs = require('parseqs');
|
24178 | var inherit = require('component-inherit');
|
24179 | var yeast = require('yeast');
|
24180 | var debug = require('debug')('engine.io-client:websocket');
|
24181 |
|
24182 |
|
24183 |
|
24184 |
|
24185 |
|
24186 |
|
24187 |
|
24188 | var WebSocket = require('ws');
|
24189 |
|
24190 |
|
24191 |
|
24192 |
|
24193 |
|
24194 | module.exports = WS;
|
24195 |
|
24196 |
|
24197 |
|
24198 |
|
24199 |
|
24200 |
|
24201 |
|
24202 |
|
24203 | function WS(opts){
|
24204 | var forceBase64 = (opts && opts.forceBase64);
|
24205 | if (forceBase64) {
|
24206 | this.supportsBinary = false;
|
24207 | }
|
24208 | this.perMessageDeflate = opts.perMessageDeflate;
|
24209 | Transport.call(this, opts);
|
24210 | }
|
24211 |
|
24212 |
|
24213 |
|
24214 |
|
24215 |
|
24216 | inherit(WS, Transport);
|
24217 |
|
24218 |
|
24219 |
|
24220 |
|
24221 |
|
24222 |
|
24223 |
|
24224 | WS.prototype.name = 'websocket';
|
24225 |
|
24226 |
|
24227 |
|
24228 |
|
24229 |
|
24230 | WS.prototype.supportsBinary = true;
|
24231 |
|
24232 |
|
24233 |
|
24234 |
|
24235 |
|
24236 |
|
24237 |
|
24238 | WS.prototype.doOpen = function(){
|
24239 | if (!this.check()) {
|
24240 |
|
24241 | return;
|
24242 | }
|
24243 |
|
24244 | var self = this;
|
24245 | var uri = this.uri();
|
24246 | var protocols = void(0);
|
24247 | var opts = {
|
24248 | agent: this.agent,
|
24249 | perMessageDeflate: this.perMessageDeflate
|
24250 | };
|
24251 |
|
24252 |
|
24253 | opts.pfx = this.pfx;
|
24254 | opts.key = this.key;
|
24255 | opts.passphrase = this.passphrase;
|
24256 | opts.cert = this.cert;
|
24257 | opts.ca = this.ca;
|
24258 | opts.ciphers = this.ciphers;
|
24259 | opts.rejectUnauthorized = this.rejectUnauthorized;
|
24260 | if (this.extraHeaders) {
|
24261 | opts.headers = this.extraHeaders;
|
24262 | }
|
24263 |
|
24264 | this.ws = new WebSocket(uri, protocols, opts);
|
24265 |
|
24266 | if (this.ws.binaryType === undefined) {
|
24267 | this.supportsBinary = false;
|
24268 | }
|
24269 |
|
24270 | if (this.ws.supports && this.ws.supports.binary) {
|
24271 | this.supportsBinary = true;
|
24272 | this.ws.binaryType = 'buffer';
|
24273 | } else {
|
24274 | this.ws.binaryType = 'arraybuffer';
|
24275 | }
|
24276 |
|
24277 | this.addEventListeners();
|
24278 | };
|
24279 |
|
24280 |
|
24281 |
|
24282 |
|
24283 |
|
24284 |
|
24285 |
|
24286 | WS.prototype.addEventListeners = function(){
|
24287 | var self = this;
|
24288 |
|
24289 | this.ws.onopen = function(){
|
24290 | self.onOpen();
|
24291 | };
|
24292 | this.ws.onclose = function(){
|
24293 | self.onClose();
|
24294 | };
|
24295 | this.ws.onmessage = function(ev){
|
24296 | self.onData(ev.data);
|
24297 | };
|
24298 | this.ws.onerror = function(e){
|
24299 | self.onError('websocket error', e);
|
24300 | };
|
24301 | };
|
24302 |
|
24303 |
|
24304 |
|
24305 |
|
24306 |
|
24307 |
|
24308 |
|
24309 |
|
24310 | if ('undefined' != typeof navigator
|
24311 | && /iPad|iPhone|iPod/i.test(navigator.userAgent)) {
|
24312 | WS.prototype.onData = function(data){
|
24313 | var self = this;
|
24314 | setTimeout(function(){
|
24315 | Transport.prototype.onData.call(self, data);
|
24316 | }, 0);
|
24317 | };
|
24318 | }
|
24319 |
|
24320 |
|
24321 |
|
24322 |
|
24323 |
|
24324 |
|
24325 |
|
24326 |
|
24327 | WS.prototype.write = function(packets){
|
24328 | var self = this;
|
24329 | this.writable = false;
|
24330 |
|
24331 | var isBrowserWebSocket = global.WebSocket && this.ws instanceof global.WebSocket;
|
24332 |
|
24333 |
|
24334 |
|
24335 | var total = packets.length;
|
24336 | for (var i = 0, l = total; i < l; i++) {
|
24337 | (function(packet) {
|
24338 | parser.encodePacket(packet, self.supportsBinary, function(data) {
|
24339 | if (!isBrowserWebSocket) {
|
24340 |
|
24341 | var opts = {};
|
24342 | if (packet.options) {
|
24343 | opts.compress = packet.options.compress;
|
24344 | }
|
24345 |
|
24346 | if (self.perMessageDeflate) {
|
24347 | var len = 'string' == typeof data ? global.Buffer.byteLength(data) : data.length;
|
24348 | if (len < self.perMessageDeflate.threshold) {
|
24349 | opts.compress = false;
|
24350 | }
|
24351 | }
|
24352 | }
|
24353 |
|
24354 |
|
24355 |
|
24356 |
|
24357 | try {
|
24358 | if (isBrowserWebSocket) {
|
24359 |
|
24360 | self.ws.send(data);
|
24361 | } else {
|
24362 | self.ws.send(data, opts);
|
24363 | }
|
24364 | } catch (e){
|
24365 | debug('websocket closed before onclose event');
|
24366 | }
|
24367 |
|
24368 | --total || done();
|
24369 | });
|
24370 | })(packets[i]);
|
24371 | }
|
24372 |
|
24373 | function done(){
|
24374 | self.emit('flush');
|
24375 |
|
24376 |
|
24377 |
|
24378 | setTimeout(function(){
|
24379 | self.writable = true;
|
24380 | self.emit('drain');
|
24381 | }, 0);
|
24382 | }
|
24383 | };
|
24384 |
|
24385 |
|
24386 |
|
24387 |
|
24388 |
|
24389 |
|
24390 |
|
24391 | WS.prototype.onClose = function(){
|
24392 | Transport.prototype.onClose.call(this);
|
24393 | };
|
24394 |
|
24395 |
|
24396 |
|
24397 |
|
24398 |
|
24399 |
|
24400 |
|
24401 | WS.prototype.doClose = function(){
|
24402 | if (typeof this.ws !== 'undefined') {
|
24403 | this.ws.close();
|
24404 | }
|
24405 | };
|
24406 |
|
24407 |
|
24408 |
|
24409 |
|
24410 |
|
24411 |
|
24412 |
|
24413 | WS.prototype.uri = function(){
|
24414 | var query = this.query || {};
|
24415 | var schema = this.secure ? 'wss' : 'ws';
|
24416 | var port = '';
|
24417 |
|
24418 |
|
24419 | if (this.port && (('wss' == schema && this.port != 443)
|
24420 | || ('ws' == schema && this.port != 80))) {
|
24421 | port = ':' + this.port;
|
24422 | }
|
24423 |
|
24424 |
|
24425 | if (this.timestampRequests) {
|
24426 | query[this.timestampParam] = yeast();
|
24427 | }
|
24428 |
|
24429 |
|
24430 | if (!this.supportsBinary) {
|
24431 | query.b64 = 1;
|
24432 | }
|
24433 |
|
24434 | query = parseqs.encode(query);
|
24435 |
|
24436 |
|
24437 | if (query.length) {
|
24438 | query = '?' + query;
|
24439 | }
|
24440 |
|
24441 | var ipv6 = this.hostname.indexOf(':') !== -1;
|
24442 | return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
|
24443 | };
|
24444 |
|
24445 |
|
24446 |
|
24447 |
|
24448 |
|
24449 |
|
24450 |
|
24451 |
|
24452 | WS.prototype.check = function(){
|
24453 | return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name);
|
24454 | };
|
24455 |
|
24456 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
24457 | },{"../transport":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/transport.js","component-inherit":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-inherit/index.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","engine.io-parser":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/browser.js","parseqs":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/parseqs/index.js","ws":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/browser.js","yeast":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/yeast/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/lib/xmlhttprequest.js":[function(require,module,exports){
|
24458 |
|
24459 | var hasCORS = require('has-cors');
|
24460 |
|
24461 | module.exports = function(opts) {
|
24462 | var xdomain = opts.xdomain;
|
24463 |
|
24464 |
|
24465 |
|
24466 | var xscheme = opts.xscheme;
|
24467 |
|
24468 |
|
24469 |
|
24470 | var enablesXDR = opts.enablesXDR;
|
24471 |
|
24472 |
|
24473 | try {
|
24474 | if ('undefined' != typeof XMLHttpRequest && (!xdomain || hasCORS)) {
|
24475 | return new XMLHttpRequest();
|
24476 | }
|
24477 | } catch (e) { }
|
24478 |
|
24479 |
|
24480 |
|
24481 |
|
24482 | try {
|
24483 | if ('undefined' != typeof XDomainRequest && !xscheme && enablesXDR) {
|
24484 | return new XDomainRequest();
|
24485 | }
|
24486 | } catch (e) { }
|
24487 |
|
24488 | if (!xdomain) {
|
24489 | try {
|
24490 | return new ActiveXObject('Microsoft.XMLHTTP');
|
24491 | } catch(e) { }
|
24492 | }
|
24493 | }
|
24494 |
|
24495 | },{"has-cors":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/has-cors/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-emitter/index.js":[function(require,module,exports){
|
24496 |
|
24497 |
|
24498 |
|
24499 |
|
24500 |
|
24501 | module.exports = Emitter;
|
24502 |
|
24503 |
|
24504 |
|
24505 |
|
24506 |
|
24507 |
|
24508 |
|
24509 | function Emitter(obj) {
|
24510 | if (obj) return mixin(obj);
|
24511 | };
|
24512 |
|
24513 |
|
24514 |
|
24515 |
|
24516 |
|
24517 |
|
24518 |
|
24519 |
|
24520 |
|
24521 | function mixin(obj) {
|
24522 | for (var key in Emitter.prototype) {
|
24523 | obj[key] = Emitter.prototype[key];
|
24524 | }
|
24525 | return obj;
|
24526 | }
|
24527 |
|
24528 |
|
24529 |
|
24530 |
|
24531 |
|
24532 |
|
24533 |
|
24534 |
|
24535 |
|
24536 |
|
24537 | Emitter.prototype.on =
|
24538 | Emitter.prototype.addEventListener = function(event, fn){
|
24539 | this._callbacks = this._callbacks || {};
|
24540 | (this._callbacks[event] = this._callbacks[event] || [])
|
24541 | .push(fn);
|
24542 | return this;
|
24543 | };
|
24544 |
|
24545 |
|
24546 |
|
24547 |
|
24548 |
|
24549 |
|
24550 |
|
24551 |
|
24552 |
|
24553 |
|
24554 |
|
24555 | Emitter.prototype.once = function(event, fn){
|
24556 | var self = this;
|
24557 | this._callbacks = this._callbacks || {};
|
24558 |
|
24559 | function on() {
|
24560 | self.off(event, on);
|
24561 | fn.apply(this, arguments);
|
24562 | }
|
24563 |
|
24564 | on.fn = fn;
|
24565 | this.on(event, on);
|
24566 | return this;
|
24567 | };
|
24568 |
|
24569 |
|
24570 |
|
24571 |
|
24572 |
|
24573 |
|
24574 |
|
24575 |
|
24576 |
|
24577 |
|
24578 |
|
24579 | Emitter.prototype.off =
|
24580 | Emitter.prototype.removeListener =
|
24581 | Emitter.prototype.removeAllListeners =
|
24582 | Emitter.prototype.removeEventListener = function(event, fn){
|
24583 | this._callbacks = this._callbacks || {};
|
24584 |
|
24585 |
|
24586 | if (0 == arguments.length) {
|
24587 | this._callbacks = {};
|
24588 | return this;
|
24589 | }
|
24590 |
|
24591 |
|
24592 | var callbacks = this._callbacks[event];
|
24593 | if (!callbacks) return this;
|
24594 |
|
24595 |
|
24596 | if (1 == arguments.length) {
|
24597 | delete this._callbacks[event];
|
24598 | return this;
|
24599 | }
|
24600 |
|
24601 |
|
24602 | var cb;
|
24603 | for (var i = 0; i < callbacks.length; i++) {
|
24604 | cb = callbacks[i];
|
24605 | if (cb === fn || cb.fn === fn) {
|
24606 | callbacks.splice(i, 1);
|
24607 | break;
|
24608 | }
|
24609 | }
|
24610 | return this;
|
24611 | };
|
24612 |
|
24613 |
|
24614 |
|
24615 |
|
24616 |
|
24617 |
|
24618 |
|
24619 |
|
24620 |
|
24621 | Emitter.prototype.emit = function(event){
|
24622 | this._callbacks = this._callbacks || {};
|
24623 | var args = [].slice.call(arguments, 1)
|
24624 | , callbacks = this._callbacks[event];
|
24625 |
|
24626 | if (callbacks) {
|
24627 | callbacks = callbacks.slice(0);
|
24628 | for (var i = 0, len = callbacks.length; i < len; ++i) {
|
24629 | callbacks[i].apply(this, args);
|
24630 | }
|
24631 | }
|
24632 |
|
24633 | return this;
|
24634 | };
|
24635 |
|
24636 |
|
24637 |
|
24638 |
|
24639 |
|
24640 |
|
24641 |
|
24642 |
|
24643 |
|
24644 | Emitter.prototype.listeners = function(event){
|
24645 | this._callbacks = this._callbacks || {};
|
24646 | return this._callbacks[event] || [];
|
24647 | };
|
24648 |
|
24649 |
|
24650 |
|
24651 |
|
24652 |
|
24653 |
|
24654 |
|
24655 |
|
24656 |
|
24657 | Emitter.prototype.hasListeners = function(event){
|
24658 | return !! this.listeners(event).length;
|
24659 | };
|
24660 |
|
24661 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-inherit/index.js":[function(require,module,exports){
|
24662 |
|
24663 | module.exports = function(a, b){
|
24664 | var fn = function(){};
|
24665 | fn.prototype = b.prototype;
|
24666 | a.prototype = new fn;
|
24667 | a.prototype.constructor = a;
|
24668 | };
|
24669 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/browser.js":[function(require,module,exports){
|
24670 | (function (global){
|
24671 |
|
24672 |
|
24673 |
|
24674 |
|
24675 | var keys = require('./keys');
|
24676 | var hasBinary = require('has-binary');
|
24677 | var sliceBuffer = require('arraybuffer.slice');
|
24678 | var base64encoder = require('base64-arraybuffer');
|
24679 | var after = require('after');
|
24680 | var utf8 = require('utf8');
|
24681 |
|
24682 |
|
24683 |
|
24684 |
|
24685 |
|
24686 |
|
24687 |
|
24688 |
|
24689 | var isAndroid = navigator.userAgent.match(/Android/i);
|
24690 |
|
24691 |
|
24692 |
|
24693 |
|
24694 |
|
24695 |
|
24696 |
|
24697 | var isPhantomJS = /PhantomJS/i.test(navigator.userAgent);
|
24698 |
|
24699 |
|
24700 |
|
24701 |
|
24702 |
|
24703 | var dontSendBlobs = isAndroid || isPhantomJS;
|
24704 |
|
24705 |
|
24706 |
|
24707 |
|
24708 |
|
24709 | exports.protocol = 3;
|
24710 |
|
24711 |
|
24712 |
|
24713 |
|
24714 |
|
24715 | var packets = exports.packets = {
|
24716 | open: 0
|
24717 | , close: 1
|
24718 | , ping: 2
|
24719 | , pong: 3
|
24720 | , message: 4
|
24721 | , upgrade: 5
|
24722 | , noop: 6
|
24723 | };
|
24724 |
|
24725 | var packetslist = keys(packets);
|
24726 |
|
24727 |
|
24728 |
|
24729 |
|
24730 |
|
24731 | var err = { type: 'error', data: 'parser error' };
|
24732 |
|
24733 |
|
24734 |
|
24735 |
|
24736 |
|
24737 | var Blob = require('blob');
|
24738 |
|
24739 |
|
24740 |
|
24741 |
|
24742 |
|
24743 |
|
24744 |
|
24745 |
|
24746 |
|
24747 |
|
24748 |
|
24749 |
|
24750 |
|
24751 |
|
24752 |
|
24753 |
|
24754 |
|
24755 | exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
|
24756 | if ('function' == typeof supportsBinary) {
|
24757 | callback = supportsBinary;
|
24758 | supportsBinary = false;
|
24759 | }
|
24760 |
|
24761 | if ('function' == typeof utf8encode) {
|
24762 | callback = utf8encode;
|
24763 | utf8encode = null;
|
24764 | }
|
24765 |
|
24766 | var data = (packet.data === undefined)
|
24767 | ? undefined
|
24768 | : packet.data.buffer || packet.data;
|
24769 |
|
24770 | if (global.ArrayBuffer && data instanceof ArrayBuffer) {
|
24771 | return encodeArrayBuffer(packet, supportsBinary, callback);
|
24772 | } else if (Blob && data instanceof global.Blob) {
|
24773 | return encodeBlob(packet, supportsBinary, callback);
|
24774 | }
|
24775 |
|
24776 |
|
24777 | if (data && data.base64) {
|
24778 | return encodeBase64Object(packet, callback);
|
24779 | }
|
24780 |
|
24781 |
|
24782 | var encoded = packets[packet.type];
|
24783 |
|
24784 |
|
24785 | if (undefined !== packet.data) {
|
24786 | encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data);
|
24787 | }
|
24788 |
|
24789 | return callback('' + encoded);
|
24790 |
|
24791 | };
|
24792 |
|
24793 | function encodeBase64Object(packet, callback) {
|
24794 |
|
24795 | var message = 'b' + exports.packets[packet.type] + packet.data.data;
|
24796 | return callback(message);
|
24797 | }
|
24798 |
|
24799 |
|
24800 |
|
24801 |
|
24802 |
|
24803 | function encodeArrayBuffer(packet, supportsBinary, callback) {
|
24804 | if (!supportsBinary) {
|
24805 | return exports.encodeBase64Packet(packet, callback);
|
24806 | }
|
24807 |
|
24808 | var data = packet.data;
|
24809 | var contentArray = new Uint8Array(data);
|
24810 | var resultBuffer = new Uint8Array(1 + data.byteLength);
|
24811 |
|
24812 | resultBuffer[0] = packets[packet.type];
|
24813 | for (var i = 0; i < contentArray.length; i++) {
|
24814 | resultBuffer[i+1] = contentArray[i];
|
24815 | }
|
24816 |
|
24817 | return callback(resultBuffer.buffer);
|
24818 | }
|
24819 |
|
24820 | function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
|
24821 | if (!supportsBinary) {
|
24822 | return exports.encodeBase64Packet(packet, callback);
|
24823 | }
|
24824 |
|
24825 | var fr = new FileReader();
|
24826 | fr.onload = function() {
|
24827 | packet.data = fr.result;
|
24828 | exports.encodePacket(packet, supportsBinary, true, callback);
|
24829 | };
|
24830 | return fr.readAsArrayBuffer(packet.data);
|
24831 | }
|
24832 |
|
24833 | function encodeBlob(packet, supportsBinary, callback) {
|
24834 | if (!supportsBinary) {
|
24835 | return exports.encodeBase64Packet(packet, callback);
|
24836 | }
|
24837 |
|
24838 | if (dontSendBlobs) {
|
24839 | return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
|
24840 | }
|
24841 |
|
24842 | var length = new Uint8Array(1);
|
24843 | length[0] = packets[packet.type];
|
24844 | var blob = new Blob([length.buffer, packet.data]);
|
24845 |
|
24846 | return callback(blob);
|
24847 | }
|
24848 |
|
24849 |
|
24850 |
|
24851 |
|
24852 |
|
24853 |
|
24854 |
|
24855 |
|
24856 | exports.encodeBase64Packet = function(packet, callback) {
|
24857 | var message = 'b' + exports.packets[packet.type];
|
24858 | if (Blob && packet.data instanceof global.Blob) {
|
24859 | var fr = new FileReader();
|
24860 | fr.onload = function() {
|
24861 | var b64 = fr.result.split(',')[1];
|
24862 | callback(message + b64);
|
24863 | };
|
24864 | return fr.readAsDataURL(packet.data);
|
24865 | }
|
24866 |
|
24867 | var b64data;
|
24868 | try {
|
24869 | b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
|
24870 | } catch (e) {
|
24871 |
|
24872 | var typed = new Uint8Array(packet.data);
|
24873 | var basic = new Array(typed.length);
|
24874 | for (var i = 0; i < typed.length; i++) {
|
24875 | basic[i] = typed[i];
|
24876 | }
|
24877 | b64data = String.fromCharCode.apply(null, basic);
|
24878 | }
|
24879 | message += global.btoa(b64data);
|
24880 | return callback(message);
|
24881 | };
|
24882 |
|
24883 |
|
24884 |
|
24885 |
|
24886 |
|
24887 |
|
24888 |
|
24889 |
|
24890 | exports.decodePacket = function (data, binaryType, utf8decode) {
|
24891 |
|
24892 | if (typeof data == 'string' || data === undefined) {
|
24893 | if (data.charAt(0) == 'b') {
|
24894 | return exports.decodeBase64Packet(data.substr(1), binaryType);
|
24895 | }
|
24896 |
|
24897 | if (utf8decode) {
|
24898 | try {
|
24899 | data = utf8.decode(data);
|
24900 | } catch (e) {
|
24901 | return err;
|
24902 | }
|
24903 | }
|
24904 | var type = data.charAt(0);
|
24905 |
|
24906 | if (Number(type) != type || !packetslist[type]) {
|
24907 | return err;
|
24908 | }
|
24909 |
|
24910 | if (data.length > 1) {
|
24911 | return { type: packetslist[type], data: data.substring(1) };
|
24912 | } else {
|
24913 | return { type: packetslist[type] };
|
24914 | }
|
24915 | }
|
24916 |
|
24917 | var asArray = new Uint8Array(data);
|
24918 | var type = asArray[0];
|
24919 | var rest = sliceBuffer(data, 1);
|
24920 | if (Blob && binaryType === 'blob') {
|
24921 | rest = new Blob([rest]);
|
24922 | }
|
24923 | return { type: packetslist[type], data: rest };
|
24924 | };
|
24925 |
|
24926 |
|
24927 |
|
24928 |
|
24929 |
|
24930 |
|
24931 |
|
24932 |
|
24933 | exports.decodeBase64Packet = function(msg, binaryType) {
|
24934 | var type = packetslist[msg.charAt(0)];
|
24935 | if (!global.ArrayBuffer) {
|
24936 | return { type: type, data: { base64: true, data: msg.substr(1) } };
|
24937 | }
|
24938 |
|
24939 | var data = base64encoder.decode(msg.substr(1));
|
24940 |
|
24941 | if (binaryType === 'blob' && Blob) {
|
24942 | data = new Blob([data]);
|
24943 | }
|
24944 |
|
24945 | return { type: type, data: data };
|
24946 | };
|
24947 |
|
24948 |
|
24949 |
|
24950 |
|
24951 |
|
24952 |
|
24953 |
|
24954 |
|
24955 |
|
24956 |
|
24957 |
|
24958 |
|
24959 |
|
24960 |
|
24961 |
|
24962 |
|
24963 |
|
24964 | exports.encodePayload = function (packets, supportsBinary, callback) {
|
24965 | if (typeof supportsBinary == 'function') {
|
24966 | callback = supportsBinary;
|
24967 | supportsBinary = null;
|
24968 | }
|
24969 |
|
24970 | var isBinary = hasBinary(packets);
|
24971 |
|
24972 | if (supportsBinary && isBinary) {
|
24973 | if (Blob && !dontSendBlobs) {
|
24974 | return exports.encodePayloadAsBlob(packets, callback);
|
24975 | }
|
24976 |
|
24977 | return exports.encodePayloadAsArrayBuffer(packets, callback);
|
24978 | }
|
24979 |
|
24980 | if (!packets.length) {
|
24981 | return callback('0:');
|
24982 | }
|
24983 |
|
24984 | function setLengthHeader(message) {
|
24985 | return message.length + ':' + message;
|
24986 | }
|
24987 |
|
24988 | function encodeOne(packet, doneCallback) {
|
24989 | exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) {
|
24990 | doneCallback(null, setLengthHeader(message));
|
24991 | });
|
24992 | }
|
24993 |
|
24994 | map(packets, encodeOne, function(err, results) {
|
24995 | return callback(results.join(''));
|
24996 | });
|
24997 | };
|
24998 |
|
24999 |
|
25000 |
|
25001 |
|
25002 |
|
25003 | function map(ary, each, done) {
|
25004 | var result = new Array(ary.length);
|
25005 | var next = after(ary.length, done);
|
25006 |
|
25007 | var eachWithIndex = function(i, el, cb) {
|
25008 | each(el, function(error, msg) {
|
25009 | result[i] = msg;
|
25010 | cb(error, result);
|
25011 | });
|
25012 | };
|
25013 |
|
25014 | for (var i = 0; i < ary.length; i++) {
|
25015 | eachWithIndex(i, ary[i], next);
|
25016 | }
|
25017 | }
|
25018 |
|
25019 |
|
25020 |
|
25021 |
|
25022 |
|
25023 |
|
25024 |
|
25025 |
|
25026 |
|
25027 | exports.decodePayload = function (data, binaryType, callback) {
|
25028 | if (typeof data != 'string') {
|
25029 | return exports.decodePayloadAsBinary(data, binaryType, callback);
|
25030 | }
|
25031 |
|
25032 | if (typeof binaryType === 'function') {
|
25033 | callback = binaryType;
|
25034 | binaryType = null;
|
25035 | }
|
25036 |
|
25037 | var packet;
|
25038 | if (data == '') {
|
25039 |
|
25040 | return callback(err, 0, 1);
|
25041 | }
|
25042 |
|
25043 | var length = ''
|
25044 | , n, msg;
|
25045 |
|
25046 | for (var i = 0, l = data.length; i < l; i++) {
|
25047 | var chr = data.charAt(i);
|
25048 |
|
25049 | if (':' != chr) {
|
25050 | length += chr;
|
25051 | } else {
|
25052 | if ('' == length || (length != (n = Number(length)))) {
|
25053 |
|
25054 | return callback(err, 0, 1);
|
25055 | }
|
25056 |
|
25057 | msg = data.substr(i + 1, n);
|
25058 |
|
25059 | if (length != msg.length) {
|
25060 |
|
25061 | return callback(err, 0, 1);
|
25062 | }
|
25063 |
|
25064 | if (msg.length) {
|
25065 | packet = exports.decodePacket(msg, binaryType, true);
|
25066 |
|
25067 | if (err.type == packet.type && err.data == packet.data) {
|
25068 |
|
25069 | return callback(err, 0, 1);
|
25070 | }
|
25071 |
|
25072 | var ret = callback(packet, i + n, l);
|
25073 | if (false === ret) return;
|
25074 | }
|
25075 |
|
25076 |
|
25077 | i += n;
|
25078 | length = '';
|
25079 | }
|
25080 | }
|
25081 |
|
25082 | if (length != '') {
|
25083 |
|
25084 | return callback(err, 0, 1);
|
25085 | }
|
25086 |
|
25087 | };
|
25088 |
|
25089 |
|
25090 |
|
25091 |
|
25092 |
|
25093 |
|
25094 |
|
25095 |
|
25096 |
|
25097 |
|
25098 |
|
25099 |
|
25100 |
|
25101 |
|
25102 |
|
25103 | exports.encodePayloadAsArrayBuffer = function(packets, callback) {
|
25104 | if (!packets.length) {
|
25105 | return callback(new ArrayBuffer(0));
|
25106 | }
|
25107 |
|
25108 | function encodeOne(packet, doneCallback) {
|
25109 | exports.encodePacket(packet, true, true, function(data) {
|
25110 | return doneCallback(null, data);
|
25111 | });
|
25112 | }
|
25113 |
|
25114 | map(packets, encodeOne, function(err, encodedPackets) {
|
25115 | var totalLength = encodedPackets.reduce(function(acc, p) {
|
25116 | var len;
|
25117 | if (typeof p === 'string'){
|
25118 | len = p.length;
|
25119 | } else {
|
25120 | len = p.byteLength;
|
25121 | }
|
25122 | return acc + len.toString().length + len + 2;
|
25123 | }, 0);
|
25124 |
|
25125 | var resultArray = new Uint8Array(totalLength);
|
25126 |
|
25127 | var bufferIndex = 0;
|
25128 | encodedPackets.forEach(function(p) {
|
25129 | var isString = typeof p === 'string';
|
25130 | var ab = p;
|
25131 | if (isString) {
|
25132 | var view = new Uint8Array(p.length);
|
25133 | for (var i = 0; i < p.length; i++) {
|
25134 | view[i] = p.charCodeAt(i);
|
25135 | }
|
25136 | ab = view.buffer;
|
25137 | }
|
25138 |
|
25139 | if (isString) {
|
25140 | resultArray[bufferIndex++] = 0;
|
25141 | } else {
|
25142 | resultArray[bufferIndex++] = 1;
|
25143 | }
|
25144 |
|
25145 | var lenStr = ab.byteLength.toString();
|
25146 | for (var i = 0; i < lenStr.length; i++) {
|
25147 | resultArray[bufferIndex++] = parseInt(lenStr[i]);
|
25148 | }
|
25149 | resultArray[bufferIndex++] = 255;
|
25150 |
|
25151 | var view = new Uint8Array(ab);
|
25152 | for (var i = 0; i < view.length; i++) {
|
25153 | resultArray[bufferIndex++] = view[i];
|
25154 | }
|
25155 | });
|
25156 |
|
25157 | return callback(resultArray.buffer);
|
25158 | });
|
25159 | };
|
25160 |
|
25161 |
|
25162 |
|
25163 |
|
25164 |
|
25165 | exports.encodePayloadAsBlob = function(packets, callback) {
|
25166 | function encodeOne(packet, doneCallback) {
|
25167 | exports.encodePacket(packet, true, true, function(encoded) {
|
25168 | var binaryIdentifier = new Uint8Array(1);
|
25169 | binaryIdentifier[0] = 1;
|
25170 | if (typeof encoded === 'string') {
|
25171 | var view = new Uint8Array(encoded.length);
|
25172 | for (var i = 0; i < encoded.length; i++) {
|
25173 | view[i] = encoded.charCodeAt(i);
|
25174 | }
|
25175 | encoded = view.buffer;
|
25176 | binaryIdentifier[0] = 0;
|
25177 | }
|
25178 |
|
25179 | var len = (encoded instanceof ArrayBuffer)
|
25180 | ? encoded.byteLength
|
25181 | : encoded.size;
|
25182 |
|
25183 | var lenStr = len.toString();
|
25184 | var lengthAry = new Uint8Array(lenStr.length + 1);
|
25185 | for (var i = 0; i < lenStr.length; i++) {
|
25186 | lengthAry[i] = parseInt(lenStr[i]);
|
25187 | }
|
25188 | lengthAry[lenStr.length] = 255;
|
25189 |
|
25190 | if (Blob) {
|
25191 | var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
|
25192 | doneCallback(null, blob);
|
25193 | }
|
25194 | });
|
25195 | }
|
25196 |
|
25197 | map(packets, encodeOne, function(err, results) {
|
25198 | return callback(new Blob(results));
|
25199 | });
|
25200 | };
|
25201 |
|
25202 |
|
25203 |
|
25204 |
|
25205 |
|
25206 |
|
25207 |
|
25208 |
|
25209 |
|
25210 |
|
25211 | exports.decodePayloadAsBinary = function (data, binaryType, callback) {
|
25212 | if (typeof binaryType === 'function') {
|
25213 | callback = binaryType;
|
25214 | binaryType = null;
|
25215 | }
|
25216 |
|
25217 | var bufferTail = data;
|
25218 | var buffers = [];
|
25219 |
|
25220 | var numberTooLong = false;
|
25221 | while (bufferTail.byteLength > 0) {
|
25222 | var tailArray = new Uint8Array(bufferTail);
|
25223 | var isString = tailArray[0] === 0;
|
25224 | var msgLength = '';
|
25225 |
|
25226 | for (var i = 1; ; i++) {
|
25227 | if (tailArray[i] == 255) break;
|
25228 |
|
25229 | if (msgLength.length > 310) {
|
25230 | numberTooLong = true;
|
25231 | break;
|
25232 | }
|
25233 |
|
25234 | msgLength += tailArray[i];
|
25235 | }
|
25236 |
|
25237 | if(numberTooLong) return callback(err, 0, 1);
|
25238 |
|
25239 | bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
|
25240 | msgLength = parseInt(msgLength);
|
25241 |
|
25242 | var msg = sliceBuffer(bufferTail, 0, msgLength);
|
25243 | if (isString) {
|
25244 | try {
|
25245 | msg = String.fromCharCode.apply(null, new Uint8Array(msg));
|
25246 | } catch (e) {
|
25247 |
|
25248 | var typed = new Uint8Array(msg);
|
25249 | msg = '';
|
25250 | for (var i = 0; i < typed.length; i++) {
|
25251 | msg += String.fromCharCode(typed[i]);
|
25252 | }
|
25253 | }
|
25254 | }
|
25255 |
|
25256 | buffers.push(msg);
|
25257 | bufferTail = sliceBuffer(bufferTail, msgLength);
|
25258 | }
|
25259 |
|
25260 | var total = buffers.length;
|
25261 | buffers.forEach(function(buffer, i) {
|
25262 | callback(exports.decodePacket(buffer, binaryType, true), i, total);
|
25263 | });
|
25264 | };
|
25265 |
|
25266 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
25267 | },{"./keys":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/keys.js","after":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js","arraybuffer.slice":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js","base64-arraybuffer":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js","blob":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/index.js","has-binary":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/has-binary/index.js","utf8":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/utf8.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/lib/keys.js":[function(require,module,exports){
|
25268 |
|
25269 |
|
25270 |
|
25271 |
|
25272 |
|
25273 |
|
25274 |
|
25275 |
|
25276 | module.exports = Object.keys || function keys (obj){
|
25277 | var arr = [];
|
25278 | var has = Object.prototype.hasOwnProperty;
|
25279 |
|
25280 | for (var i in obj) {
|
25281 | if (has.call(obj, i)) {
|
25282 | arr.push(i);
|
25283 | }
|
25284 | }
|
25285 | return arr;
|
25286 | };
|
25287 |
|
25288 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js":[function(require,module,exports){
|
25289 | module.exports = after
|
25290 |
|
25291 | function after(count, callback, err_cb) {
|
25292 | var bail = false
|
25293 | err_cb = err_cb || noop
|
25294 | proxy.count = count
|
25295 |
|
25296 | return (count === 0) ? callback() : proxy
|
25297 |
|
25298 | function proxy(err, result) {
|
25299 | if (proxy.count <= 0) {
|
25300 | throw new Error('after called too many times')
|
25301 | }
|
25302 | --proxy.count
|
25303 |
|
25304 |
|
25305 | if (err) {
|
25306 | bail = true
|
25307 | callback(err)
|
25308 |
|
25309 | callback = err_cb
|
25310 | } else if (proxy.count === 0 && !bail) {
|
25311 | callback(null, result)
|
25312 | }
|
25313 | }
|
25314 | }
|
25315 |
|
25316 | function noop() {}
|
25317 |
|
25318 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/arraybuffer.slice/index.js":[function(require,module,exports){
|
25319 |
|
25320 |
|
25321 |
|
25322 |
|
25323 |
|
25324 |
|
25325 |
|
25326 | module.exports = function(arraybuffer, start, end) {
|
25327 | var bytes = arraybuffer.byteLength;
|
25328 | start = start || 0;
|
25329 | end = end || bytes;
|
25330 |
|
25331 | if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
|
25332 |
|
25333 | if (start < 0) { start += bytes; }
|
25334 | if (end < 0) { end += bytes; }
|
25335 | if (end > bytes) { end = bytes; }
|
25336 |
|
25337 | if (start >= bytes || start >= end || bytes === 0) {
|
25338 | return new ArrayBuffer(0);
|
25339 | }
|
25340 |
|
25341 | var abv = new Uint8Array(arraybuffer);
|
25342 | var result = new Uint8Array(end - start);
|
25343 | for (var i = start, ii = 0; i < end; i++, ii++) {
|
25344 | result[ii] = abv[i];
|
25345 | }
|
25346 | return result.buffer;
|
25347 | };
|
25348 |
|
25349 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/base64-arraybuffer/lib/base64-arraybuffer.js":[function(require,module,exports){
|
25350 |
|
25351 |
|
25352 |
|
25353 |
|
25354 |
|
25355 |
|
25356 |
|
25357 | (function(chars){
|
25358 | "use strict";
|
25359 |
|
25360 | exports.encode = function(arraybuffer) {
|
25361 | var bytes = new Uint8Array(arraybuffer),
|
25362 | i, len = bytes.length, base64 = "";
|
25363 |
|
25364 | for (i = 0; i < len; i+=3) {
|
25365 | base64 += chars[bytes[i] >> 2];
|
25366 | base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
|
25367 | base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
|
25368 | base64 += chars[bytes[i + 2] & 63];
|
25369 | }
|
25370 |
|
25371 | if ((len % 3) === 2) {
|
25372 | base64 = base64.substring(0, base64.length - 1) + "=";
|
25373 | } else if (len % 3 === 1) {
|
25374 | base64 = base64.substring(0, base64.length - 2) + "==";
|
25375 | }
|
25376 |
|
25377 | return base64;
|
25378 | };
|
25379 |
|
25380 | exports.decode = function(base64) {
|
25381 | var bufferLength = base64.length * 0.75,
|
25382 | len = base64.length, i, p = 0,
|
25383 | encoded1, encoded2, encoded3, encoded4;
|
25384 |
|
25385 | if (base64[base64.length - 1] === "=") {
|
25386 | bufferLength--;
|
25387 | if (base64[base64.length - 2] === "=") {
|
25388 | bufferLength--;
|
25389 | }
|
25390 | }
|
25391 |
|
25392 | var arraybuffer = new ArrayBuffer(bufferLength),
|
25393 | bytes = new Uint8Array(arraybuffer);
|
25394 |
|
25395 | for (i = 0; i < len; i+=4) {
|
25396 | encoded1 = chars.indexOf(base64[i]);
|
25397 | encoded2 = chars.indexOf(base64[i+1]);
|
25398 | encoded3 = chars.indexOf(base64[i+2]);
|
25399 | encoded4 = chars.indexOf(base64[i+3]);
|
25400 |
|
25401 | bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
|
25402 | bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
|
25403 | bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
|
25404 | }
|
25405 |
|
25406 | return arraybuffer;
|
25407 | };
|
25408 | })("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
25409 |
|
25410 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/blob/index.js":[function(require,module,exports){
|
25411 | (function (global){
|
25412 |
|
25413 |
|
25414 |
|
25415 |
|
25416 | var BlobBuilder = global.BlobBuilder
|
25417 | || global.WebKitBlobBuilder
|
25418 | || global.MSBlobBuilder
|
25419 | || global.MozBlobBuilder;
|
25420 |
|
25421 |
|
25422 |
|
25423 |
|
25424 |
|
25425 | var blobSupported = (function() {
|
25426 | try {
|
25427 | var a = new Blob(['hi']);
|
25428 | return a.size === 2;
|
25429 | } catch(e) {
|
25430 | return false;
|
25431 | }
|
25432 | })();
|
25433 |
|
25434 |
|
25435 |
|
25436 |
|
25437 |
|
25438 |
|
25439 | var blobSupportsArrayBufferView = blobSupported && (function() {
|
25440 | try {
|
25441 | var b = new Blob([new Uint8Array([1,2])]);
|
25442 | return b.size === 2;
|
25443 | } catch(e) {
|
25444 | return false;
|
25445 | }
|
25446 | })();
|
25447 |
|
25448 |
|
25449 |
|
25450 |
|
25451 |
|
25452 | var blobBuilderSupported = BlobBuilder
|
25453 | && BlobBuilder.prototype.append
|
25454 | && BlobBuilder.prototype.getBlob;
|
25455 |
|
25456 |
|
25457 |
|
25458 |
|
25459 |
|
25460 |
|
25461 |
|
25462 | function mapArrayBufferViews(ary) {
|
25463 | for (var i = 0; i < ary.length; i++) {
|
25464 | var chunk = ary[i];
|
25465 | if (chunk.buffer instanceof ArrayBuffer) {
|
25466 | var buf = chunk.buffer;
|
25467 |
|
25468 |
|
25469 |
|
25470 | if (chunk.byteLength !== buf.byteLength) {
|
25471 | var copy = new Uint8Array(chunk.byteLength);
|
25472 | copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
|
25473 | buf = copy.buffer;
|
25474 | }
|
25475 |
|
25476 | ary[i] = buf;
|
25477 | }
|
25478 | }
|
25479 | }
|
25480 |
|
25481 | function BlobBuilderConstructor(ary, options) {
|
25482 | options = options || {};
|
25483 |
|
25484 | var bb = new BlobBuilder();
|
25485 | mapArrayBufferViews(ary);
|
25486 |
|
25487 | for (var i = 0; i < ary.length; i++) {
|
25488 | bb.append(ary[i]);
|
25489 | }
|
25490 |
|
25491 | return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
|
25492 | };
|
25493 |
|
25494 | function BlobConstructor(ary, options) {
|
25495 | mapArrayBufferViews(ary);
|
25496 | return new Blob(ary, options || {});
|
25497 | };
|
25498 |
|
25499 | module.exports = (function() {
|
25500 | if (blobSupported) {
|
25501 | return blobSupportsArrayBufferView ? global.Blob : BlobConstructor;
|
25502 | } else if (blobBuilderSupported) {
|
25503 | return BlobBuilderConstructor;
|
25504 | } else {
|
25505 | return undefined;
|
25506 | }
|
25507 | })();
|
25508 |
|
25509 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
25510 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/has-binary/index.js":[function(require,module,exports){
|
25511 | (function (global){
|
25512 |
|
25513 |
|
25514 |
|
25515 |
|
25516 |
|
25517 | var isArray = require('isarray');
|
25518 |
|
25519 |
|
25520 |
|
25521 |
|
25522 |
|
25523 | module.exports = hasBinary;
|
25524 |
|
25525 |
|
25526 |
|
25527 |
|
25528 |
|
25529 |
|
25530 |
|
25531 |
|
25532 |
|
25533 |
|
25534 | function hasBinary(data) {
|
25535 |
|
25536 | function _hasBinary(obj) {
|
25537 | if (!obj) return false;
|
25538 |
|
25539 | if ( (global.Buffer && global.Buffer.isBuffer(obj)) ||
|
25540 | (global.ArrayBuffer && obj instanceof ArrayBuffer) ||
|
25541 | (global.Blob && obj instanceof Blob) ||
|
25542 | (global.File && obj instanceof File)
|
25543 | ) {
|
25544 | return true;
|
25545 | }
|
25546 |
|
25547 | if (isArray(obj)) {
|
25548 | for (var i = 0; i < obj.length; i++) {
|
25549 | if (_hasBinary(obj[i])) {
|
25550 | return true;
|
25551 | }
|
25552 | }
|
25553 | } else if (obj && 'object' == typeof obj) {
|
25554 | if (obj.toJSON) {
|
25555 | obj = obj.toJSON();
|
25556 | }
|
25557 |
|
25558 | for (var key in obj) {
|
25559 | if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) {
|
25560 | return true;
|
25561 | }
|
25562 | }
|
25563 | }
|
25564 |
|
25565 | return false;
|
25566 | }
|
25567 |
|
25568 | return _hasBinary(data);
|
25569 | }
|
25570 |
|
25571 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
25572 | },{"isarray":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js":[function(require,module,exports){
|
25573 | module.exports = Array.isArray || function (arr) {
|
25574 | return Object.prototype.toString.call(arr) == '[object Array]';
|
25575 | };
|
25576 |
|
25577 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/utf8/utf8.js":[function(require,module,exports){
|
25578 | (function (global){
|
25579 |
|
25580 | ;(function(root) {
|
25581 |
|
25582 |
|
25583 | var freeExports = typeof exports == 'object' && exports;
|
25584 |
|
25585 |
|
25586 | var freeModule = typeof module == 'object' && module &&
|
25587 | module.exports == freeExports && module;
|
25588 |
|
25589 |
|
25590 |
|
25591 | var freeGlobal = typeof global == 'object' && global;
|
25592 | if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
25593 | root = freeGlobal;
|
25594 | }
|
25595 |
|
25596 |
|
25597 |
|
25598 | var stringFromCharCode = String.fromCharCode;
|
25599 |
|
25600 |
|
25601 | function ucs2decode(string) {
|
25602 | var output = [];
|
25603 | var counter = 0;
|
25604 | var length = string.length;
|
25605 | var value;
|
25606 | var extra;
|
25607 | while (counter < length) {
|
25608 | value = string.charCodeAt(counter++);
|
25609 | if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
25610 |
|
25611 | extra = string.charCodeAt(counter++);
|
25612 | if ((extra & 0xFC00) == 0xDC00) {
|
25613 | output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
25614 | } else {
|
25615 |
|
25616 |
|
25617 | output.push(value);
|
25618 | counter--;
|
25619 | }
|
25620 | } else {
|
25621 | output.push(value);
|
25622 | }
|
25623 | }
|
25624 | return output;
|
25625 | }
|
25626 |
|
25627 |
|
25628 | function ucs2encode(array) {
|
25629 | var length = array.length;
|
25630 | var index = -1;
|
25631 | var value;
|
25632 | var output = '';
|
25633 | while (++index < length) {
|
25634 | value = array[index];
|
25635 | if (value > 0xFFFF) {
|
25636 | value -= 0x10000;
|
25637 | output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
25638 | value = 0xDC00 | value & 0x3FF;
|
25639 | }
|
25640 | output += stringFromCharCode(value);
|
25641 | }
|
25642 | return output;
|
25643 | }
|
25644 |
|
25645 | function checkScalarValue(codePoint) {
|
25646 | if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
|
25647 | throw Error(
|
25648 | 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
|
25649 | ' is not a scalar value'
|
25650 | );
|
25651 | }
|
25652 | }
|
25653 |
|
25654 |
|
25655 | function createByte(codePoint, shift) {
|
25656 | return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
|
25657 | }
|
25658 |
|
25659 | function encodeCodePoint(codePoint) {
|
25660 | if ((codePoint & 0xFFFFFF80) == 0) {
|
25661 | return stringFromCharCode(codePoint);
|
25662 | }
|
25663 | var symbol = '';
|
25664 | if ((codePoint & 0xFFFFF800) == 0) {
|
25665 | symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
|
25666 | }
|
25667 | else if ((codePoint & 0xFFFF0000) == 0) {
|
25668 | checkScalarValue(codePoint);
|
25669 | symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
|
25670 | symbol += createByte(codePoint, 6);
|
25671 | }
|
25672 | else if ((codePoint & 0xFFE00000) == 0) {
|
25673 | symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
|
25674 | symbol += createByte(codePoint, 12);
|
25675 | symbol += createByte(codePoint, 6);
|
25676 | }
|
25677 | symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
|
25678 | return symbol;
|
25679 | }
|
25680 |
|
25681 | function utf8encode(string) {
|
25682 | var codePoints = ucs2decode(string);
|
25683 | var length = codePoints.length;
|
25684 | var index = -1;
|
25685 | var codePoint;
|
25686 | var byteString = '';
|
25687 | while (++index < length) {
|
25688 | codePoint = codePoints[index];
|
25689 | byteString += encodeCodePoint(codePoint);
|
25690 | }
|
25691 | return byteString;
|
25692 | }
|
25693 |
|
25694 |
|
25695 |
|
25696 | function readContinuationByte() {
|
25697 | if (byteIndex >= byteCount) {
|
25698 | throw Error('Invalid byte index');
|
25699 | }
|
25700 |
|
25701 | var continuationByte = byteArray[byteIndex] & 0xFF;
|
25702 | byteIndex++;
|
25703 |
|
25704 | if ((continuationByte & 0xC0) == 0x80) {
|
25705 | return continuationByte & 0x3F;
|
25706 | }
|
25707 |
|
25708 |
|
25709 | throw Error('Invalid continuation byte');
|
25710 | }
|
25711 |
|
25712 | function decodeSymbol() {
|
25713 | var byte1;
|
25714 | var byte2;
|
25715 | var byte3;
|
25716 | var byte4;
|
25717 | var codePoint;
|
25718 |
|
25719 | if (byteIndex > byteCount) {
|
25720 | throw Error('Invalid byte index');
|
25721 | }
|
25722 |
|
25723 | if (byteIndex == byteCount) {
|
25724 | return false;
|
25725 | }
|
25726 |
|
25727 |
|
25728 | byte1 = byteArray[byteIndex] & 0xFF;
|
25729 | byteIndex++;
|
25730 |
|
25731 |
|
25732 | if ((byte1 & 0x80) == 0) {
|
25733 | return byte1;
|
25734 | }
|
25735 |
|
25736 |
|
25737 | if ((byte1 & 0xE0) == 0xC0) {
|
25738 | var byte2 = readContinuationByte();
|
25739 | codePoint = ((byte1 & 0x1F) << 6) | byte2;
|
25740 | if (codePoint >= 0x80) {
|
25741 | return codePoint;
|
25742 | } else {
|
25743 | throw Error('Invalid continuation byte');
|
25744 | }
|
25745 | }
|
25746 |
|
25747 |
|
25748 | if ((byte1 & 0xF0) == 0xE0) {
|
25749 | byte2 = readContinuationByte();
|
25750 | byte3 = readContinuationByte();
|
25751 | codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
|
25752 | if (codePoint >= 0x0800) {
|
25753 | checkScalarValue(codePoint);
|
25754 | return codePoint;
|
25755 | } else {
|
25756 | throw Error('Invalid continuation byte');
|
25757 | }
|
25758 | }
|
25759 |
|
25760 |
|
25761 | if ((byte1 & 0xF8) == 0xF0) {
|
25762 | byte2 = readContinuationByte();
|
25763 | byte3 = readContinuationByte();
|
25764 | byte4 = readContinuationByte();
|
25765 | codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) |
|
25766 | (byte3 << 0x06) | byte4;
|
25767 | if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
|
25768 | return codePoint;
|
25769 | }
|
25770 | }
|
25771 |
|
25772 | throw Error('Invalid UTF-8 detected');
|
25773 | }
|
25774 |
|
25775 | var byteArray;
|
25776 | var byteCount;
|
25777 | var byteIndex;
|
25778 | function utf8decode(byteString) {
|
25779 | byteArray = ucs2decode(byteString);
|
25780 | byteCount = byteArray.length;
|
25781 | byteIndex = 0;
|
25782 | var codePoints = [];
|
25783 | var tmp;
|
25784 | while ((tmp = decodeSymbol()) !== false) {
|
25785 | codePoints.push(tmp);
|
25786 | }
|
25787 | return ucs2encode(codePoints);
|
25788 | }
|
25789 |
|
25790 |
|
25791 |
|
25792 | var utf8 = {
|
25793 | 'version': '2.0.0',
|
25794 | 'encode': utf8encode,
|
25795 | 'decode': utf8decode
|
25796 | };
|
25797 |
|
25798 |
|
25799 |
|
25800 | if (
|
25801 | typeof define == 'function' &&
|
25802 | typeof define.amd == 'object' &&
|
25803 | define.amd
|
25804 | ) {
|
25805 | define(function() {
|
25806 | return utf8;
|
25807 | });
|
25808 | } else if (freeExports && !freeExports.nodeType) {
|
25809 | if (freeModule) {
|
25810 | freeModule.exports = utf8;
|
25811 | } else {
|
25812 | var object = {};
|
25813 | var hasOwnProperty = object.hasOwnProperty;
|
25814 | for (var key in utf8) {
|
25815 | hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
|
25816 | }
|
25817 | }
|
25818 | } else {
|
25819 | root.utf8 = utf8;
|
25820 | }
|
25821 |
|
25822 | }(this));
|
25823 |
|
25824 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
25825 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/has-cors/index.js":[function(require,module,exports){
|
25826 |
|
25827 |
|
25828 |
|
25829 |
|
25830 |
|
25831 |
|
25832 |
|
25833 |
|
25834 |
|
25835 | try {
|
25836 | module.exports = typeof XMLHttpRequest !== 'undefined' &&
|
25837 | 'withCredentials' in new XMLHttpRequest();
|
25838 | } catch (err) {
|
25839 |
|
25840 |
|
25841 | module.exports = false;
|
25842 | }
|
25843 |
|
25844 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/parsejson/index.js":[function(require,module,exports){
|
25845 | (function (global){
|
25846 |
|
25847 |
|
25848 |
|
25849 |
|
25850 |
|
25851 |
|
25852 |
|
25853 | var rvalidchars = /^[\],:{}\s]*$/;
|
25854 | var rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;
|
25855 | var rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
|
25856 | var rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g;
|
25857 | var rtrimLeft = /^\s+/;
|
25858 | var rtrimRight = /\s+$/;
|
25859 |
|
25860 | module.exports = function parsejson(data) {
|
25861 | if ('string' != typeof data || !data) {
|
25862 | return null;
|
25863 | }
|
25864 |
|
25865 | data = data.replace(rtrimLeft, '').replace(rtrimRight, '');
|
25866 |
|
25867 |
|
25868 | if (global.JSON && JSON.parse) {
|
25869 | return JSON.parse(data);
|
25870 | }
|
25871 |
|
25872 | if (rvalidchars.test(data.replace(rvalidescape, '@')
|
25873 | .replace(rvalidtokens, ']')
|
25874 | .replace(rvalidbraces, ''))) {
|
25875 | return (new Function('return ' + data))();
|
25876 | }
|
25877 | };
|
25878 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
25879 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/parseqs/index.js":[function(require,module,exports){
|
25880 |
|
25881 |
|
25882 |
|
25883 |
|
25884 |
|
25885 |
|
25886 |
|
25887 |
|
25888 | exports.encode = function (obj) {
|
25889 | var str = '';
|
25890 |
|
25891 | for (var i in obj) {
|
25892 | if (obj.hasOwnProperty(i)) {
|
25893 | if (str.length) str += '&';
|
25894 | str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
|
25895 | }
|
25896 | }
|
25897 |
|
25898 | return str;
|
25899 | };
|
25900 |
|
25901 |
|
25902 |
|
25903 |
|
25904 |
|
25905 |
|
25906 |
|
25907 |
|
25908 | exports.decode = function(qs){
|
25909 | var qry = {};
|
25910 | var pairs = qs.split('&');
|
25911 | for (var i = 0, l = pairs.length; i < l; i++) {
|
25912 | var pair = pairs[i].split('=');
|
25913 | qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
25914 | }
|
25915 | return qry;
|
25916 | };
|
25917 |
|
25918 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/lib/browser.js":[function(require,module,exports){
|
25919 |
|
25920 |
|
25921 |
|
25922 |
|
25923 |
|
25924 | var global = (function() { return this; })();
|
25925 |
|
25926 |
|
25927 |
|
25928 |
|
25929 |
|
25930 | var WebSocket = global.WebSocket || global.MozWebSocket;
|
25931 |
|
25932 |
|
25933 |
|
25934 |
|
25935 |
|
25936 | module.exports = WebSocket ? ws : null;
|
25937 |
|
25938 |
|
25939 |
|
25940 |
|
25941 |
|
25942 |
|
25943 |
|
25944 |
|
25945 |
|
25946 |
|
25947 |
|
25948 |
|
25949 |
|
25950 |
|
25951 | function ws(uri, protocols, opts) {
|
25952 | var instance;
|
25953 | if (protocols) {
|
25954 | instance = new WebSocket(uri, protocols);
|
25955 | } else {
|
25956 | instance = new WebSocket(uri);
|
25957 | }
|
25958 | return instance;
|
25959 | }
|
25960 |
|
25961 | if (WebSocket) ws.prototype = WebSocket.prototype;
|
25962 |
|
25963 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/yeast/index.js":[function(require,module,exports){
|
25964 | 'use strict';
|
25965 |
|
25966 | var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
|
25967 | , length = 64
|
25968 | , map = {}
|
25969 | , seed = 0
|
25970 | , i = 0
|
25971 | , prev;
|
25972 |
|
25973 |
|
25974 |
|
25975 |
|
25976 |
|
25977 |
|
25978 |
|
25979 |
|
25980 | function encode(num) {
|
25981 | var encoded = '';
|
25982 |
|
25983 | do {
|
25984 | encoded = alphabet[num % length] + encoded;
|
25985 | num = Math.floor(num / length);
|
25986 | } while (num > 0);
|
25987 |
|
25988 | return encoded;
|
25989 | }
|
25990 |
|
25991 |
|
25992 |
|
25993 |
|
25994 |
|
25995 |
|
25996 |
|
25997 |
|
25998 | function decode(str) {
|
25999 | var decoded = 0;
|
26000 |
|
26001 | for (i = 0; i < str.length; i++) {
|
26002 | decoded = decoded * length + map[str.charAt(i)];
|
26003 | }
|
26004 |
|
26005 | return decoded;
|
26006 | }
|
26007 |
|
26008 |
|
26009 |
|
26010 |
|
26011 |
|
26012 |
|
26013 |
|
26014 | function yeast() {
|
26015 | var now = encode(+new Date());
|
26016 |
|
26017 | if (now !== prev) return seed = 0, prev = now;
|
26018 | return now +'.'+ encode(seed++);
|
26019 | }
|
26020 |
|
26021 |
|
26022 |
|
26023 |
|
26024 | for (; i < length; i++) map[alphabet[i]] = i;
|
26025 |
|
26026 |
|
26027 |
|
26028 |
|
26029 | yeast.encode = encode;
|
26030 | yeast.decode = decode;
|
26031 | module.exports = yeast;
|
26032 |
|
26033 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/has-binary/index.js":[function(require,module,exports){
|
26034 | (function (global){
|
26035 |
|
26036 |
|
26037 |
|
26038 |
|
26039 |
|
26040 | var isArray = require('isarray');
|
26041 |
|
26042 |
|
26043 |
|
26044 |
|
26045 |
|
26046 | module.exports = hasBinary;
|
26047 |
|
26048 |
|
26049 |
|
26050 |
|
26051 |
|
26052 |
|
26053 |
|
26054 |
|
26055 |
|
26056 |
|
26057 | function hasBinary(data) {
|
26058 |
|
26059 | function _hasBinary(obj) {
|
26060 | if (!obj) return false;
|
26061 |
|
26062 | if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) ||
|
26063 | (global.ArrayBuffer && obj instanceof ArrayBuffer) ||
|
26064 | (global.Blob && obj instanceof Blob) ||
|
26065 | (global.File && obj instanceof File)
|
26066 | ) {
|
26067 | return true;
|
26068 | }
|
26069 |
|
26070 | if (isArray(obj)) {
|
26071 | for (var i = 0; i < obj.length; i++) {
|
26072 | if (_hasBinary(obj[i])) {
|
26073 | return true;
|
26074 | }
|
26075 | }
|
26076 | } else if (obj && 'object' == typeof obj) {
|
26077 |
|
26078 | if (obj.toJSON && 'function' == typeof obj.toJSON) {
|
26079 | obj = obj.toJSON();
|
26080 | }
|
26081 |
|
26082 | for (var key in obj) {
|
26083 | if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) {
|
26084 | return true;
|
26085 | }
|
26086 | }
|
26087 | }
|
26088 |
|
26089 | return false;
|
26090 | }
|
26091 |
|
26092 | return _hasBinary(data);
|
26093 | }
|
26094 |
|
26095 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
26096 | },{"isarray":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/has-binary/node_modules/isarray/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/has-binary/node_modules/isarray/index.js":[function(require,module,exports){
|
26097 | arguments[4]["/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js"][0].apply(exports,arguments)
|
26098 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/indexof/index.js":[function(require,module,exports){
|
26099 |
|
26100 | var indexOf = [].indexOf;
|
26101 |
|
26102 | module.exports = function(arr, obj){
|
26103 | if (indexOf) return arr.indexOf(obj);
|
26104 | for (var i = 0; i < arr.length; ++i) {
|
26105 | if (arr[i] === obj) return i;
|
26106 | }
|
26107 | return -1;
|
26108 | };
|
26109 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/parseuri/index.js":[function(require,module,exports){
|
26110 |
|
26111 |
|
26112 |
|
26113 |
|
26114 |
|
26115 |
|
26116 |
|
26117 | var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
|
26118 |
|
26119 | var parts = [
|
26120 | 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
|
26121 | ];
|
26122 |
|
26123 | module.exports = function parseuri(str) {
|
26124 | var src = str,
|
26125 | b = str.indexOf('['),
|
26126 | e = str.indexOf(']');
|
26127 |
|
26128 | if (b != -1 && e != -1) {
|
26129 | str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
|
26130 | }
|
26131 |
|
26132 | var m = re.exec(str || ''),
|
26133 | uri = {},
|
26134 | i = 14;
|
26135 |
|
26136 | while (i--) {
|
26137 | uri[parts[i]] = m[i] || '';
|
26138 | }
|
26139 |
|
26140 | if (b != -1 && e != -1) {
|
26141 | uri.source = src;
|
26142 | uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
|
26143 | uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
|
26144 | uri.ipv6uri = true;
|
26145 | }
|
26146 |
|
26147 | return uri;
|
26148 | };
|
26149 |
|
26150 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/binary.js":[function(require,module,exports){
|
26151 | (function (global){
|
26152 |
|
26153 |
|
26154 |
|
26155 |
|
26156 |
|
26157 |
|
26158 | var isArray = require('isarray');
|
26159 | var isBuf = require('./is-buffer');
|
26160 |
|
26161 |
|
26162 |
|
26163 |
|
26164 |
|
26165 |
|
26166 |
|
26167 |
|
26168 |
|
26169 |
|
26170 |
|
26171 | exports.deconstructPacket = function(packet){
|
26172 | var buffers = [];
|
26173 | var packetData = packet.data;
|
26174 |
|
26175 | function _deconstructPacket(data) {
|
26176 | if (!data) return data;
|
26177 |
|
26178 | if (isBuf(data)) {
|
26179 | var placeholder = { _placeholder: true, num: buffers.length };
|
26180 | buffers.push(data);
|
26181 | return placeholder;
|
26182 | } else if (isArray(data)) {
|
26183 | var newData = new Array(data.length);
|
26184 | for (var i = 0; i < data.length; i++) {
|
26185 | newData[i] = _deconstructPacket(data[i]);
|
26186 | }
|
26187 | return newData;
|
26188 | } else if ('object' == typeof data && !(data instanceof Date)) {
|
26189 | var newData = {};
|
26190 | for (var key in data) {
|
26191 | newData[key] = _deconstructPacket(data[key]);
|
26192 | }
|
26193 | return newData;
|
26194 | }
|
26195 | return data;
|
26196 | }
|
26197 |
|
26198 | var pack = packet;
|
26199 | pack.data = _deconstructPacket(packetData);
|
26200 | pack.attachments = buffers.length;
|
26201 | return {packet: pack, buffers: buffers};
|
26202 | };
|
26203 |
|
26204 |
|
26205 |
|
26206 |
|
26207 |
|
26208 |
|
26209 |
|
26210 |
|
26211 |
|
26212 |
|
26213 | exports.reconstructPacket = function(packet, buffers) {
|
26214 | var curPlaceHolder = 0;
|
26215 |
|
26216 | function _reconstructPacket(data) {
|
26217 | if (data && data._placeholder) {
|
26218 | var buf = buffers[data.num];
|
26219 | return buf;
|
26220 | } else if (isArray(data)) {
|
26221 | for (var i = 0; i < data.length; i++) {
|
26222 | data[i] = _reconstructPacket(data[i]);
|
26223 | }
|
26224 | return data;
|
26225 | } else if (data && 'object' == typeof data) {
|
26226 | for (var key in data) {
|
26227 | data[key] = _reconstructPacket(data[key]);
|
26228 | }
|
26229 | return data;
|
26230 | }
|
26231 | return data;
|
26232 | }
|
26233 |
|
26234 | packet.data = _reconstructPacket(packet.data);
|
26235 | packet.attachments = undefined;
|
26236 | return packet;
|
26237 | };
|
26238 |
|
26239 |
|
26240 |
|
26241 |
|
26242 |
|
26243 |
|
26244 |
|
26245 |
|
26246 |
|
26247 |
|
26248 |
|
26249 | exports.removeBlobs = function(data, callback) {
|
26250 | function _removeBlobs(obj, curKey, containingObject) {
|
26251 | if (!obj) return obj;
|
26252 |
|
26253 |
|
26254 | if ((global.Blob && obj instanceof Blob) ||
|
26255 | (global.File && obj instanceof File)) {
|
26256 | pendingBlobs++;
|
26257 |
|
26258 |
|
26259 | var fileReader = new FileReader();
|
26260 | fileReader.onload = function() {
|
26261 | if (containingObject) {
|
26262 | containingObject[curKey] = this.result;
|
26263 | }
|
26264 | else {
|
26265 | bloblessData = this.result;
|
26266 | }
|
26267 |
|
26268 |
|
26269 | if(! --pendingBlobs) {
|
26270 | callback(bloblessData);
|
26271 | }
|
26272 | };
|
26273 |
|
26274 | fileReader.readAsArrayBuffer(obj);
|
26275 | } else if (isArray(obj)) {
|
26276 | for (var i = 0; i < obj.length; i++) {
|
26277 | _removeBlobs(obj[i], i, obj);
|
26278 | }
|
26279 | } else if (obj && 'object' == typeof obj && !isBuf(obj)) {
|
26280 | for (var key in obj) {
|
26281 | _removeBlobs(obj[key], key, obj);
|
26282 | }
|
26283 | }
|
26284 | }
|
26285 |
|
26286 | var pendingBlobs = 0;
|
26287 | var bloblessData = data;
|
26288 | _removeBlobs(bloblessData);
|
26289 | if (!pendingBlobs) {
|
26290 | callback(bloblessData);
|
26291 | }
|
26292 | };
|
26293 |
|
26294 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
26295 | },{"./is-buffer":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/is-buffer.js","isarray":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/isarray/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/index.js":[function(require,module,exports){
|
26296 |
|
26297 |
|
26298 |
|
26299 |
|
26300 |
|
26301 | var debug = require('debug')('socket.io-parser');
|
26302 | var json = require('json3');
|
26303 | var isArray = require('isarray');
|
26304 | var Emitter = require('component-emitter');
|
26305 | var binary = require('./binary');
|
26306 | var isBuf = require('./is-buffer');
|
26307 |
|
26308 |
|
26309 |
|
26310 |
|
26311 |
|
26312 |
|
26313 |
|
26314 | exports.protocol = 4;
|
26315 |
|
26316 |
|
26317 |
|
26318 |
|
26319 |
|
26320 |
|
26321 |
|
26322 | exports.types = [
|
26323 | 'CONNECT',
|
26324 | 'DISCONNECT',
|
26325 | 'EVENT',
|
26326 | 'BINARY_EVENT',
|
26327 | 'ACK',
|
26328 | 'BINARY_ACK',
|
26329 | 'ERROR'
|
26330 | ];
|
26331 |
|
26332 |
|
26333 |
|
26334 |
|
26335 |
|
26336 |
|
26337 |
|
26338 | exports.CONNECT = 0;
|
26339 |
|
26340 |
|
26341 |
|
26342 |
|
26343 |
|
26344 |
|
26345 |
|
26346 | exports.DISCONNECT = 1;
|
26347 |
|
26348 |
|
26349 |
|
26350 |
|
26351 |
|
26352 |
|
26353 |
|
26354 | exports.EVENT = 2;
|
26355 |
|
26356 |
|
26357 |
|
26358 |
|
26359 |
|
26360 |
|
26361 |
|
26362 | exports.ACK = 3;
|
26363 |
|
26364 |
|
26365 |
|
26366 |
|
26367 |
|
26368 |
|
26369 |
|
26370 | exports.ERROR = 4;
|
26371 |
|
26372 |
|
26373 |
|
26374 |
|
26375 |
|
26376 |
|
26377 |
|
26378 | exports.BINARY_EVENT = 5;
|
26379 |
|
26380 |
|
26381 |
|
26382 |
|
26383 |
|
26384 |
|
26385 |
|
26386 | exports.BINARY_ACK = 6;
|
26387 |
|
26388 |
|
26389 |
|
26390 |
|
26391 |
|
26392 |
|
26393 |
|
26394 | exports.Encoder = Encoder;
|
26395 |
|
26396 |
|
26397 |
|
26398 |
|
26399 |
|
26400 |
|
26401 |
|
26402 | exports.Decoder = Decoder;
|
26403 |
|
26404 |
|
26405 |
|
26406 |
|
26407 |
|
26408 |
|
26409 |
|
26410 | function Encoder() {}
|
26411 |
|
26412 |
|
26413 |
|
26414 |
|
26415 |
|
26416 |
|
26417 |
|
26418 |
|
26419 |
|
26420 |
|
26421 |
|
26422 | Encoder.prototype.encode = function(obj, callback){
|
26423 | debug('encoding packet %j', obj);
|
26424 |
|
26425 | if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {
|
26426 | encodeAsBinary(obj, callback);
|
26427 | }
|
26428 | else {
|
26429 | var encoding = encodeAsString(obj);
|
26430 | callback([encoding]);
|
26431 | }
|
26432 | };
|
26433 |
|
26434 |
|
26435 |
|
26436 |
|
26437 |
|
26438 |
|
26439 |
|
26440 |
|
26441 |
|
26442 | function encodeAsString(obj) {
|
26443 | var str = '';
|
26444 | var nsp = false;
|
26445 |
|
26446 |
|
26447 | str += obj.type;
|
26448 |
|
26449 |
|
26450 | if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) {
|
26451 | str += obj.attachments;
|
26452 | str += '-';
|
26453 | }
|
26454 |
|
26455 |
|
26456 |
|
26457 | if (obj.nsp && '/' != obj.nsp) {
|
26458 | nsp = true;
|
26459 | str += obj.nsp;
|
26460 | }
|
26461 |
|
26462 |
|
26463 | if (null != obj.id) {
|
26464 | if (nsp) {
|
26465 | str += ',';
|
26466 | nsp = false;
|
26467 | }
|
26468 | str += obj.id;
|
26469 | }
|
26470 |
|
26471 |
|
26472 | if (null != obj.data) {
|
26473 | if (nsp) str += ',';
|
26474 | str += json.stringify(obj.data);
|
26475 | }
|
26476 |
|
26477 | debug('encoded %j as %s', obj, str);
|
26478 | return str;
|
26479 | }
|
26480 |
|
26481 |
|
26482 |
|
26483 |
|
26484 |
|
26485 |
|
26486 |
|
26487 |
|
26488 |
|
26489 |
|
26490 |
|
26491 | function encodeAsBinary(obj, callback) {
|
26492 |
|
26493 | function writeEncoding(bloblessData) {
|
26494 | var deconstruction = binary.deconstructPacket(bloblessData);
|
26495 | var pack = encodeAsString(deconstruction.packet);
|
26496 | var buffers = deconstruction.buffers;
|
26497 |
|
26498 | buffers.unshift(pack);
|
26499 | callback(buffers);
|
26500 | }
|
26501 |
|
26502 | binary.removeBlobs(obj, writeEncoding);
|
26503 | }
|
26504 |
|
26505 |
|
26506 |
|
26507 |
|
26508 |
|
26509 |
|
26510 |
|
26511 |
|
26512 | function Decoder() {
|
26513 | this.reconstructor = null;
|
26514 | }
|
26515 |
|
26516 |
|
26517 |
|
26518 |
|
26519 |
|
26520 | Emitter(Decoder.prototype);
|
26521 |
|
26522 |
|
26523 |
|
26524 |
|
26525 |
|
26526 |
|
26527 |
|
26528 |
|
26529 |
|
26530 | Decoder.prototype.add = function(obj) {
|
26531 | var packet;
|
26532 | if ('string' == typeof obj) {
|
26533 | packet = decodeString(obj);
|
26534 | if (exports.BINARY_EVENT == packet.type || exports.BINARY_ACK == packet.type) {
|
26535 | this.reconstructor = new BinaryReconstructor(packet);
|
26536 |
|
26537 |
|
26538 | if (this.reconstructor.reconPack.attachments === 0) {
|
26539 | this.emit('decoded', packet);
|
26540 | }
|
26541 | } else {
|
26542 | this.emit('decoded', packet);
|
26543 | }
|
26544 | }
|
26545 | else if (isBuf(obj) || obj.base64) {
|
26546 | if (!this.reconstructor) {
|
26547 | throw new Error('got binary data when not reconstructing a packet');
|
26548 | } else {
|
26549 | packet = this.reconstructor.takeBinaryData(obj);
|
26550 | if (packet) {
|
26551 | this.reconstructor = null;
|
26552 | this.emit('decoded', packet);
|
26553 | }
|
26554 | }
|
26555 | }
|
26556 | else {
|
26557 | throw new Error('Unknown type: ' + obj);
|
26558 | }
|
26559 | };
|
26560 |
|
26561 |
|
26562 |
|
26563 |
|
26564 |
|
26565 |
|
26566 |
|
26567 |
|
26568 |
|
26569 | function decodeString(str) {
|
26570 | var p = {};
|
26571 | var i = 0;
|
26572 |
|
26573 |
|
26574 | p.type = Number(str.charAt(0));
|
26575 | if (null == exports.types[p.type]) return error();
|
26576 |
|
26577 |
|
26578 | if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) {
|
26579 | var buf = '';
|
26580 | while (str.charAt(++i) != '-') {
|
26581 | buf += str.charAt(i);
|
26582 | if (i == str.length) break;
|
26583 | }
|
26584 | if (buf != Number(buf) || str.charAt(i) != '-') {
|
26585 | throw new Error('Illegal attachments');
|
26586 | }
|
26587 | p.attachments = Number(buf);
|
26588 | }
|
26589 |
|
26590 |
|
26591 | if ('/' == str.charAt(i + 1)) {
|
26592 | p.nsp = '';
|
26593 | while (++i) {
|
26594 | var c = str.charAt(i);
|
26595 | if (',' == c) break;
|
26596 | p.nsp += c;
|
26597 | if (i == str.length) break;
|
26598 | }
|
26599 | } else {
|
26600 | p.nsp = '/';
|
26601 | }
|
26602 |
|
26603 |
|
26604 | var next = str.charAt(i + 1);
|
26605 | if ('' !== next && Number(next) == next) {
|
26606 | p.id = '';
|
26607 | while (++i) {
|
26608 | var c = str.charAt(i);
|
26609 | if (null == c || Number(c) != c) {
|
26610 | --i;
|
26611 | break;
|
26612 | }
|
26613 | p.id += str.charAt(i);
|
26614 | if (i == str.length) break;
|
26615 | }
|
26616 | p.id = Number(p.id);
|
26617 | }
|
26618 |
|
26619 |
|
26620 | if (str.charAt(++i)) {
|
26621 | try {
|
26622 | p.data = json.parse(str.substr(i));
|
26623 | } catch(e){
|
26624 | return error();
|
26625 | }
|
26626 | }
|
26627 |
|
26628 | debug('decoded %s as %j', str, p);
|
26629 | return p;
|
26630 | }
|
26631 |
|
26632 |
|
26633 |
|
26634 |
|
26635 |
|
26636 |
|
26637 |
|
26638 | Decoder.prototype.destroy = function() {
|
26639 | if (this.reconstructor) {
|
26640 | this.reconstructor.finishedReconstruction();
|
26641 | }
|
26642 | };
|
26643 |
|
26644 |
|
26645 |
|
26646 |
|
26647 |
|
26648 |
|
26649 |
|
26650 |
|
26651 |
|
26652 |
|
26653 |
|
26654 | function BinaryReconstructor(packet) {
|
26655 | this.reconPack = packet;
|
26656 | this.buffers = [];
|
26657 | }
|
26658 |
|
26659 |
|
26660 |
|
26661 |
|
26662 |
|
26663 |
|
26664 |
|
26665 |
|
26666 |
|
26667 |
|
26668 |
|
26669 | BinaryReconstructor.prototype.takeBinaryData = function(binData) {
|
26670 | this.buffers.push(binData);
|
26671 | if (this.buffers.length == this.reconPack.attachments) {
|
26672 | var packet = binary.reconstructPacket(this.reconPack, this.buffers);
|
26673 | this.finishedReconstruction();
|
26674 | return packet;
|
26675 | }
|
26676 | return null;
|
26677 | };
|
26678 |
|
26679 |
|
26680 |
|
26681 |
|
26682 |
|
26683 |
|
26684 |
|
26685 | BinaryReconstructor.prototype.finishedReconstruction = function() {
|
26686 | this.reconPack = null;
|
26687 | this.buffers = [];
|
26688 | };
|
26689 |
|
26690 | function error(data){
|
26691 | return {
|
26692 | type: exports.ERROR,
|
26693 | data: 'parser error'
|
26694 | };
|
26695 | }
|
26696 |
|
26697 | },{"./binary":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/binary.js","./is-buffer":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/is-buffer.js","component-emitter":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/component-emitter/index.js","debug":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/debug/browser.js","isarray":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/isarray/index.js","json3":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/json3/lib/json3.js"}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/is-buffer.js":[function(require,module,exports){
|
26698 | (function (global){
|
26699 |
|
26700 | module.exports = isBuf;
|
26701 |
|
26702 |
|
26703 |
|
26704 |
|
26705 |
|
26706 |
|
26707 |
|
26708 | function isBuf(obj) {
|
26709 | return (global.Buffer && global.Buffer.isBuffer(obj)) ||
|
26710 | (global.ArrayBuffer && obj instanceof ArrayBuffer);
|
26711 | }
|
26712 |
|
26713 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
26714 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/component-emitter/index.js":[function(require,module,exports){
|
26715 | arguments[4]["/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/component-emitter/index.js"][0].apply(exports,arguments)
|
26716 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/isarray/index.js":[function(require,module,exports){
|
26717 | arguments[4]["/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/has-binary/node_modules/isarray/index.js"][0].apply(exports,arguments)
|
26718 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/json3/lib/json3.js":[function(require,module,exports){
|
26719 | (function (global){
|
26720 |
|
26721 | ;(function () {
|
26722 |
|
26723 |
|
26724 | var isLoader = typeof define === "function" && define.amd;
|
26725 |
|
26726 |
|
26727 | var objectTypes = {
|
26728 | "function": true,
|
26729 | "object": true
|
26730 | };
|
26731 |
|
26732 |
|
26733 | var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
26734 |
|
26735 |
|
26736 |
|
26737 |
|
26738 |
|
26739 | var root = objectTypes[typeof window] && window || this,
|
26740 | freeGlobal = freeExports && objectTypes[typeof module] && module && !module.nodeType && typeof global == "object" && global;
|
26741 |
|
26742 | if (freeGlobal && (freeGlobal["global"] === freeGlobal || freeGlobal["window"] === freeGlobal || freeGlobal["self"] === freeGlobal)) {
|
26743 | root = freeGlobal;
|
26744 | }
|
26745 |
|
26746 |
|
26747 |
|
26748 | function runInContext(context, exports) {
|
26749 | context || (context = root["Object"]());
|
26750 | exports || (exports = root["Object"]());
|
26751 |
|
26752 |
|
26753 | var Number = context["Number"] || root["Number"],
|
26754 | String = context["String"] || root["String"],
|
26755 | Object = context["Object"] || root["Object"],
|
26756 | Date = context["Date"] || root["Date"],
|
26757 | SyntaxError = context["SyntaxError"] || root["SyntaxError"],
|
26758 | TypeError = context["TypeError"] || root["TypeError"],
|
26759 | Math = context["Math"] || root["Math"],
|
26760 | nativeJSON = context["JSON"] || root["JSON"];
|
26761 |
|
26762 |
|
26763 | if (typeof nativeJSON == "object" && nativeJSON) {
|
26764 | exports.stringify = nativeJSON.stringify;
|
26765 | exports.parse = nativeJSON.parse;
|
26766 | }
|
26767 |
|
26768 |
|
26769 | var objectProto = Object.prototype,
|
26770 | getClass = objectProto.toString,
|
26771 | isProperty, forEach, undef;
|
26772 |
|
26773 |
|
26774 | var isExtended = new Date(-3509827334573292);
|
26775 | try {
|
26776 |
|
26777 |
|
26778 | isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 &&
|
26779 |
|
26780 |
|
26781 |
|
26782 | isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708;
|
26783 | } catch (exception) {}
|
26784 |
|
26785 |
|
26786 |
|
26787 | function has(name) {
|
26788 | if (has[name] !== undef) {
|
26789 |
|
26790 | return has[name];
|
26791 | }
|
26792 | var isSupported;
|
26793 | if (name == "bug-string-char-index") {
|
26794 |
|
26795 |
|
26796 | isSupported = "a"[0] != "a";
|
26797 | } else if (name == "json") {
|
26798 |
|
26799 |
|
26800 | isSupported = has("json-stringify") && has("json-parse");
|
26801 | } else {
|
26802 | var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
|
26803 |
|
26804 | if (name == "json-stringify") {
|
26805 | var stringify = exports.stringify, stringifySupported = typeof stringify == "function" && isExtended;
|
26806 | if (stringifySupported) {
|
26807 |
|
26808 | (value = function () {
|
26809 | return 1;
|
26810 | }).toJSON = value;
|
26811 | try {
|
26812 | stringifySupported =
|
26813 |
|
26814 |
|
26815 | stringify(0) === "0" &&
|
26816 |
|
26817 |
|
26818 | stringify(new Number()) === "0" &&
|
26819 | stringify(new String()) == '""' &&
|
26820 |
|
26821 |
|
26822 |
|
26823 |
|
26824 | stringify(getClass) === undef &&
|
26825 |
|
26826 |
|
26827 | stringify(undef) === undef &&
|
26828 |
|
26829 |
|
26830 | stringify() === undef &&
|
26831 |
|
26832 |
|
26833 |
|
26834 |
|
26835 |
|
26836 | stringify(value) === "1" &&
|
26837 | stringify([value]) == "[1]" &&
|
26838 |
|
26839 |
|
26840 | stringify([undef]) == "[null]" &&
|
26841 |
|
26842 | stringify(null) == "null" &&
|
26843 |
|
26844 |
|
26845 |
|
26846 |
|
26847 | stringify([undef, getClass, null]) == "[null,null,null]" &&
|
26848 |
|
26849 |
|
26850 | stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized &&
|
26851 |
|
26852 | stringify(null, value) === "1" &&
|
26853 | stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" &&
|
26854 |
|
26855 |
|
26856 | stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&
|
26857 |
|
26858 | stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&
|
26859 |
|
26860 |
|
26861 | stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&
|
26862 |
|
26863 |
|
26864 | stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';
|
26865 | } catch (exception) {
|
26866 | stringifySupported = false;
|
26867 | }
|
26868 | }
|
26869 | isSupported = stringifySupported;
|
26870 | }
|
26871 |
|
26872 | if (name == "json-parse") {
|
26873 | var parse = exports.parse;
|
26874 | if (typeof parse == "function") {
|
26875 | try {
|
26876 |
|
26877 |
|
26878 |
|
26879 | if (parse("0") === 0 && !parse(false)) {
|
26880 |
|
26881 | value = parse(serialized);
|
26882 | var parseSupported = value["a"].length == 5 && value["a"][0] === 1;
|
26883 | if (parseSupported) {
|
26884 | try {
|
26885 |
|
26886 | parseSupported = !parse('"\t"');
|
26887 | } catch (exception) {}
|
26888 | if (parseSupported) {
|
26889 | try {
|
26890 |
|
26891 |
|
26892 |
|
26893 | parseSupported = parse("01") !== 1;
|
26894 | } catch (exception) {}
|
26895 | }
|
26896 | if (parseSupported) {
|
26897 | try {
|
26898 |
|
26899 |
|
26900 |
|
26901 | parseSupported = parse("1.") !== 1;
|
26902 | } catch (exception) {}
|
26903 | }
|
26904 | }
|
26905 | }
|
26906 | } catch (exception) {
|
26907 | parseSupported = false;
|
26908 | }
|
26909 | }
|
26910 | isSupported = parseSupported;
|
26911 | }
|
26912 | }
|
26913 | return has[name] = !!isSupported;
|
26914 | }
|
26915 |
|
26916 | if (!has("json")) {
|
26917 |
|
26918 | var functionClass = "[object Function]",
|
26919 | dateClass = "[object Date]",
|
26920 | numberClass = "[object Number]",
|
26921 | stringClass = "[object String]",
|
26922 | arrayClass = "[object Array]",
|
26923 | booleanClass = "[object Boolean]";
|
26924 |
|
26925 |
|
26926 | var charIndexBuggy = has("bug-string-char-index");
|
26927 |
|
26928 |
|
26929 | if (!isExtended) {
|
26930 | var floor = Math.floor;
|
26931 |
|
26932 |
|
26933 | var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
26934 |
|
26935 |
|
26936 | var getDay = function (year, month) {
|
26937 | return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
|
26938 | };
|
26939 | }
|
26940 |
|
26941 |
|
26942 |
|
26943 | if (!(isProperty = objectProto.hasOwnProperty)) {
|
26944 | isProperty = function (property) {
|
26945 | var members = {}, constructor;
|
26946 | if ((members.__proto__ = null, members.__proto__ = {
|
26947 |
|
26948 |
|
26949 | "toString": 1
|
26950 | }, members).toString != getClass) {
|
26951 |
|
26952 |
|
26953 | isProperty = function (property) {
|
26954 |
|
26955 |
|
26956 |
|
26957 | var original = this.__proto__, result = property in (this.__proto__ = null, this);
|
26958 |
|
26959 | this.__proto__ = original;
|
26960 | return result;
|
26961 | };
|
26962 | } else {
|
26963 |
|
26964 | constructor = members.constructor;
|
26965 | // Use the `constructor` property to simulate `Object#hasOwnProperty` in
|
26966 | // other environments.
|
26967 | isProperty = function (property) {
|
26968 | var parent = (this.constructor || constructor).prototype;
|
26969 | return property in this && !(property in parent && this[property] === parent[property]);
|
26970 | };
|
26971 | }
|
26972 | members = null;
|
26973 | return isProperty.call(this, property);
|
26974 | };
|
26975 | }
|
26976 |
|
26977 | // Internal: Normalizes the `for...in` iteration algorithm across
|
26978 | // environments. Each enumerated key is yielded to a `callback` function.
|
26979 | forEach = function (object, callback) {
|
26980 | var size = 0, Properties, members, property;
|
26981 |
|
26982 |
|
26983 |
|
26984 |
|
26985 | (Properties = function () {
|
26986 | this.valueOf = 0;
|
26987 | }).prototype.valueOf = 0;
|
26988 |
|
26989 |
|
26990 | members = new Properties();
|
26991 | for (property in members) {
|
26992 |
|
26993 | if (isProperty.call(members, property)) {
|
26994 | size++;
|
26995 | }
|
26996 | }
|
26997 | Properties = members = null;
|
26998 |
|
26999 |
|
27000 | if (!size) {
|
27001 |
|
27002 | members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
|
27003 |
|
27004 |
|
27005 | forEach = function (object, callback) {
|
27006 | var isFunction = getClass.call(object) == functionClass, property, length;
|
27007 | var hasProperty = !isFunction && typeof object.constructor != "function" && objectTypes[typeof object.hasOwnProperty] && object.hasOwnProperty || isProperty;
|
27008 | for (property in object) {
|
27009 |
|
27010 |
|
27011 | if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) {
|
27012 | callback(property);
|
27013 | }
|
27014 | }
|
27015 |
|
27016 | for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property));
|
27017 | };
|
27018 | } else if (size == 2) {
|
27019 |
|
27020 | forEach = function (object, callback) {
|
27021 |
|
27022 | var members = {}, isFunction = getClass.call(object) == functionClass, property;
|
27023 | for (property in object) {
|
27024 |
|
27025 |
|
27026 |
|
27027 | if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
|
27028 | callback(property);
|
27029 | }
|
27030 | }
|
27031 | };
|
27032 | } else {
|
27033 |
|
27034 | forEach = function (object, callback) {
|
27035 | var isFunction = getClass.call(object) == functionClass, property, isConstructor;
|
27036 | for (property in object) {
|
27037 | if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
|
27038 | callback(property);
|
27039 | }
|
27040 | }
|
27041 |
|
27042 |
|
27043 | if (isConstructor || isProperty.call(object, (property = "constructor"))) {
|
27044 | callback(property);
|
27045 | }
|
27046 | };
|
27047 | }
|
27048 | return forEach(object, callback);
|
27049 | };
|
27050 |
|
27051 |
|
27052 |
|
27053 |
|
27054 |
|
27055 |
|
27056 |
|
27057 | if (!has("json-stringify")) {
|
27058 |
|
27059 | var Escapes = {
|
27060 | 92: "\\\\",
|
27061 | 34: '\\"',
|
27062 | 8: "\\b",
|
27063 | 12: "\\f",
|
27064 | 10: "\\n",
|
27065 | 13: "\\r",
|
27066 | 9: "\\t"
|
27067 | };
|
27068 |
|
27069 |
|
27070 |
|
27071 | var leadingZeroes = "000000";
|
27072 | var toPaddedString = function (width, value) {
|
27073 |
|
27074 |
|
27075 | return (leadingZeroes + (value || 0)).slice(-width);
|
27076 | };
|
27077 |
|
27078 |
|
27079 |
|
27080 |
|
27081 |
|
27082 | var unicodePrefix = "\\u00";
|
27083 | var quote = function (value) {
|
27084 | var result = '"', index = 0, length = value.length, useCharIndex = !charIndexBuggy || length > 10;
|
27085 | var symbols = useCharIndex && (charIndexBuggy ? value.split("") : value);
|
27086 | for (; index < length; index++) {
|
27087 | var charCode = value.charCodeAt(index);
|
27088 |
|
27089 |
|
27090 | switch (charCode) {
|
27091 | case 8: case 9: case 10: case 12: case 13: case 34: case 92:
|
27092 | result += Escapes[charCode];
|
27093 | break;
|
27094 | default:
|
27095 | if (charCode < 32) {
|
27096 | result += unicodePrefix + toPaddedString(2, charCode.toString(16));
|
27097 | break;
|
27098 | }
|
27099 | result += useCharIndex ? symbols[index] : value.charAt(index);
|
27100 | }
|
27101 | }
|
27102 | return result + '"';
|
27103 | };
|
27104 |
|
27105 |
|
27106 |
|
27107 | var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
|
27108 | var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, result;
|
27109 | try {
|
27110 |
|
27111 | value = object[property];
|
27112 | } catch (exception) {}
|
27113 | if (typeof value == "object" && value) {
|
27114 | className = getClass.call(value);
|
27115 | if (className == dateClass && !isProperty.call(value, "toJSON")) {
|
27116 | if (value > -1 / 0 && value < 1 / 0) {
|
27117 |
|
27118 |
|
27119 |
|
27120 | if (getDay) {
|
27121 |
|
27122 |
|
27123 |
|
27124 | date = floor(value / 864e5);
|
27125 | for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
|
27126 | for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
|
27127 | date = 1 + date - getDay(year, month);
|
27128 |
|
27129 |
|
27130 |
|
27131 |
|
27132 | time = (value % 864e5 + 864e5) % 864e5;
|
27133 |
|
27134 |
|
27135 | hours = floor(time / 36e5) % 24;
|
27136 | minutes = floor(time / 6e4) % 60;
|
27137 | seconds = floor(time / 1e3) % 60;
|
27138 | milliseconds = time % 1e3;
|
27139 | } else {
|
27140 | year = value.getUTCFullYear();
|
27141 | month = value.getUTCMonth();
|
27142 | date = value.getUTCDate();
|
27143 | hours = value.getUTCHours();
|
27144 | minutes = value.getUTCMinutes();
|
27145 | seconds = value.getUTCSeconds();
|
27146 | milliseconds = value.getUTCMilliseconds();
|
27147 | }
|
27148 |
|
27149 | value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
|
27150 | "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
|
27151 |
|
27152 |
|
27153 | "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
|
27154 |
|
27155 | "." + toPaddedString(3, milliseconds) + "Z";
|
27156 | } else {
|
27157 | value = null;
|
27158 | }
|
27159 | } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) {
|
27160 |
|
27161 |
|
27162 |
|
27163 |
|
27164 | value = value.toJSON(property);
|
27165 | }
|
27166 | }
|
27167 | if (callback) {
|
27168 |
|
27169 |
|
27170 | value = callback.call(object, property, value);
|
27171 | }
|
27172 | if (value === null) {
|
27173 | return "null";
|
27174 | }
|
27175 | className = getClass.call(value);
|
27176 | if (className == booleanClass) {
|
27177 |
|
27178 | return "" + value;
|
27179 | } else if (className == numberClass) {
|
27180 |
|
27181 |
|
27182 | return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
|
27183 | } else if (className == stringClass) {
|
27184 |
|
27185 | return quote("" + value);
|
27186 | }
|
27187 |
|
27188 | if (typeof value == "object") {
|
27189 |
|
27190 |
|
27191 | for (length = stack.length; length--;) {
|
27192 | if (stack[length] === value) {
|
27193 |
|
27194 | throw TypeError();
|
27195 | }
|
27196 | }
|
27197 |
|
27198 | stack.push(value);
|
27199 | results = [];
|
27200 |
|
27201 | prefix = indentation;
|
27202 | indentation += whitespace;
|
27203 | if (className == arrayClass) {
|
27204 |
|
27205 | for (index = 0, length = value.length; index < length; index++) {
|
27206 | element = serialize(index, value, callback, properties, whitespace, indentation, stack);
|
27207 | results.push(element === undef ? "null" : element);
|
27208 | }
|
27209 | result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
|
27210 | } else {
|
27211 |
|
27212 |
|
27213 |
|
27214 | forEach(properties || value, function (property) {
|
27215 | var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
|
27216 | if (element !== undef) {
|
27217 |
|
27218 |
|
27219 |
|
27220 |
|
27221 |
|
27222 |
|
27223 | results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
|
27224 | }
|
27225 | });
|
27226 | result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
|
27227 | }
|
27228 |
|
27229 | stack.pop();
|
27230 | return result;
|
27231 | }
|
27232 | };
|
27233 |
|
27234 |
|
27235 | exports.stringify = function (source, filter, width) {
|
27236 | var whitespace, callback, properties, className;
|
27237 | if (objectTypes[typeof filter] && filter) {
|
27238 | if ((className = getClass.call(filter)) == functionClass) {
|
27239 | callback = filter;
|
27240 | } else if (className == arrayClass) {
|
27241 |
|
27242 | properties = {};
|
27243 | for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((className = getClass.call(value)), className == stringClass || className == numberClass) && (properties[value] = 1));
|
27244 | }
|
27245 | }
|
27246 | if (width) {
|
27247 | if ((className = getClass.call(width)) == numberClass) {
|
27248 |
|
27249 |
|
27250 | if ((width -= width % 1) > 0) {
|
27251 | for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
|
27252 | }
|
27253 | } else if (className == stringClass) {
|
27254 | whitespace = width.length <= 10 ? width : width.slice(0, 10);
|
27255 | }
|
27256 | }
|
27257 |
|
27258 |
|
27259 |
|
27260 | return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
|
27261 | };
|
27262 | }
|
27263 |
|
27264 |
|
27265 | if (!has("json-parse")) {
|
27266 | var fromCharCode = String.fromCharCode;
|
27267 |
|
27268 |
|
27269 |
|
27270 | var Unescapes = {
|
27271 | 92: "\\",
|
27272 | 34: '"',
|
27273 | 47: "/",
|
27274 | 98: "\b",
|
27275 | 116: "\t",
|
27276 | 110: "\n",
|
27277 | 102: "\f",
|
27278 | 114: "\r"
|
27279 | };
|
27280 |
|
27281 |
|
27282 | var Index, Source;
|
27283 |
|
27284 |
|
27285 | var abort = function () {
|
27286 | Index = Source = null;
|
27287 | throw SyntaxError();
|
27288 | };
|
27289 |
|
27290 |
|
27291 |
|
27292 |
|
27293 | var lex = function () {
|
27294 | var source = Source, length = source.length, value, begin, position, isSigned, charCode;
|
27295 | while (Index < length) {
|
27296 | charCode = source.charCodeAt(Index);
|
27297 | switch (charCode) {
|
27298 | case 9: case 10: case 13: case 32:
|
27299 |
|
27300 |
|
27301 | Index++;
|
27302 | break;
|
27303 | case 123: case 125: case 91: case 93: case 58: case 44:
|
27304 |
|
27305 |
|
27306 | value = charIndexBuggy ? source.charAt(Index) : source[Index];
|
27307 | Index++;
|
27308 | return value;
|
27309 | case 34:
|
27310 |
|
27311 |
|
27312 |
|
27313 |
|
27314 | for (value = "@", Index++; Index < length;) {
|
27315 | charCode = source.charCodeAt(Index);
|
27316 | if (charCode < 32) {
|
27317 |
|
27318 |
|
27319 | abort();
|
27320 | } else if (charCode == 92) {
|
27321 |
|
27322 |
|
27323 |
|
27324 | charCode = source.charCodeAt(++Index);
|
27325 | switch (charCode) {
|
27326 | case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114:
|
27327 |
|
27328 | value += Unescapes[charCode];
|
27329 | Index++;
|
27330 | break;
|
27331 | case 117:
|
27332 |
|
27333 |
|
27334 |
|
27335 | begin = ++Index;
|
27336 | for (position = Index + 4; Index < position; Index++) {
|
27337 | charCode = source.charCodeAt(Index);
|
27338 |
|
27339 |
|
27340 | if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {
|
27341 |
|
27342 | abort();
|
27343 | }
|
27344 | }
|
27345 |
|
27346 | value += fromCharCode("0x" + source.slice(begin, Index));
|
27347 | break;
|
27348 | default:
|
27349 |
|
27350 | abort();
|
27351 | }
|
27352 | } else {
|
27353 | if (charCode == 34) {
|
27354 |
|
27355 |
|
27356 | break;
|
27357 | }
|
27358 | charCode = source.charCodeAt(Index);
|
27359 | begin = Index;
|
27360 |
|
27361 | while (charCode >= 32 && charCode != 92 && charCode != 34) {
|
27362 | charCode = source.charCodeAt(++Index);
|
27363 | }
|
27364 |
|
27365 | value += source.slice(begin, Index);
|
27366 | }
|
27367 | }
|
27368 | if (source.charCodeAt(Index) == 34) {
|
27369 |
|
27370 | Index++;
|
27371 | return value;
|
27372 | }
|
27373 |
|
27374 | abort();
|
27375 | default:
|
27376 |
|
27377 | begin = Index;
|
27378 |
|
27379 | if (charCode == 45) {
|
27380 | isSigned = true;
|
27381 | charCode = source.charCodeAt(++Index);
|
27382 | }
|
27383 |
|
27384 | if (charCode >= 48 && charCode <= 57) {
|
27385 |
|
27386 | if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {
|
27387 |
|
27388 | abort();
|
27389 | }
|
27390 | isSigned = false;
|
27391 |
|
27392 | for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++);
|
27393 |
|
27394 |
|
27395 | if (source.charCodeAt(Index) == 46) {
|
27396 | position = ++Index;
|
27397 |
|
27398 | for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
|
27399 | if (position == Index) {
|
27400 |
|
27401 | abort();
|
27402 | }
|
27403 | Index = position;
|
27404 | }
|
27405 |
|
27406 |
|
27407 | charCode = source.charCodeAt(Index);
|
27408 | if (charCode == 101 || charCode == 69) {
|
27409 | charCode = source.charCodeAt(++Index);
|
27410 |
|
27411 |
|
27412 | if (charCode == 43 || charCode == 45) {
|
27413 | Index++;
|
27414 | }
|
27415 |
|
27416 | for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
|
27417 | if (position == Index) {
|
27418 |
|
27419 | abort();
|
27420 | }
|
27421 | Index = position;
|
27422 | }
|
27423 |
|
27424 | return +source.slice(begin, Index);
|
27425 | }
|
27426 |
|
27427 | if (isSigned) {
|
27428 | abort();
|
27429 | }
|
27430 |
|
27431 | if (source.slice(Index, Index + 4) == "true") {
|
27432 | Index += 4;
|
27433 | return true;
|
27434 | } else if (source.slice(Index, Index + 5) == "false") {
|
27435 | Index += 5;
|
27436 | return false;
|
27437 | } else if (source.slice(Index, Index + 4) == "null") {
|
27438 | Index += 4;
|
27439 | return null;
|
27440 | }
|
27441 |
|
27442 | abort();
|
27443 | }
|
27444 | }
|
27445 |
|
27446 |
|
27447 | return "$";
|
27448 | };
|
27449 |
|
27450 |
|
27451 | var get = function (value) {
|
27452 | var results, hasMembers;
|
27453 | if (value == "$") {
|
27454 |
|
27455 | abort();
|
27456 | }
|
27457 | if (typeof value == "string") {
|
27458 | if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") {
|
27459 |
|
27460 | return value.slice(1);
|
27461 | }
|
27462 |
|
27463 | if (value == "[") {
|
27464 |
|
27465 | results = [];
|
27466 | for (;; hasMembers || (hasMembers = true)) {
|
27467 | value = lex();
|
27468 |
|
27469 | if (value == "]") {
|
27470 | break;
|
27471 | }
|
27472 |
|
27473 |
|
27474 |
|
27475 | if (hasMembers) {
|
27476 | if (value == ",") {
|
27477 | value = lex();
|
27478 | if (value == "]") {
|
27479 |
|
27480 | abort();
|
27481 | }
|
27482 | } else {
|
27483 |
|
27484 | abort();
|
27485 | }
|
27486 | }
|
27487 |
|
27488 | if (value == ",") {
|
27489 | abort();
|
27490 | }
|
27491 | results.push(get(value));
|
27492 | }
|
27493 | return results;
|
27494 | } else if (value == "{") {
|
27495 |
|
27496 | results = {};
|
27497 | for (;; hasMembers || (hasMembers = true)) {
|
27498 | value = lex();
|
27499 |
|
27500 | if (value == "}") {
|
27501 | break;
|
27502 | }
|
27503 |
|
27504 |
|
27505 | if (hasMembers) {
|
27506 | if (value == ",") {
|
27507 | value = lex();
|
27508 | if (value == "}") {
|
27509 |
|
27510 | abort();
|
27511 | }
|
27512 | } else {
|
27513 |
|
27514 | abort();
|
27515 | }
|
27516 | }
|
27517 |
|
27518 |
|
27519 |
|
27520 | if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") {
|
27521 | abort();
|
27522 | }
|
27523 | results[value.slice(1)] = get(lex());
|
27524 | }
|
27525 | return results;
|
27526 | }
|
27527 | // Unexpected token encountered.
|
27528 | abort();
|
27529 | }
|
27530 | return value;
|
27531 | };
|
27532 |
|
27533 | // Internal: Updates a traversed object member.
|
27534 | var update = function (source, property, callback) {
|
27535 | var element = walk(source, property, callback);
|
27536 | if (element === undef) {
|
27537 | delete source[property];
|
27538 | } else {
|
27539 | source[property] = element;
|
27540 | }
|
27541 | };
|
27542 |
|
27543 |
|
27544 |
|
27545 |
|
27546 | var walk = function (source, property, callback) {
|
27547 | var value = source[property], length;
|
27548 | if (typeof value == "object" && value) {
|
27549 |
|
27550 |
|
27551 |
|
27552 | if (getClass.call(value) == arrayClass) {
|
27553 | for (length = value.length; length--;) {
|
27554 | update(value, length, callback);
|
27555 | }
|
27556 | } else {
|
27557 | forEach(value, function (property) {
|
27558 | update(value, property, callback);
|
27559 | });
|
27560 | }
|
27561 | }
|
27562 | return callback.call(source, property, value);
|
27563 | };
|
27564 |
|
27565 |
|
27566 | exports.parse = function (source, callback) {
|
27567 | var result, value;
|
27568 | Index = 0;
|
27569 | Source = "" + source;
|
27570 | result = get(lex());
|
27571 | // If a JSON string contains multiple tokens, it is invalid.
|
27572 | if (lex() != "$") {
|
27573 | abort();
|
27574 | }
|
27575 |
|
27576 | Index = Source = null;
|
27577 | return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;
|
27578 | };
|
27579 | }
|
27580 | }
|
27581 |
|
27582 | exports["runInContext"] = runInContext;
|
27583 | return exports;
|
27584 | }
|
27585 |
|
27586 | if (freeExports && !isLoader) {
|
27587 |
|
27588 | runInContext(root, freeExports);
|
27589 | } else {
|
27590 |
|
27591 | var nativeJSON = root.JSON,
|
27592 | previousJSON = root["JSON3"],
|
27593 | isRestored = false;
|
27594 |
|
27595 | var JSON3 = runInContext(root, (root["JSON3"] = {
|
27596 |
|
27597 |
|
27598 | "noConflict": function () {
|
27599 | if (!isRestored) {
|
27600 | isRestored = true;
|
27601 | root.JSON = nativeJSON;
|
27602 | root["JSON3"] = previousJSON;
|
27603 | nativeJSON = previousJSON = null;
|
27604 | }
|
27605 | return JSON3;
|
27606 | }
|
27607 | }));
|
27608 |
|
27609 | root.JSON = {
|
27610 | "parse": JSON3.parse,
|
27611 | "stringify": JSON3.stringify
|
27612 | };
|
27613 | }
|
27614 |
|
27615 |
|
27616 | if (isLoader) {
|
27617 | define(function () {
|
27618 | return JSON3;
|
27619 | });
|
27620 | }
|
27621 | }).call(this);
|
27622 |
|
27623 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
27624 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/node_modules/to-array/index.js":[function(require,module,exports){
|
27625 | module.exports = toArray
|
27626 |
|
27627 | function toArray(list, index) {
|
27628 | var array = []
|
27629 |
|
27630 | index = index || 0
|
27631 |
|
27632 | for (var i = index || 0; i < list.length; i++) {
|
27633 | array[i - index] = list[i]
|
27634 | }
|
27635 |
|
27636 | return array
|
27637 | }
|
27638 |
|
27639 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/index.js":[function(require,module,exports){
|
27640 | var HttpClient = require('./lib/http-client');
|
27641 | var events = require('events');
|
27642 | var inherits = require('inherits');
|
27643 | var StreamAPI = require('./lib/stream_api');
|
27644 | var _ = require('lodash');
|
27645 | var Logger = require('./lib/logger');
|
27646 |
|
27647 | function Klic(options){
|
27648 | options = options || {};
|
27649 | this.base_url = options.url || "https://api.2klic.io";
|
27650 | this.apiVersion = options.apiVersion || "1.0";
|
27651 | this.auth = options.auth || {};
|
27652 |
|
27653 | this.logger = new Logger(options.log_level || 6);
|
27654 |
|
27655 | this.http = new HttpClient(this.base_url, {app_key: options.app_key, unsafe: options.unsafe, logger: this.logger, api_version: this.api_version, app_type: options.app_type });
|
27656 |
|
27657 |
|
27658 | this.alarm = require("./lib/methods/alarm/alarm")({ platform: this });
|
27659 | this.zones = require("./lib/methods/alarm/zones")({ platform: this });
|
27660 |
|
27661 | this.noc = require("./lib/methods/noc/noc")({ platform: this });
|
27662 | this.cameras = require("./lib/methods/cameras")({ platform: this });
|
27663 | this.streams = require("./lib/methods/streams")({ platform: this });
|
27664 | this.devices = require("./lib/methods/devices")({ platform: this });
|
27665 | this.zwave = require("./lib/methods/zwave")({ platform: this });
|
27666 | this.events = require("./lib/methods/events")({ platform: this });
|
27667 | this.locations = require("./lib/methods/locations")({ platform: this });
|
27668 | this.scenarios = require("./lib/methods/scenarios")({ platform: this });
|
27669 | this.models = require("./lib/methods/models")({ platform: this });
|
27670 | this.notifications = require("./lib/methods/notifications")({ platform: this });
|
27671 | this.translations = require("./lib/methods/translations")({ platform: this });
|
27672 | this.user = require("./lib/methods/user")({ platform: this });
|
27673 | this.templates = require("./lib/methods/templates")({ platform: this });
|
27674 | this.system = require("./lib/methods/system")({ platform: this });
|
27675 | this.access = require("./lib/methods/access/access")({ platform: this });
|
27676 | }
|
27677 |
|
27678 | inherits(Klic, events.EventEmitter);
|
27679 |
|
27680 | Klic.prototype.authenticate = require('./lib/methods/authenticate');
|
27681 | Klic.prototype.register = require('./lib/methods/register');
|
27682 |
|
27683 | module.exports = Klic;
|
27684 |
|
27685 | },{"./lib/http-client":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/http-client.js","./lib/logger":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/logger.js","./lib/methods/access/access":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/access/access.js","./lib/methods/alarm/alarm":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/alarm.js","./lib/methods/alarm/zones":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/zones.js","./lib/methods/authenticate":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/authenticate.js","./lib/methods/cameras":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/cameras.js","./lib/methods/devices":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/devices.js","./lib/methods/events":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/events.js","./lib/methods/locations":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/locations.js","./lib/methods/models":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/models.js","./lib/methods/noc/noc":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/noc.js","./lib/methods/notifications":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/notifications.js","./lib/methods/register":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/register.js","./lib/methods/scenarios":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/scenarios.js","./lib/methods/streams":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/streams.js","./lib/methods/system":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/system.js","./lib/methods/templates":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/templates.js","./lib/methods/translations":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/translations.js","./lib/methods/user":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/user.js","./lib/methods/zwave":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/zwave.js","./lib/stream_api":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/stream_api.js","events":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/events/events.js","inherits":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/inherits/inherits_browser.js","lodash":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/lodash/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/http-client.js":[function(require,module,exports){
|
27686 | (function (Buffer){
|
27687 | var request = require('request');
|
27688 |
|
27689 | var MixinPromise = require('./mixin_promise');
|
27690 | var _ = require('lodash');
|
27691 |
|
27692 | function HttpClient(baseUrl, options) {
|
27693 | options = options || {};
|
27694 | this.url = baseUrl;
|
27695 | this.app_key = options.app_key;
|
27696 | this.app_type = options.app_type || 'browser';
|
27697 | this.app_secret = options.app_secret;
|
27698 | this.unsafe = options.unsafe;
|
27699 | this.logger = options.logger;
|
27700 | this.api_version = options.api_version;
|
27701 | this.callback = _.noop;
|
27702 | this.enableCallback = options.enableCallback || true;
|
27703 | }
|
27704 |
|
27705 | HttpClient.prototype.request = function(method, path, body, options) {
|
27706 | var _this = this;
|
27707 | this.logger.trace("Executing HTTP request " + method + " " + path);
|
27708 |
|
27709 | if(arguments.length === 3) {
|
27710 | options = body;
|
27711 | body = undefined;
|
27712 | }
|
27713 | else if(arguments.length === 2) {
|
27714 | options = {};
|
27715 | }
|
27716 |
|
27717 | options = options || {};
|
27718 |
|
27719 | return new MixinPromise(function(resolve, reject) {
|
27720 |
|
27721 | var headers = {};
|
27722 |
|
27723 | if (options.token) {
|
27724 | _this.logger.trace("Token was provided. Adding Authorization header");
|
27725 | headers['authorization'] = "Bearer " + options.token;
|
27726 | _this.logger.trace(headers['authorization']);
|
27727 | }
|
27728 | else if (options.basic) {
|
27729 | _this.logger.trace("Basic credentials were provided. Adding Authorization header");
|
27730 | var str = new Buffer(options.basic.username + ":" + options.basic.password, "utf8").toString("base64");
|
27731 | headers['authorization'] = "Basic " + str;
|
27732 | }
|
27733 |
|
27734 | if (options.app_key || _this.app_key) {
|
27735 | _this.logger.trace("Configuring X-App-Key to ", options.app_key || _this.app_key);
|
27736 | headers['x-app-key'] = options.app_key || _this.app_key;
|
27737 | }
|
27738 |
|
27739 | if (options.unsafe || _this.unsafe) {
|
27740 | _this.logger.trace("Indicating to the platform that we are in the browser (unsafe)");
|
27741 | headers['x-unsafe-auth'] = options.unsafe || _this.unsafe;
|
27742 | }
|
27743 |
|
27744 | if (options.api_version || _this.api_version) {
|
27745 | headers['x-api-version'] = options.api_version || _this.api_version;
|
27746 | }
|
27747 |
|
27748 | if (options.app_type || _this.app_type) {
|
27749 | headers['x-app-type'] = options.app_type || _this.app_type;
|
27750 | }
|
27751 |
|
27752 | _this.logger.trace("Request URL is: " + method + " " + _this.url + path);
|
27753 |
|
27754 | return new MixinPromise(function (resolve, reject) {
|
27755 | request({
|
27756 | method: method,
|
27757 | url: _this.url + path,
|
27758 | json: body,
|
27759 | headers: headers,
|
27760 | verbose: false,
|
27761 |
|
27762 | timeout: options.timeout || 30000,
|
27763 | qs: options.query || null
|
27764 | }, function (err, resp, body) {
|
27765 | if (err) {
|
27766 | _this.logger.error("HTTP ERROR:", err);
|
27767 | reject(err);
|
27768 | }
|
27769 | else {
|
27770 | _this.logger.trace("Receive a valid HTTP response");
|
27771 | if (resp.statusCode >= 400) {
|
27772 | _this.logger.error("Receive status code %d", resp.statusCode);
|
27773 | err = new Error("HTTP " + resp.statusCode + ": " + method + " " + path);
|
27774 | err.statusCode = resp.statusCode;
|
27775 | err.statusText = resp.statusText;
|
27776 |
|
27777 | if (_isJson(body)) body = JSON.parse(body);
|
27778 | err.code = body.code;
|
27779 | err.parameters = body.parameters;
|
27780 | err.message = body.message;
|
27781 |
|
27782 | if (body.details) err.details = body.details;
|
27783 |
|
27784 | err.error = resp.error;
|
27785 | err.body = body;
|
27786 | reject(err);
|
27787 | }
|
27788 | else if (resp.statusCode === 0) {
|
27789 | _this.logger.error("Unable to connect to platform");
|
27790 | err = new Error("Unable to connect to server");
|
27791 | err.statusCode = 0;
|
27792 | reject(err);
|
27793 | }
|
27794 | else if (body) {
|
27795 | _this.logger.trace("Receive a valid body");
|
27796 | if (_.isString(body)) {
|
27797 | body = JSON.parse(body);
|
27798 | }
|
27799 |
|
27800 | if (body.data) {
|
27801 | resolve(body);
|
27802 | }
|
27803 | else {
|
27804 | _this.logger.trace("Resolving response promise. Status Code=", resp.statusCode);
|
27805 | resolve({statusCode: resp.statusCode, data: body});
|
27806 | }
|
27807 | }
|
27808 | else {
|
27809 | _this.logger.trace("Resolving without body. Status code = %d", resp.statusCode);
|
27810 | resolve({statusCode: resp.statusCode});
|
27811 | }
|
27812 | }
|
27813 | });
|
27814 | }).then(function (res) {
|
27815 | resolve(res);
|
27816 | }).catch(function (error) {
|
27817 | if (_this.enableCallback) {
|
27818 | var p = _this.callback(error);
|
27819 | var isPromise = _.isObject(p) && _.isFunction(p.then);
|
27820 |
|
27821 | if (isPromise) {
|
27822 | p.then(function () {
|
27823 | reject(error);
|
27824 | });
|
27825 | }
|
27826 | else reject(error);
|
27827 | }
|
27828 | });
|
27829 | });
|
27830 | };
|
27831 |
|
27832 | HttpClient.prototype.post = function(path, body, options) {
|
27833 | if(typeof(body) === 'object') body = _.omit(body, function(prop){ if(typeof(prop)==='string' && !prop.length) return true });
|
27834 | return this.request('POST', path, body, options);
|
27835 | };
|
27836 |
|
27837 | HttpClient.prototype.delete = function(path, options) {
|
27838 | return this.request('DELETE', path, options);
|
27839 | };
|
27840 |
|
27841 | HttpClient.prototype.get = function(path, options) {
|
27842 | return this.request('GET', path, options);
|
27843 | };
|
27844 |
|
27845 | HttpClient.prototype.put = function(path, body, options) {
|
27846 | if(typeof(body) === 'object') body = _.omit(body, function(prop){ if(typeof(prop)==='string' && !prop.length) return true });
|
27847 | if(arguments.length === 2) {
|
27848 | options = body;
|
27849 | body = undefined;
|
27850 | }
|
27851 | return this.request('PUT', path, body, options);
|
27852 | };
|
27853 |
|
27854 | HttpClient.prototype.patch = function(path, body, options) {
|
27855 | if(typeof(body) === 'object') body = _.omit(body, function(prop){ if(typeof(prop)==='string' && !prop.length) return true });
|
27856 | return this.request('PATCH', path, body, options);
|
27857 | };
|
27858 |
|
27859 | function _isJson(str) {
|
27860 | try {
|
27861 | JSON.parse(str);
|
27862 | } catch (e) {
|
27863 | return false;
|
27864 | }
|
27865 | return true;
|
27866 | }
|
27867 |
|
27868 | module.exports = HttpClient;
|
27869 | }).call(this,require("buffer").Buffer)
|
27870 | },{"./mixin_promise":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/mixin_promise.js","buffer":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/buffer/index.js","lodash":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/lodash/index.js","request":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browser-request/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/logger.js":[function(require,module,exports){
|
27871 | function Logger(level) {
|
27872 | this.level = level;
|
27873 | }
|
27874 |
|
27875 | Logger.prototype.trace = function() {
|
27876 | if(this.level > 9) {
|
27877 | console.log.apply(console, arguments);
|
27878 | }
|
27879 | };
|
27880 |
|
27881 | Logger.prototype.debug = function() {
|
27882 | if(this.level > 7) {
|
27883 | console.log.apply(console, arguments);
|
27884 | }
|
27885 | };
|
27886 |
|
27887 | Logger.prototype.info = function() {
|
27888 | if(this.level > 5) {
|
27889 | console.log.apply(console, arguments);
|
27890 | }
|
27891 | };
|
27892 |
|
27893 | Logger.prototype.warn = function() {
|
27894 | if(this.level > 3) {
|
27895 | console.log.apply(console, arguments);
|
27896 | }
|
27897 | };
|
27898 |
|
27899 | Logger.prototype.error = function() {
|
27900 | if(this.level > 1) {
|
27901 | console.log.apply(console, arguments);
|
27902 | }
|
27903 | };
|
27904 |
|
27905 | Logger.prototype.fatal = function() {
|
27906 | console.log.apply(console, arguments);
|
27907 | };
|
27908 |
|
27909 | module.exports = Logger;
|
27910 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/access/access.js":[function(require,module,exports){
|
27911 | 'use strict';
|
27912 | var Cards = require("./cards");
|
27913 |
|
27914 | function Access(options) {
|
27915 | options = options || {};
|
27916 | this.platform = options.platform;
|
27917 | this.cards = new Cards ({ platform: this.platform });
|
27918 | }
|
27919 |
|
27920 | Access.prototype.list = function(params){
|
27921 | return this.platform.http.get('/access/', { query: params, token: this.platform.auth.token });
|
27922 | };
|
27923 |
|
27924 | Access.prototype.get = function(id, params){
|
27925 | return this.platform.http.get('/access/'+id, { query: params, token: this.platform.auth.token });
|
27926 | };
|
27927 |
|
27928 | Access.prototype.create = function(accessData){
|
27929 | return this.platform.http.post('/access', accessData, { token: this.platform.auth.token });
|
27930 | };
|
27931 |
|
27932 | Access.prototype.update = function(id, accessData){
|
27933 | return this.platform.http.put('/access/' + id, accessData, { token: this.platform.auth.token });
|
27934 | };
|
27935 |
|
27936 | Access.prototype.patch = function(id, accessData){
|
27937 | return this.platform.http.patch('/access/' + d, accessData, { token: this.platform.auth.token });
|
27938 | };
|
27939 |
|
27940 | Access.prototype.patch = function(id, accessData){
|
27941 | return this.platform.http.patch('/access/' + id, accessData, { token: this.platform.auth.token });
|
27942 | };
|
27943 |
|
27944 |
|
27945 | module.exports = function(options) {
|
27946 | options = options || {};
|
27947 | return new Access(options);
|
27948 | };
|
27949 |
|
27950 | },{"./cards":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/access/cards.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/access/cards.js":[function(require,module,exports){
|
27951 | 'use strict';
|
27952 |
|
27953 | function Cards(options) {
|
27954 | options = options || {};
|
27955 | this.platform = options.platform;
|
27956 | }
|
27957 |
|
27958 | Cards.prototype.list= function(){
|
27959 | return this.platform.http.get('/access/cards', { token: this.platform.auth.token });
|
27960 | };
|
27961 |
|
27962 | Cards.prototype.get= function(id){
|
27963 | return this.platform.http.get('/access/cards/' + id, { token: this.platform.auth.token });
|
27964 | };
|
27965 |
|
27966 | Cards.prototype.create= function(cardData){
|
27967 | return this.platform.http.post('/access/cards', cardData, { token: this.platform.auth.token });
|
27968 | };
|
27969 |
|
27970 | Cards.prototype.update= function(id, cardData){
|
27971 | return this.platform.http.put('/access/cards/' + id, cardData, { token: this.platform.auth.token });
|
27972 | };
|
27973 |
|
27974 | Cards.prototype.patch = function(id, cardData){
|
27975 | return this.platform.http.patch ('/access/cards/' + id, cardData, { token: this.platform.auth.token });
|
27976 | };
|
27977 |
|
27978 | module.exports = function(options) {
|
27979 | options = options || {};
|
27980 | return new Cards(options);
|
27981 | };
|
27982 |
|
27983 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/alarm.js":[function(require,module,exports){
|
27984 | 'use strict';
|
27985 | var User = require("./user");
|
27986 | var Pin = require("./pin");
|
27987 | var Zone = require("./zones");
|
27988 |
|
27989 | function Alarm(options) {
|
27990 | options = options || {};
|
27991 | this.platform = options.platform;
|
27992 | this.user = new User({ platform: this.platform });
|
27993 | this.pin = new Pin({ platform: this.platform });
|
27994 | this.zones = new Zone({ platform: this.platform });
|
27995 | }
|
27996 |
|
27997 |
|
27998 | Alarm.prototype.create = function(alarm){
|
27999 | return this.platform.http.post('/alarms', alarm, { token: this.platform.auth.token });
|
28000 | };
|
28001 |
|
28002 |
|
28003 | Alarm.prototype.get = function(alarmId){
|
28004 | return this.platform.http.get('/alarms/'+alarmId, { token: this.platform.auth.token });
|
28005 | };
|
28006 |
|
28007 | Alarm.prototype.list = function(){
|
28008 | return this.platform.http.get('/alarms', { token: this.platform.auth.token });
|
28009 | };
|
28010 |
|
28011 | Alarm.prototype.patch = function(alarm, alarmId){
|
28012 | return this.platform.http.patch('/alarms/'+alarmId, alarm, { token: this.platform.auth.token });
|
28013 | };
|
28014 |
|
28015 | Alarm.prototype.delete = function(alarmId){
|
28016 | return this.platform.http.delete('/alarms/'+alarmId, { token: this.platform.auth.token });
|
28017 | };
|
28018 |
|
28019 | Alarm.prototype.getToken = function(alarmId, pin){
|
28020 | return this.platform.http.post('/alarms/'+alarmId+'/auth/token', { pin: pin }, { token: this.platform.auth.token });
|
28021 | };
|
28022 |
|
28023 |
|
28024 | Alarm.prototype.reset = function(alarmId){
|
28025 | return this.platform.http.post('/alarms/'+alarmId+'/reset', {}, { token: this.platform.auth.token });
|
28026 | };
|
28027 |
|
28028 | Alarm.prototype.arm = function(alarmId, armToken, state, bypassedZoneIds){
|
28029 | return this.platform.http.put('/alarms/'+alarmId, { state: state, bypassed: bypassedZoneIds }, { query: { armToken: armToken }, token: this.platform.auth.token });
|
28030 | };
|
28031 |
|
28032 | module.exports = function(options) {
|
28033 | options = options || {};
|
28034 | return new Alarm(options);
|
28035 | };
|
28036 |
|
28037 |
|
28038 | },{"./pin":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/pin.js","./user":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/user.js","./zones":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/zones.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/pin.js":[function(require,module,exports){
|
28039 | 'use strict';
|
28040 |
|
28041 | function Pin(options) {
|
28042 | options = options || {};
|
28043 | this.platform = options.platform;
|
28044 | }
|
28045 |
|
28046 | Pin.prototype.update = function(alarmId, userId, pin){
|
28047 | return this.platform.http.put('/alarms/'+alarmId+'/users/'+userId+'/pin', pin, { token: this.platform.auth.token });
|
28048 | };
|
28049 |
|
28050 | module.exports = function(options) {
|
28051 | options = options || {};
|
28052 | return new Pin(options);
|
28053 | };
|
28054 |
|
28055 |
|
28056 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/user.js":[function(require,module,exports){
|
28057 | 'use strict';
|
28058 |
|
28059 | function User(options) {
|
28060 | options = options || {};
|
28061 | this.platform = options.platform;
|
28062 | }
|
28063 |
|
28064 |
|
28065 | User.prototype.create = function(alarmId, userId){
|
28066 | return this.platform.http.post('/alarms/'+alarmId+'/users/'+userId, {}, { token: this.platform.auth.token });
|
28067 | };
|
28068 |
|
28069 |
|
28070 | User.prototype.list = function(alarmId){
|
28071 | return this.platform.http.get('/alarms/'+alarmId+'/users', { token: this.platform.auth.token });
|
28072 | };
|
28073 |
|
28074 |
|
28075 | User.prototype.delete = function(alarmId, userId){
|
28076 | if(userId) return this.platform.http.delete('/alarms/'+alarmId+'/users/'+userId, { token: this.platform.auth.token });
|
28077 | else return this.platform.http.delete('/alarms/'+alarmId+'/users', { token: this.platform.auth.token });
|
28078 | };
|
28079 |
|
28080 |
|
28081 |
|
28082 | module.exports = function(options) {
|
28083 | options = options || {};
|
28084 | return new User(options);
|
28085 | };
|
28086 |
|
28087 |
|
28088 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/alarm/zones.js":[function(require,module,exports){
|
28089 | 'use strict';
|
28090 |
|
28091 | var _ = require('lodash');
|
28092 |
|
28093 | function Zones(options) {
|
28094 | options = options || {};
|
28095 | this.platform = options.platform;
|
28096 | }
|
28097 |
|
28098 |
|
28099 | Zones.prototype.create = function(alarmId, zone, query){
|
28100 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28101 | return this.platform.http.post('/alarms/'+alarmId+'/zones', zone, { query: query, token: this.platform.auth.token });
|
28102 | };
|
28103 |
|
28104 | Zones.prototype.list = function(alarmId, query){
|
28105 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28106 | return this.platform.http.get('/alarms/'+alarmId+'/zones', { query: query, token: this.platform.auth.token });
|
28107 | };
|
28108 |
|
28109 | Zones.prototype.get = function(alarmId, zoneId, query){
|
28110 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28111 | return this.platform.http.get('/alarms/'+alarmId+'/zones/'+zoneId, { query: query, token: this.platform.auth.token });
|
28112 | };
|
28113 |
|
28114 | Zones.prototype.update = function(alarmId, zone, query){
|
28115 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28116 | return this.platform.http.put('/alarms/'+alarmId+'/zones/'+zone._id, zone, { query: query, token: this.platform.auth.token });
|
28117 | };
|
28118 |
|
28119 | Zones.prototype.patch = function(alarmId, obj, zoneId, query){
|
28120 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28121 | return this.platform.http.patch('/alarms/'+alarmId+'/zones/'+zoneId, obj, { query: query, token: this.platform.auth.token });
|
28122 | };
|
28123 |
|
28124 | Zones.prototype.delete = function(alarmId, zoneId, query){
|
28125 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28126 | if(zoneId) return this.platform.http.delete('/alarms/'+alarmId+'/zones/'+zoneId, { token: this.platform.auth.token });
|
28127 | else return this.platform.http.delete('/alarms/'+alarmId+'/zones', { query: query, token: this.platform.auth.token });
|
28128 | };
|
28129 |
|
28130 | module.exports = function(options) {
|
28131 | options = options || {};
|
28132 | return new Zones(options);
|
28133 | };
|
28134 |
|
28135 |
|
28136 | },{"lodash":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/lodash/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/authenticate.js":[function(require,module,exports){
|
28137 | module.exports = (function() {
|
28138 |
|
28139 | return function(credentials, options) {
|
28140 | var _this = this, logger = this.logger;
|
28141 | options = options || {};
|
28142 |
|
28143 | logger.debug("Executing HTTP request GET /auth/token");
|
28144 | return this.http.post("/auth/token", {}, {
|
28145 | basic: {
|
28146 | username: credentials.username,
|
28147 | password: credentials.password
|
28148 | }
|
28149 | }).then(function(resp) {
|
28150 | logger.trace(resp);
|
28151 | if(!_this.auth) {
|
28152 | logger.debug("No existing platform auth field. Initializing it");
|
28153 | _this.auth = {};
|
28154 | }
|
28155 | if(resp) {
|
28156 | logger.debug("Installing token %s as default platform auth mechanism", resp.data.token);
|
28157 | _this.auth.token = resp.data.token;
|
28158 | return resp.data;
|
28159 | }
|
28160 | else {
|
28161 | logger.error("Invalid response received from platform");
|
28162 | }
|
28163 |
|
28164 | });
|
28165 |
|
28166 | };
|
28167 |
|
28168 | })();
|
28169 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/cameras.js":[function(require,module,exports){
|
28170 | 'use strict';
|
28171 |
|
28172 | function Cameras(options) {
|
28173 | options = options || {};
|
28174 | this.platform = options.platform;
|
28175 | }
|
28176 |
|
28177 | Cameras.prototype.get = function(propertyId){
|
28178 | return this.platform.http.get('/homes/'+propertyId+'/cameras/stream/all', { token: this.platform.auth.token });
|
28179 | };
|
28180 |
|
28181 | module.exports = function(options) {
|
28182 | options = options || {};
|
28183 | return new Cameras(options);
|
28184 | };
|
28185 |
|
28186 |
|
28187 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/devices.js":[function(require,module,exports){
|
28188 | 'use strict';
|
28189 |
|
28190 | var _ = require('lodash');
|
28191 |
|
28192 | function Devices(options) {
|
28193 | options = options || {};
|
28194 | this.platform = options.platform;
|
28195 | }
|
28196 |
|
28197 | Devices.prototype.list = function(query){
|
28198 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28199 | return this.platform.http.get('/devices', { query: query, token: this.platform.auth.token });
|
28200 | };
|
28201 |
|
28202 | Devices.prototype.get = function(deviceId, query){
|
28203 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28204 | return this.platform.http.get('/devices/'+deviceId, { query: query, token: this.platform.auth.token });
|
28205 | };
|
28206 |
|
28207 | Devices.prototype.getChildren = function(deviceId, level, query){
|
28208 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28209 | var query = _.merge({ showChildren: true, level: level }, query);
|
28210 | return this.platform.http.get('/devices/'+deviceId, { query: query, token: this.platform.auth.token });
|
28211 | };
|
28212 |
|
28213 | Devices.prototype.create = function(device, query){
|
28214 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28215 | return this.platform.http.post('/devices', device, { query: query, token: this.platform.auth.token });
|
28216 | };
|
28217 |
|
28218 | Devices.prototype.update = function(device, query){
|
28219 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28220 | return this.platform.http.put('/devices/'+device._id, device, { query: query, token: this.platform.auth.token });
|
28221 | };
|
28222 |
|
28223 | Devices.prototype.patch = function(obj, deviceId, query){
|
28224 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28225 | return this.platform.http.patch('/devices/'+deviceId, obj, { query: query, token: this.platform.auth.token });
|
28226 | };
|
28227 |
|
28228 | Devices.prototype.delete = function(deviceId, query){
|
28229 | if(_.get(query, 'populate')) query.populate = query.populate.toString();
|
28230 | return this.platform.http.delete('/devices/'+deviceId, { query: query, token: this.platform.auth.token });
|
28231 | };
|
28232 |
|
28233 |
|
28234 | Devices.prototype.reset = function(deviceId){
|
28235 | return this.platform.http.put('/devices/'+deviceId+'/reset', {}, { token: this.platform.auth.token });
|
28236 | };
|
28237 |
|
28238 | Devices.prototype.updateCapability = function(deviceId, capabilityId, value, unit, timestamp){
|
28239 | return this.platform.http.put('/devices/'+deviceId+'/caps/'+capabilityId, { value: value, unit: unit, timestamp: timestamp }, { token: this.platform.auth.token });
|
28240 | };
|
28241 |
|
28242 | Devices.prototype.patchCapability = function(deviceId, capabilityId, obj){
|
28243 | return this.platform.http.patch('/devices/'+deviceId+'/caps/'+capabilityId, obj, { token: this.platform.auth.token });
|
28244 | };
|
28245 |
|
28246 | Devices.prototype.getCapability = function(deviceId, capabilityId){
|
28247 | return this.platform.http.get('/devices/'+deviceId+'/caps/'+capabilityId, { token: this.platform.auth.token });
|
28248 | };
|
28249 |
|
28250 | Devices.prototype.listCapability = function(deviceId){
|
28251 | return this.platform.http.get('/devices/'+deviceId+'/caps', { token: this.platform.auth.token });
|
28252 | };
|
28253 |
|
28254 |
|
28255 | Devices.prototype.provision = function(name, mac, model, location){
|
28256 | var _this = this;
|
28257 | var obj = _.merge({ name:name, mac:mac, model:model }, { location: location });
|
28258 | return this.platform.http.post('/devices', obj)
|
28259 | .then(function(res){
|
28260 |
|
28261 | if(res.data.token) _this.platform.auth.token = res.data.token;
|
28262 | return res;
|
28263 | })
|
28264 | };
|
28265 |
|
28266 |
|
28267 | Devices.prototype.heartbeat = function(deviceId, sysHealth){
|
28268 | return this.platform.http.post('/devices/'+deviceId+'/heartbeat', sysHealth, { token: this.platform.auth.token });
|
28269 | };
|
28270 |
|
28271 | Devices.prototype.listHeartbeat = function(deviceId, query){
|
28272 | return this.platform.http.get('/devices/'+deviceId+'/heartbeat', { query: query, token: this.platform.auth.token });
|
28273 | };
|
28274 |
|
28275 |
|
28276 | Devices.prototype.ping = function(deviceId){
|
28277 | return this.platform.http.post('/devices/'+deviceId+'/ping', {}, { token: this.platform.auth.token });
|
28278 | };
|
28279 |
|
28280 | module.exports = function(options) {
|
28281 | options = options || {};
|
28282 | return new Devices(options);
|
28283 | };
|
28284 |
|
28285 |
|
28286 | },{"lodash":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/lodash/index.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/events.js":[function(require,module,exports){
|
28287 | 'use strict';
|
28288 |
|
28289 | function Events(options) {
|
28290 | options = options || {};
|
28291 | this.platform = options.platform;
|
28292 | }
|
28293 |
|
28294 | Events.prototype.create = function(resourcePath, eventType, resource, timestamp, requestId){
|
28295 | return this.platform.http.post('/events', { path: resourcePath, resource: resource, timestamp: timestamp, type: eventType, request: requestId }, { token: this.platform.auth.token });
|
28296 | };
|
28297 |
|
28298 | module.exports = function(options) {
|
28299 | options = options || {};
|
28300 | return new Events(options);
|
28301 | };
|
28302 |
|
28303 |
|
28304 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/locations.js":[function(require,module,exports){
|
28305 | 'use strict';
|
28306 |
|
28307 | function Locations(options) {
|
28308 | options = options || {};
|
28309 | this.platform = options.platform;
|
28310 | }
|
28311 |
|
28312 | Locations.prototype.list = function(level){
|
28313 | return this.platform.http.get('/locations', { query:{ level: level }, token: this.platform.auth.token });
|
28314 | };
|
28315 |
|
28316 | Locations.prototype.get = function(locationId, level){
|
28317 | return this.platform.http.get('/locations/'+locationId, { query: { level: level }, token: this.platform.auth.token });
|
28318 | };
|
28319 |
|
28320 | Locations.prototype.getRoot = function(locationId, level){
|
28321 | return this.platform.http.get('/locations/'+locationId, { query: { root: true, level: level }, token: this.platform.auth.token });
|
28322 | };
|
28323 |
|
28324 | Locations.prototype.create = function(location){
|
28325 | return this.platform.http.post('/locations', location, { token: this.platform.auth.token });
|
28326 | };
|
28327 |
|
28328 | Locations.prototype.update = function(location){
|
28329 | return this.platform.http.put('/locations/'+location._id, location, { token: this.platform.auth.token });
|
28330 | };
|
28331 |
|
28332 | Locations.prototype.patch = function(obj, locationId){
|
28333 | return this.platform.http.patch('/locations/'+locationId, obj, { token: this.platform.auth.token });
|
28334 | };
|
28335 |
|
28336 | Locations.prototype.delete = function(locationId){
|
28337 | return this.platform.http.delete('/locations/'+locationId, { token: this.platform.auth.token });
|
28338 | };
|
28339 |
|
28340 | module.exports = function(options) {
|
28341 | options = options || {};
|
28342 | return new Locations(options);
|
28343 | };
|
28344 |
|
28345 |
|
28346 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/models.js":[function(require,module,exports){
|
28347 | 'use strict';
|
28348 |
|
28349 | function Models(options) {
|
28350 | options = options || {};
|
28351 | this.platform = options.platform;
|
28352 | }
|
28353 |
|
28354 | Models.prototype.list = function(query){
|
28355 | return this.platform.http.get('/models', { query: query, token: this.platform.auth.token });
|
28356 | };
|
28357 |
|
28358 | Models.prototype.get = function(id, query){
|
28359 | return this.platform.http.get('/models/'+id, { query: query, token: this.platform.auth.token });
|
28360 | };
|
28361 |
|
28362 | Models.prototype.search = function(query){
|
28363 | return this.platform.http.get('/models', { query: query, token: this.platform.auth.token });
|
28364 | };
|
28365 |
|
28366 | module.exports = function(options) {
|
28367 | options = options || {};
|
28368 | return new Models(options);
|
28369 | };
|
28370 |
|
28371 |
|
28372 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/customers.js":[function(require,module,exports){
|
28373 | 'use strict';
|
28374 |
|
28375 | function NocCustomers(options) {
|
28376 | options = options || {};
|
28377 | this.platform = options.platform;
|
28378 | }
|
28379 |
|
28380 | NocCustomers.prototype.list= function(nocId){
|
28381 | return this.platform.http.get('/nocs/' + nocId + '/customers', { token: this.platform.auth.token });
|
28382 | };
|
28383 |
|
28384 | NocCustomers.prototype.get= function(nocId, customerId){
|
28385 | return this.platform.http.get('/nocs/' + nocId + '/customers/' + customerId, { token: this.platform.auth.token });
|
28386 | };
|
28387 |
|
28388 | NocCustomers.prototype.create= function(nocId, customer){
|
28389 | return this.platform.http.post('/nocs/' + nocId + '/customers', customer, { token: this.platform.auth.token });
|
28390 | };
|
28391 |
|
28392 | NocCustomers.prototype.update= function(nocId, customerId, customer){
|
28393 | return this.platform.http.put('/nocs/' + nocId + '/customers/' + customerId, customer, { token: this.platform.auth.token });
|
28394 | };
|
28395 |
|
28396 | NocCustomers.prototype.patch = function(nocId, customerId, customer){
|
28397 | return this.platform.http.patch ('/nocs/' + nocId + '/customers/' + customerId, customer, { token: this.platform.auth.token });
|
28398 | };
|
28399 |
|
28400 | NocCustomers.prototype.listDevices = function(nocId, customerId, alarmSystemId){
|
28401 | return this.platform.http.get('/nocs/' + nocId + '/customers/' + customerId + '/devices/' + alarmSystemId, { token: this.platform.auth.token });
|
28402 | };
|
28403 |
|
28404 | NocCustomers.prototype.getPredefinedServiceActions= function(nocId, customerId, alarmSystemId){
|
28405 | return this.platform.http.get('/nocs/' + nocId + '/customers/' + customerId + '/alarmsystem/' + alarmSystemId + '/predefined-service-actions', { token: this.platform.auth.token });
|
28406 | };
|
28407 |
|
28408 | NocCustomers.prototype.listServiceActions= function(nocId, customerId){
|
28409 | return this.platform.http.get('/nocs/' + nocId + '/customers/' + customerId + '/actions', { token: this.platform.auth.token });
|
28410 | };
|
28411 |
|
28412 | NocCustomers.prototype.getServiceAction= function(nocId, customerId, actionId){
|
28413 | return this.platform.http.get('/nocs/' + nocId + '/customers/' + customerId + '/actions/' + actionId, { token: this.platform.auth.token });
|
28414 | };
|
28415 |
|
28416 | NocCustomers.prototype.createServiceAction= function(nocId, customerId, actionData){
|
28417 | return this.platform.http.post('/nocs/' + nocId + '/customers/' + customerId + '/actions', actionData, { token: this.platform.auth.token });
|
28418 | };
|
28419 |
|
28420 | NocCustomers.prototype.updateServiceAction = function(nocId, customerId, actionId, actionData){
|
28421 | return this.platform.http.put('/nocs/' + nocId + '/customers/' + customerId + '/actions/' + actionId, actionData, { token: this.platform.auth.token });
|
28422 | };
|
28423 |
|
28424 | NocCustomers.prototype.listInstallations= function(nocId){
|
28425 | return this.platform.http.get('/nocs/' + nocId + '/customers/installations', { token: this.platform.auth.token });
|
28426 | };
|
28427 |
|
28428 | NocCustomers.prototype.getInstallation= function(nocId, installationId){
|
28429 | return this.platform.http.get('/nocs/' + nocId + '/customers/installations/' + installationId, { token: this.platform.auth.token });
|
28430 | };
|
28431 |
|
28432 | NocCustomers.prototype.createInstallation= function(nocId, installationData){
|
28433 | return this.platform.http.post('/nocs/' + nocId + '/customers/installations', installationData, { token: this.platform.auth.token });
|
28434 | };
|
28435 |
|
28436 | NocCustomers.prototype.updateInstallation= function(nocId, installationId, installationData){
|
28437 | return this.platform.http.put('/nocs/' + nocId + '/customers/installations/' + installationId, installationData, { token: this.platform.auth.token });
|
28438 | };
|
28439 |
|
28440 |
|
28441 | module.exports = function(options) {
|
28442 | options = options || {};
|
28443 | return new NocCustomers(options);
|
28444 | };
|
28445 |
|
28446 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/noc.js":[function(require,module,exports){
|
28447 | 'use strict';
|
28448 | var NocCustomers = require("./customers");
|
28449 | var NocTickets = require("./tickets");
|
28450 | var NocServices = require("./services");
|
28451 | var NocServiceActions = require("./service_actions");
|
28452 |
|
28453 | function Noc(options) {
|
28454 | options = options || {};
|
28455 | this.platform = options.platform;
|
28456 | this.customers = new NocCustomers({ platform: this.platform });
|
28457 | this.tickets = new NocTickets({ platform: this.platform });
|
28458 | this.services = new NocServices({ platform: this.platform });
|
28459 | this.service_actions = new NocServiceActions({ platform: this.platform });
|
28460 | }
|
28461 |
|
28462 | Noc.prototype.list = function() {
|
28463 | return this.platform.http.get('/nocs/', { token: this.platform.auth.token });
|
28464 | };
|
28465 |
|
28466 | Noc.prototype.get = function(nocId){
|
28467 | return this.platform.http.get('/nocs/' + nocId, { token: this.platform.auth.token });
|
28468 | };
|
28469 |
|
28470 | Noc.prototype.create = function(noc){
|
28471 | return this.platform.http.post('/nocs', noc, { token: this.platform.auth.token });
|
28472 | };
|
28473 |
|
28474 | Noc.prototype.update = function(nocId, noc){
|
28475 | return this.platform.http.put('/nocs/' + nocId, noc, { token: this.platform.auth.token });
|
28476 | };
|
28477 |
|
28478 | Noc.prototype.patch = function(nocId, noc){
|
28479 | return this.platform.http.patch('/nocs/' + nocId, noc, { token: this.platform.auth.token });
|
28480 | };
|
28481 |
|
28482 | Noc.prototype.approve = function(nocId, approvalToken){
|
28483 | return this.platform.http.put('/nocs/' + nocId + '/approve/' + approvalToken);
|
28484 | };
|
28485 |
|
28486 | Noc.prototype.approval_link = function(email){
|
28487 | return this.platform.http.get('/nocs/approval-link/' + email);
|
28488 | };
|
28489 |
|
28490 | module.exports = function(options) {
|
28491 | options = options || {};
|
28492 | return new Noc(options);
|
28493 | };
|
28494 |
|
28495 | },{"./customers":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/customers.js","./service_actions":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/service_actions.js","./services":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/services.js","./tickets":"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/tickets.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/service_actions.js":[function(require,module,exports){
|
28496 | 'use strict';
|
28497 |
|
28498 | function NocServiceActions(options) {
|
28499 | options = options || {};
|
28500 | this.platform = options.platform;
|
28501 | }
|
28502 |
|
28503 | NocServiceActions.prototype.list= function(nocId){
|
28504 | return this.platform.http.get('/nocs/' + nocId + '/service_actions', { token: this.platform.auth.token });
|
28505 | };
|
28506 |
|
28507 | NocServiceActions.prototype.get= function(nocId, serviceId){
|
28508 | return this.platform.http.get('/nocs/' + nocId + '/service_actions/' + serviceId, { token: this.platform.auth.token });
|
28509 | };
|
28510 |
|
28511 | NocServiceActions.prototype.getPredefinedServiceActions= function(nocId){
|
28512 | return this.platform.http.get('/nocs/' + nocId + '/service_actions/predefined', { token: this.platform.auth.token });
|
28513 | };
|
28514 |
|
28515 | NocServiceActions.prototype.create= function(nocId, serviceActions){
|
28516 | return this.platform.http.post('/nocs/' + nocId + '/service_actions', serviceActions, { token: this.platform.auth.token });
|
28517 | };
|
28518 |
|
28519 | NocServiceActions.prototype.update= function(nocId, serviceId, serviceActions){
|
28520 | return this.platform.http.put('/nocs/' + nocId + '/service_actions/' + serviceId, serviceActions, { token: this.platform.auth.token });
|
28521 | };
|
28522 |
|
28523 | NocServiceActions.prototype.patch = function(nocId, serviceId, serviceActions){
|
28524 | return this.platform.http.patch ('/nocs/' + nocId + '/service_actions/' + serviceId, serviceActions, { token: this.platform.auth.token });
|
28525 | };
|
28526 |
|
28527 | module.exports = function(options) {
|
28528 | options = options || {};
|
28529 | return new NocServiceActions(options);
|
28530 | };
|
28531 |
|
28532 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/services.js":[function(require,module,exports){
|
28533 | 'use strict';
|
28534 |
|
28535 | function NocServices(options) {
|
28536 | options = options || {};
|
28537 | this.platform = options.platform;
|
28538 | }
|
28539 |
|
28540 | NocServices.prototype.list= function(nocId){
|
28541 | return this.platform.http.get('/nocs/' + nocId + '/services', { token: this.platform.auth.token });
|
28542 | };
|
28543 |
|
28544 | NocServices.prototype.get= function(nocId, serviceId){
|
28545 | return this.platform.http.get('/nocs/' + nocId + '/services/' + serviceId, { token: this.platform.auth.token });
|
28546 | };
|
28547 |
|
28548 | NocServices.prototype.create= function(nocId, service){
|
28549 | return this.platform.http.post('/nocs/' + nocId + '/services', service, { token: this.platform.auth.token });
|
28550 | };
|
28551 |
|
28552 | NocServices.prototype.update= function(nocId, serviceId, service){
|
28553 | return this.platform.http.put('/nocs/' + nocId + '/services/' + serviceId, service, { token: this.platform.auth.token });
|
28554 | };
|
28555 |
|
28556 | NocServices.prototype.patch = function(nocId, serviceId, service){
|
28557 | return this.platform.http.patch ('/nocs/' + nocId + '/services/' + serviceId, service, { token: this.platform.auth.token });
|
28558 | };
|
28559 |
|
28560 | module.exports = function(options) {
|
28561 | options = options || {};
|
28562 | return new NocServices(options);
|
28563 | };
|
28564 |
|
28565 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/noc/tickets.js":[function(require,module,exports){
|
28566 | 'use strict';
|
28567 |
|
28568 | function NocTickets(options) {
|
28569 | options = options || {};
|
28570 | this.platform = options.platform;
|
28571 | }
|
28572 |
|
28573 | NocTickets.prototype.list = function(nocId){
|
28574 | return this.platform.http.get('/nocs/' + nocId + '/noc_tickets', { token: this.platform.auth.token });
|
28575 | };
|
28576 |
|
28577 | NocTickets.prototype.get = function(nocId, ticketId){
|
28578 | return this.platform.http.get('/nocs/' + nocId + '/noc_tickets/' + ticketId, { token: this.platform.auth.token });
|
28579 | };
|
28580 |
|
28581 | NocTickets.prototype.update = function(nocId, ticketId, ticket){
|
28582 | return this.platform.http.put('/nocs/' + nocId + '/noc_tickets/' + ticketId, ticket, { token: this.platform.auth.token });
|
28583 | };
|
28584 |
|
28585 | NocTickets.prototype.patch = function(nocId, ticketId, ticket){
|
28586 | return this.platform.http.patch ('/nocs/' + nocId + '/noc_tickets/' + ticketId, ticket, { token: this.platform.auth.token });
|
28587 | };
|
28588 |
|
28589 | NocTickets.prototype.create = function(nocId, ticket){
|
28590 | return this.platform.http.post('/nocs' + nocId + '/noc_ticket', ticket, { token: this.platform.auth.token });
|
28591 | };
|
28592 |
|
28593 | NocTickets.prototype.listDevices = function(nocId, ticketId){
|
28594 | return this.platform.http.get('/nocs/' + nocId + '/noc_tickets/' + ticketId + '/devices', { token: this.platform.auth.token });
|
28595 | };
|
28596 |
|
28597 | NocTickets.prototype.listEvents = function(nocId, ticketId){
|
28598 | return this.platform.http.get('/nocs/' + nocId + '/noc_tickets/' + ticketId + '/noc_ticket_events', { token: this.platform.auth.token });
|
28599 | };
|
28600 |
|
28601 | NocTickets.prototype.getEvent = function(nocId, ticketId, ticketEventId){
|
28602 | return this.platform.http.get('/nocs/' + nocId + '/noc_tickets/' + ticketId + '/noc_ticket_events/' + ticketEventId, { token: this.platform.auth.token });
|
28603 | };
|
28604 |
|
28605 | NocTickets.prototype.createEvent = function(nocId, ticketId, ticketEvent){
|
28606 | return this.platform.http.post('/nocs/' + nocId + '/noc_tickets/' + ticketId + '/noc_ticket_events', ticketEvent, { token: this.platform.auth.token });
|
28607 | };
|
28608 |
|
28609 | NocTickets.prototype.updateEvent= function(nocId, ticketId, ticketEventId, ticketEvent){
|
28610 | return this.platform.http.put('/nocs/' + nocId + '/noc_tickets/' + ticketId + '/noc_ticket_events/' + ticketEventId, ticketEvent, { token: this.platform.auth.token });
|
28611 | };
|
28612 |
|
28613 | NocTickets.prototype.patchEvent = function(nocId, ticketId, ticketEventId, ticketEvent){
|
28614 | return this.platform.http.patch ('/nocs/' + nocId + '/noc_tickets/' + ticketId + '/noc_ticket_events/' + ticketEventId, ticketEvent, { token: this.platform.auth.token });
|
28615 | };
|
28616 |
|
28617 | module.exports = function(options) {
|
28618 | options = options || {};
|
28619 | return new NocTickets(options);
|
28620 | };
|
28621 |
|
28622 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/notifications.js":[function(require,module,exports){
|
28623 | 'use strict';
|
28624 |
|
28625 | function Notifications(options) {
|
28626 | options = options || {};
|
28627 | this.platform = options.platform;
|
28628 | }
|
28629 |
|
28630 | Notifications.prototype.list = function(params){
|
28631 | return this.platform.http.get('/notifications', { query: params, token: this.platform.auth.token });
|
28632 | };
|
28633 |
|
28634 | Notifications.prototype.get = function(locationId, params){
|
28635 | return this.platform.http.get('/locations/'+locationId+'/notifications', { query: params, token: this.platform.auth.token });
|
28636 | };
|
28637 |
|
28638 | Notifications.prototype.patch = function(notificationId, obj){
|
28639 | return this.platform.http.patch('/notifications/'+notificationId, obj, { token: this.platform.auth.token });
|
28640 | };
|
28641 |
|
28642 | Notifications.prototype.markRead = function(notificationId){
|
28643 | return this.platform.http.patch('/notifications/'+notificationId, { read: true, readTs: Date.now() }, { token: this.platform.auth.token });
|
28644 | };
|
28645 |
|
28646 | Notifications.prototype.getConfig = function(){
|
28647 | return this.platform.http.get('/notifications/config', { token: this.platform.auth.token });
|
28648 | };
|
28649 |
|
28650 | Notifications.prototype.updateConfig = function(config){
|
28651 | return this.platform.http.put('/notifications/config' + (config._id ? "/"+config._id:""), config, { token: this.platform.auth.token });
|
28652 | };
|
28653 |
|
28654 | module.exports = function(options) {
|
28655 | options = options || {};
|
28656 | return new Notifications(options);
|
28657 | };
|
28658 |
|
28659 |
|
28660 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/register.js":[function(require,module,exports){
|
28661 | module.exports = (function() {
|
28662 |
|
28663 | return function(user, options) {
|
28664 | var _this = this, logger = this.logger;
|
28665 | options = options || {};
|
28666 |
|
28667 | logger.debug("Executing HTTP request GET /auth/register");
|
28668 | return this.http.post("/auth/register", user, options).then(function(resp) {
|
28669 | logger.debug(resp);
|
28670 | if(resp) {
|
28671 | return resp.data;
|
28672 | }
|
28673 | else {
|
28674 | logger.error("Invalid response received from platform");
|
28675 | }
|
28676 |
|
28677 | });
|
28678 |
|
28679 | };
|
28680 |
|
28681 | })();
|
28682 |
|
28683 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/scenarios.js":[function(require,module,exports){
|
28684 | 'use strict';
|
28685 |
|
28686 | function Scenarios(options) {
|
28687 | options = options || {};
|
28688 | this.platform = options.platform;
|
28689 | }
|
28690 |
|
28691 | Scenarios.prototype.list = function(){
|
28692 | return this.platform.http.get('/scenarios', { token: this.platform.auth.token });
|
28693 | };
|
28694 |
|
28695 | Scenarios.prototype.get = function(scenarioId){
|
28696 | return this.platform.http.get('/scenarios/'+scenarioId, { token: this.platform.auth.token });
|
28697 | };
|
28698 |
|
28699 | Scenarios.prototype.create = function(scenario){
|
28700 | return this.platform.http.post('/scenarios', scenario, { token: this.platform.auth.token });
|
28701 | };
|
28702 |
|
28703 | Scenarios.prototype.update = function(scenario){
|
28704 | return this.platform.http.put('/scenarios/'+scenario._id, scenario, { token: this.platform.auth.token });
|
28705 | };
|
28706 |
|
28707 | Scenarios.prototype.patch = function(scenarioId, obj){
|
28708 | return this.platform.http.patch('/scenarios/'+scenarioId, obj, { token: this.platform.auth.token });
|
28709 | };
|
28710 |
|
28711 | Scenarios.prototype.delete = function(scenarioId){
|
28712 | return this.platform.http.delete('/scenarios/'+scenarioId, { token: this.platform.auth.token });
|
28713 | };
|
28714 |
|
28715 | module.exports = function(options) {
|
28716 | options = options || {};
|
28717 | return new Scenarios(options);
|
28718 | };
|
28719 |
|
28720 |
|
28721 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/streams.js":[function(require,module,exports){
|
28722 | 'use strict';
|
28723 |
|
28724 | function Streams(options) {
|
28725 | options = options || {};
|
28726 | this.platform = options.platform;
|
28727 | }
|
28728 |
|
28729 |
|
28730 | Streams.prototype.list = function(){
|
28731 |
|
28732 | return this.platform.http.get('/streams', { token: this.platform.auth.token });
|
28733 | };
|
28734 |
|
28735 | module.exports = function(options) {
|
28736 | options = options || {};
|
28737 | return new Streams(options);
|
28738 | };
|
28739 |
|
28740 |
|
28741 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/system.js":[function(require,module,exports){
|
28742 | 'use strict';
|
28743 |
|
28744 | function System(options) {
|
28745 | options = options || {};
|
28746 | this.platform = options.platform;
|
28747 | }
|
28748 |
|
28749 | System.prototype.info = function(){
|
28750 | return this.platform.http.get('/system/info');
|
28751 | };
|
28752 |
|
28753 | module.exports = function(options) {
|
28754 | options = options || {};
|
28755 | return new System(options);
|
28756 | };
|
28757 |
|
28758 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/templates.js":[function(require,module,exports){
|
28759 | 'use strict';
|
28760 |
|
28761 | function Templates(options) {
|
28762 | options = options || {};
|
28763 | this.platform = options.platform;
|
28764 | }
|
28765 |
|
28766 | Templates.prototype.list = function(){
|
28767 | return this.platform.http.get('/templates', { token: this.platform.auth.token });
|
28768 | };
|
28769 |
|
28770 | Templates.prototype.get = function(templateId, level){
|
28771 | return this.platform.http.get('/templates/'+templateId, { query: { level: level }, token: this.platform.auth.token });
|
28772 | };
|
28773 |
|
28774 | Templates.prototype.create = function(template){
|
28775 | return this.platform.http.post('/templates', template, { token: this.platform.auth.token });
|
28776 | };
|
28777 |
|
28778 | Templates.prototype.patch = function(obj, templateId){
|
28779 | return this.platform.http.patch('/templates/'+templateId, obj, { token: this.platform.auth.token });
|
28780 | };
|
28781 |
|
28782 | Templates.prototype.delete = function(templateId){
|
28783 | return this.platform.http.delete('/templates/'+templateId, { token: this.platform.auth.token });
|
28784 | };
|
28785 |
|
28786 | module.exports = function(options) {
|
28787 | options = options || {};
|
28788 | return new Templates(options);
|
28789 | };
|
28790 |
|
28791 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/translations.js":[function(require,module,exports){
|
28792 | 'use strict';
|
28793 |
|
28794 | function Translations(options) {
|
28795 | options = options || {};
|
28796 | this.platform = options.platform;
|
28797 | }
|
28798 |
|
28799 | Translations.prototype.list = function(){
|
28800 | return this.platform.http.get('/translations', { token: this.platform.auth.token });
|
28801 | };
|
28802 |
|
28803 | Translations.prototype.get = function(key){
|
28804 | return this.platform.http.get('/translations/'+key, { token: this.platform.auth.token });
|
28805 | };
|
28806 |
|
28807 | Translations.prototype.create = function(translation){
|
28808 | return this.platform.http.post('/translations', translation, { token: this.platform.auth.token });
|
28809 | };
|
28810 |
|
28811 | Translations.prototype.update = function(key, translation){
|
28812 | return this.platform.http.put('/translations/'+key, translation, { token: this.platform.auth.token });
|
28813 | };
|
28814 |
|
28815 |
|
28816 | module.exports = function(options) {
|
28817 | options = options || {};
|
28818 | return new Translations(options);
|
28819 | };
|
28820 |
|
28821 |
|
28822 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/user.js":[function(require,module,exports){
|
28823 | 'use strict';
|
28824 |
|
28825 | function User(options) {
|
28826 | options = options || {};
|
28827 | this.platform = options.platform;
|
28828 | }
|
28829 |
|
28830 | User.prototype.get = function(username){
|
28831 | return this.platform.http.get('/users/'+username, { token: this.platform.auth.token });
|
28832 | };
|
28833 |
|
28834 | User.prototype.register = function(user){
|
28835 | return this.platform.http.post('/auth/register', user);
|
28836 | };
|
28837 |
|
28838 | User.prototype.forgot = function(email){
|
28839 | return this.platform.http.get('/auth/forgot/'+email);
|
28840 | };
|
28841 |
|
28842 | User.prototype.reset = function(resetToken){
|
28843 | return this.platform.http.get('/auth/reset/'+resetToken);
|
28844 | };
|
28845 |
|
28846 | User.prototype.resetPassword = function(resetToken, passwordInfo){
|
28847 | return this.platform.http.post('/auth/reset/'+resetToken, passwordInfo);
|
28848 | };
|
28849 |
|
28850 | User.prototype.confirm = function(key){
|
28851 | return this.platform.http.get('/auth/confirm/'+key);
|
28852 | };
|
28853 |
|
28854 | User.prototype.changePassword = function(username, currentPassword, password){
|
28855 | return this.platform.http.put('/users/'+username+'/password', { current:currentPassword, password:password }, { token: this.platform.auth.token });
|
28856 | };
|
28857 |
|
28858 | User.prototype.list = function(){
|
28859 | return this.platform.http.get('/users', { token: this.platform.auth.token });
|
28860 | };
|
28861 |
|
28862 | User.prototype.listAlarmSystems = function(userId){
|
28863 | return this.platform.http.get('/users/' + userId + '/alarms', { token: this.platform.auth.token });
|
28864 | };
|
28865 |
|
28866 | User.prototype.getCurrentUser = function(options){
|
28867 | var token;
|
28868 | options ? token = options.token : token = undefined;
|
28869 | return this.platform.http.get('/users/me', { token: token || this.platform.auth.token });
|
28870 | };
|
28871 |
|
28872 | User.prototype.update = function(username, user){
|
28873 | return this.platform.http.put('/users/'+username, user, { token: this.platform.auth.token });
|
28874 | };
|
28875 |
|
28876 | User.prototype.patch = function(username, obj){
|
28877 | return this.platform.http.patch('/users/'+username, obj, { token: this.platform.auth.token });
|
28878 | };
|
28879 |
|
28880 | User.prototype.delete = function(username){
|
28881 | return this.platform.http.delete('/users/'+username, { token: this.platform.auth.token });
|
28882 | };
|
28883 |
|
28884 | User.prototype.bindDevice = function(mac, location){
|
28885 | return this.platform.http.post('/devices/bind', { mac: mac, location: location }, { token: this.platform.auth.token });
|
28886 | };
|
28887 |
|
28888 | module.exports = function(options) {
|
28889 | options = options || {};
|
28890 | return new User(options);
|
28891 | };
|
28892 |
|
28893 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/methods/zwave.js":[function(require,module,exports){
|
28894 | 'use strict';
|
28895 |
|
28896 | function ZWave(options) {
|
28897 | options = options || {};
|
28898 | this.platform = options.platform;
|
28899 | }
|
28900 |
|
28901 | ZWave.prototype.exclusion = function(gatewayId){
|
28902 | return this.platform.http.post('/devices/'+gatewayId+'/zwave/exclude', {}, { token: this.platform.auth.token });
|
28903 | };
|
28904 |
|
28905 | ZWave.prototype.removeFailed = function(gatewayId){
|
28906 | return this.platform.http.delete('/devices/'+gatewayId+'/zwave/failed', {}, { token: this.platform.auth.token });
|
28907 | };
|
28908 |
|
28909 | module.exports = function(options) {
|
28910 | options = options || {};
|
28911 | return new ZWave(options);
|
28912 | };
|
28913 |
|
28914 |
|
28915 | },{}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/mixin_promise.js":[function(require,module,exports){
|
28916 | var P = require("bluebird").noConflict();
|
28917 |
|
28918 | P.prototype.mixin = function(cstor) {
|
28919 | var o = new cstor();
|
28920 | o.__p = this;
|
28921 |
|
28922 | o.catch = function(fn) {
|
28923 | this.__p.catch.call(this.__p, fn.bind(this));
|
28924 | return this;
|
28925 | };
|
28926 |
|
28927 | o.then = o.ready = function(fn) {
|
28928 | this.__p.then.call(this.__p, fn.bind(this));
|
28929 | return this;
|
28930 | };
|
28931 |
|
28932 | o.finally = function(fn) {
|
28933 | this.__p.finally.apply(this.__p, fn.bind(this));
|
28934 | return this;
|
28935 | };
|
28936 |
|
28937 | return o;
|
28938 | };
|
28939 |
|
28940 | module.exports = P;
|
28941 | },{"bluebird":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/bluebird/js/browser/bluebird.js"}],"/home/employee-2klic/projects/2klic_io-sdk/src/lib/stream_api.js":[function(require,module,exports){
|
28942 | var socketIOClient = require('socket.io-client');
|
28943 | var events = require('events');
|
28944 | var inherits = require('inherits');
|
28945 | var _ = require('lodash');
|
28946 |
|
28947 | function Subscriber(channelString, handler) {
|
28948 | this.channelString = channelString;
|
28949 | this.handler = handler;
|
28950 | }
|
28951 |
|
28952 | Subscriber.prototype.handle = function(event) {
|
28953 |
|
28954 | if(this.channelString.indexOf('*') !== -1) {
|
28955 | var channel = this.channelString.split('/')[0];
|
28956 | if(event.type.indexOf(channel) !== -1) {
|
28957 | this.handler(event);
|
28958 | }
|
28959 | }
|
28960 | else if(this.channelString === event.type) {
|
28961 | return this.handler(event);
|
28962 | }
|
28963 |
|
28964 | };
|
28965 |
|
28966 | function Channel(key, api) {
|
28967 | this.key = key;
|
28968 | this.api = api;
|
28969 | events.EventEmitter.call(this);
|
28970 | }
|
28971 | inherits(Channel, events.EventEmitter);
|
28972 |
|
28973 |
|
28974 |
|
28975 |
|
28976 |
|
28977 |
|
28978 |
|
28979 |
|
28980 |
|
28981 |
|
28982 | Channel.subscribe = function(options) {
|
28983 | var subscribeKey = "/" + this.key + "/";
|
28984 | if(_.isString(options.type)) {
|
28985 | subscribeKey += options.type;
|
28986 | }
|
28987 | else {
|
28988 | subscribeKey += "*";
|
28989 | }
|
28990 |
|
28991 | return this.api.subscribe(subscribeKey, (function(options) {
|
28992 | var types = [];
|
28993 | if(_.isString(options.type)) {
|
28994 | types = options.type.split(',');
|
28995 | }
|
28996 | else {
|
28997 | types = options.types;
|
28998 | }
|
28999 |
|
29000 | return function(event) {
|
29001 | if(types.indexOf(event.type) !== -1) {
|
29002 | options.handler.call(options.scope || this, event);
|
29003 | }
|
29004 | }
|
29005 | })(options), { token: options.token, persistence: options.persistence });
|
29006 | };
|
29007 |
|
29008 | function _handleEvent(event) {
|
29009 | var _this = this;
|
29010 |
|
29011 | _.each(this.subscribers, function(subscriber) {
|
29012 |
|
29013 |
|
29014 | subscriber.handle(event, function(reply) {
|
29015 | _this.socket.emit('reply', {
|
29016 | replyTo: event.id,
|
29017 | data: reply
|
29018 | });
|
29019 | });
|
29020 |
|
29021 | });
|
29022 |
|
29023 | }
|
29024 |
|
29025 | function StreamAPI(options) {
|
29026 | options = options || {};
|
29027 |
|
29028 | this.url = options.url;
|
29029 | this.subscribers = [];
|
29030 |
|
29031 | this.socket = socketIOClient(options.url, options.socket);
|
29032 |
|
29033 | events.EventEmitter.call(this);
|
29034 |
|
29035 |
|
29036 | this.socket.on('connect', function() {
|
29037 | console.log("Stream API is CONNECTED to %s", this.url);
|
29038 | this.emit('connect');
|
29039 | }.bind(this));
|
29040 |
|
29041 | this.socket.on('disconnect', function() {
|
29042 | console.log("Stream API is DISCONNECTED from %s", this.url);
|
29043 | this.emit('disconnect');
|
29044 | }.bind(this));
|
29045 |
|
29046 | this.socket.on('event', _handleEvent.bind(this));
|
29047 |
|
29048 |
|
29049 | StreamAPI.catalog = new Channel("catalog", this);
|
29050 | StreamAPI.klic = new Channel("2klic", this);
|
29051 | StreamAPI.marketplace = new Channel("marketplace", this);
|
29052 | StreamAPI.social = new Channel("social", this);
|
29053 | StreamAPI.profile = new Channel("profile", this);
|
29054 | StreamAPI.system = new Channel("system", this);
|
29055 |
|
29056 | }
|
29057 |
|
29058 | inherits(StreamAPI, events.EventEmitter);
|
29059 |
|
29060 | StreamAPI.prototype.subscribe = function(channelString, handler, options) {
|
29061 | options = options || {};
|
29062 |
|
29063 |
|
29064 | this.subscribers.push(new Subscriber(channelString, handler));
|
29065 |
|
29066 | this.socket.emit('subscribe', {
|
29067 | channel: channelString,
|
29068 | token: options.token,
|
29069 | persistence: options.persistence
|
29070 | });
|
29071 | };
|
29072 |
|
29073 | module.exports = StreamAPI;
|
29074 | },{"events":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/browserify/node_modules/events/events.js","inherits":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/inherits/inherits_browser.js","lodash":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/lodash/index.js","socket.io-client":"/home/employee-2klic/projects/2klic_io-sdk/node_modules/socket.io-client/lib/index.js"}]},{},["/home/employee-2klic/projects/2klic_io-sdk/src/index.js"])("/home/employee-2klic/projects/2klic_io-sdk/src/index.js")
|
29075 | });
|
29076 |
|