Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50659 views
1
(function() {
2
var define, requireModule, require, requirejs;
3
4
(function() {
5
var registry = {}, seen = {};
6
7
define = function(name, deps, callback) {
8
registry[name] = { deps: deps, callback: callback };
9
};
10
11
requirejs = require = requireModule = function(name) {
12
requirejs._eak_seen = registry;
13
14
if (seen[name]) { return seen[name]; }
15
seen[name] = {};
16
17
if (!registry[name]) {
18
throw new Error("Could not find module " + name);
19
}
20
21
var mod = registry[name],
22
deps = mod.deps,
23
callback = mod.callback,
24
reified = [],
25
exports;
26
27
for (var i=0, l=deps.length; i<l; i++) {
28
if (deps[i] === 'exports') {
29
reified.push(exports = {});
30
} else {
31
reified.push(requireModule(resolve(deps[i])));
32
}
33
}
34
35
var value = callback.apply(this, reified);
36
return seen[name] = exports || value;
37
38
function resolve(child) {
39
if (child.charAt(0) !== '.') { return child; }
40
var parts = child.split("/");
41
var parentBase = name.split("/").slice(0, -1);
42
43
for (var i=0, l=parts.length; i<l; i++) {
44
var part = parts[i];
45
46
if (part === '..') { parentBase.pop(); }
47
else if (part === '.') { continue; }
48
else { parentBase.push(part); }
49
}
50
51
return parentBase.join("/");
52
}
53
};
54
})();
55
56
define("promise/all",
57
["./utils","exports"],
58
function(__dependency1__, __exports__) {
59
"use strict";
60
/* global toString */
61
62
var isArray = __dependency1__.isArray;
63
var isFunction = __dependency1__.isFunction;
64
65
/**
66
Returns a promise that is fulfilled when all the given promises have been
67
fulfilled, or rejected if any of them become rejected. The return promise
68
is fulfilled with an array that gives all the values in the order they were
69
passed in the `promises` array argument.
70
71
Example:
72
73
```javascript
74
var promise1 = RSVP.resolve(1);
75
var promise2 = RSVP.resolve(2);
76
var promise3 = RSVP.resolve(3);
77
var promises = [ promise1, promise2, promise3 ];
78
79
RSVP.all(promises).then(function(array){
80
// The array here would be [ 1, 2, 3 ];
81
});
82
```
83
84
If any of the `promises` given to `RSVP.all` are rejected, the first promise
85
that is rejected will be given as an argument to the returned promises's
86
rejection handler. For example:
87
88
Example:
89
90
```javascript
91
var promise1 = RSVP.resolve(1);
92
var promise2 = RSVP.reject(new Error("2"));
93
var promise3 = RSVP.reject(new Error("3"));
94
var promises = [ promise1, promise2, promise3 ];
95
96
RSVP.all(promises).then(function(array){
97
// Code here never runs because there are rejected promises!
98
}, function(error) {
99
// error.message === "2"
100
});
101
```
102
103
@method all
104
@for RSVP
105
@param {Array} promises
106
@param {String} label
107
@return {Promise} promise that is fulfilled when all `promises` have been
108
fulfilled, or rejected if any of them become rejected.
109
*/
110
function all(promises) {
111
/*jshint validthis:true */
112
var Promise = this;
113
114
if (!isArray(promises)) {
115
throw new TypeError('You must pass an array to all.');
116
}
117
118
return new Promise(function(resolve, reject) {
119
var results = [], remaining = promises.length,
120
promise;
121
122
if (remaining === 0) {
123
resolve([]);
124
}
125
126
function resolver(index) {
127
return function(value) {
128
resolveAll(index, value);
129
};
130
}
131
132
function resolveAll(index, value) {
133
results[index] = value;
134
if (--remaining === 0) {
135
resolve(results);
136
}
137
}
138
139
for (var i = 0; i < promises.length; i++) {
140
promise = promises[i];
141
142
if (promise && isFunction(promise.then)) {
143
promise.then(resolver(i), reject);
144
} else {
145
resolveAll(i, promise);
146
}
147
}
148
});
149
}
150
151
__exports__.all = all;
152
});
153
define("promise/asap",
154
["exports"],
155
function(__exports__) {
156
"use strict";
157
var browserGlobal = (typeof window !== 'undefined') ? window : {};
158
var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
159
var local = (typeof global !== 'undefined') ? global : (this === undefined? window:this);
160
161
// node
162
function useNextTick() {
163
return function() {
164
process.nextTick(flush);
165
};
166
}
167
168
function useMutationObserver() {
169
var iterations = 0;
170
var observer = new BrowserMutationObserver(flush);
171
var node = document.createTextNode('');
172
observer.observe(node, { characterData: true });
173
174
return function() {
175
node.data = (iterations = ++iterations % 2);
176
};
177
}
178
179
function useSetTimeout() {
180
return function() {
181
local.setTimeout(flush, 1);
182
};
183
}
184
185
var queue = [];
186
function flush() {
187
for (var i = 0; i < queue.length; i++) {
188
var tuple = queue[i];
189
var callback = tuple[0], arg = tuple[1];
190
callback(arg);
191
}
192
queue = [];
193
}
194
195
var scheduleFlush;
196
197
// Decide what async method to use to triggering processing of queued callbacks:
198
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
199
scheduleFlush = useNextTick();
200
} else if (BrowserMutationObserver) {
201
scheduleFlush = useMutationObserver();
202
} else {
203
scheduleFlush = useSetTimeout();
204
}
205
206
function asap(callback, arg) {
207
var length = queue.push([callback, arg]);
208
if (length === 1) {
209
// If length is 1, that means that we need to schedule an async flush.
210
// If additional callbacks are queued before the queue is flushed, they
211
// will be processed by this flush that we are scheduling.
212
scheduleFlush();
213
}
214
}
215
216
__exports__.asap = asap;
217
});
218
define("promise/config",
219
["exports"],
220
function(__exports__) {
221
"use strict";
222
var config = {
223
instrument: false
224
};
225
226
function configure(name, value) {
227
if (arguments.length === 2) {
228
config[name] = value;
229
} else {
230
return config[name];
231
}
232
}
233
234
__exports__.config = config;
235
__exports__.configure = configure;
236
});
237
define("promise/polyfill",
238
["./promise","./utils","exports"],
239
function(__dependency1__, __dependency2__, __exports__) {
240
"use strict";
241
/*global self*/
242
var RSVPPromise = __dependency1__.Promise;
243
var isFunction = __dependency2__.isFunction;
244
245
function polyfill() {
246
var local;
247
248
if (typeof global !== 'undefined') {
249
local = global;
250
} else if (typeof window !== 'undefined' && window.document) {
251
local = window;
252
} else {
253
local = self;
254
}
255
256
var es6PromiseSupport =
257
"Promise" in local &&
258
// Some of these methods are missing from
259
// Firefox/Chrome experimental implementations
260
"resolve" in local.Promise &&
261
"reject" in local.Promise &&
262
"all" in local.Promise &&
263
"race" in local.Promise &&
264
// Older version of the spec had a resolver object
265
// as the arg rather than a function
266
(function() {
267
var resolve;
268
new local.Promise(function(r) { resolve = r; });
269
return isFunction(resolve);
270
}());
271
272
if (!es6PromiseSupport) {
273
local.Promise = RSVPPromise;
274
}
275
}
276
277
__exports__.polyfill = polyfill;
278
});
279
define("promise/promise",
280
["./config","./utils","./all","./race","./resolve","./reject","./asap","exports"],
281
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __exports__) {
282
"use strict";
283
var config = __dependency1__.config;
284
var configure = __dependency1__.configure;
285
var objectOrFunction = __dependency2__.objectOrFunction;
286
var isFunction = __dependency2__.isFunction;
287
var now = __dependency2__.now;
288
var all = __dependency3__.all;
289
var race = __dependency4__.race;
290
var staticResolve = __dependency5__.resolve;
291
var staticReject = __dependency6__.reject;
292
var asap = __dependency7__.asap;
293
294
var counter = 0;
295
296
config.async = asap; // default async is asap;
297
298
function Promise(resolver) {
299
if (!isFunction(resolver)) {
300
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
301
}
302
303
if (!(this instanceof Promise)) {
304
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
305
}
306
307
this._subscribers = [];
308
309
invokeResolver(resolver, this);
310
}
311
312
function invokeResolver(resolver, promise) {
313
function resolvePromise(value) {
314
resolve(promise, value);
315
}
316
317
function rejectPromise(reason) {
318
reject(promise, reason);
319
}
320
321
try {
322
resolver(resolvePromise, rejectPromise);
323
} catch(e) {
324
rejectPromise(e);
325
}
326
}
327
328
function invokeCallback(settled, promise, callback, detail) {
329
var hasCallback = isFunction(callback),
330
value, error, succeeded, failed;
331
332
if (hasCallback) {
333
try {
334
value = callback(detail);
335
succeeded = true;
336
} catch(e) {
337
failed = true;
338
error = e;
339
}
340
} else {
341
value = detail;
342
succeeded = true;
343
}
344
345
if (handleThenable(promise, value)) {
346
return;
347
} else if (hasCallback && succeeded) {
348
resolve(promise, value);
349
} else if (failed) {
350
reject(promise, error);
351
} else if (settled === FULFILLED) {
352
resolve(promise, value);
353
} else if (settled === REJECTED) {
354
reject(promise, value);
355
}
356
}
357
358
var PENDING = void 0;
359
var SEALED = 0;
360
var FULFILLED = 1;
361
var REJECTED = 2;
362
363
function subscribe(parent, child, onFulfillment, onRejection) {
364
var subscribers = parent._subscribers;
365
var length = subscribers.length;
366
367
subscribers[length] = child;
368
subscribers[length + FULFILLED] = onFulfillment;
369
subscribers[length + REJECTED] = onRejection;
370
}
371
372
function publish(promise, settled) {
373
var child, callback, subscribers = promise._subscribers, detail = promise._detail;
374
375
for (var i = 0; i < subscribers.length; i += 3) {
376
child = subscribers[i];
377
callback = subscribers[i + settled];
378
379
invokeCallback(settled, child, callback, detail);
380
}
381
382
promise._subscribers = null;
383
}
384
385
Promise.prototype = {
386
constructor: Promise,
387
388
_state: undefined,
389
_detail: undefined,
390
_subscribers: undefined,
391
392
then: function(onFulfillment, onRejection) {
393
var promise = this;
394
395
var thenPromise = new this.constructor(function() {});
396
397
if (this._state) {
398
var callbacks = arguments;
399
config.async(function invokePromiseCallback() {
400
invokeCallback(promise._state, thenPromise, callbacks[promise._state - 1], promise._detail);
401
});
402
} else {
403
subscribe(this, thenPromise, onFulfillment, onRejection);
404
}
405
406
return thenPromise;
407
},
408
409
'catch': function(onRejection) {
410
return this.then(null, onRejection);
411
}
412
};
413
414
Promise.all = all;
415
Promise.race = race;
416
Promise.resolve = staticResolve;
417
Promise.reject = staticReject;
418
419
function handleThenable(promise, value) {
420
var then = null,
421
resolved;
422
423
try {
424
if (promise === value) {
425
throw new TypeError("A promises callback cannot return that same promise.");
426
}
427
428
if (objectOrFunction(value)) {
429
then = value.then;
430
431
if (isFunction(then)) {
432
then.call(value, function(val) {
433
if (resolved) { return true; }
434
resolved = true;
435
436
if (value !== val) {
437
resolve(promise, val);
438
} else {
439
fulfill(promise, val);
440
}
441
}, function(val) {
442
if (resolved) { return true; }
443
resolved = true;
444
445
reject(promise, val);
446
});
447
448
return true;
449
}
450
}
451
} catch (error) {
452
if (resolved) { return true; }
453
reject(promise, error);
454
return true;
455
}
456
457
return false;
458
}
459
460
function resolve(promise, value) {
461
if (promise === value) {
462
fulfill(promise, value);
463
} else if (!handleThenable(promise, value)) {
464
fulfill(promise, value);
465
}
466
}
467
468
function fulfill(promise, value) {
469
if (promise._state !== PENDING) { return; }
470
promise._state = SEALED;
471
promise._detail = value;
472
473
config.async(publishFulfillment, promise);
474
}
475
476
function reject(promise, reason) {
477
if (promise._state !== PENDING) { return; }
478
promise._state = SEALED;
479
promise._detail = reason;
480
481
config.async(publishRejection, promise);
482
}
483
484
function publishFulfillment(promise) {
485
publish(promise, promise._state = FULFILLED);
486
}
487
488
function publishRejection(promise) {
489
publish(promise, promise._state = REJECTED);
490
}
491
492
__exports__.Promise = Promise;
493
});
494
define("promise/race",
495
["./utils","exports"],
496
function(__dependency1__, __exports__) {
497
"use strict";
498
/* global toString */
499
var isArray = __dependency1__.isArray;
500
501
/**
502
`RSVP.race` allows you to watch a series of promises and act as soon as the
503
first promise given to the `promises` argument fulfills or rejects.
504
505
Example:
506
507
```javascript
508
var promise1 = new RSVP.Promise(function(resolve, reject){
509
setTimeout(function(){
510
resolve("promise 1");
511
}, 200);
512
});
513
514
var promise2 = new RSVP.Promise(function(resolve, reject){
515
setTimeout(function(){
516
resolve("promise 2");
517
}, 100);
518
});
519
520
RSVP.race([promise1, promise2]).then(function(result){
521
// result === "promise 2" because it was resolved before promise1
522
// was resolved.
523
});
524
```
525
526
`RSVP.race` is deterministic in that only the state of the first completed
527
promise matters. For example, even if other promises given to the `promises`
528
array argument are resolved, but the first completed promise has become
529
rejected before the other promises became fulfilled, the returned promise
530
will become rejected:
531
532
```javascript
533
var promise1 = new RSVP.Promise(function(resolve, reject){
534
setTimeout(function(){
535
resolve("promise 1");
536
}, 200);
537
});
538
539
var promise2 = new RSVP.Promise(function(resolve, reject){
540
setTimeout(function(){
541
reject(new Error("promise 2"));
542
}, 100);
543
});
544
545
RSVP.race([promise1, promise2]).then(function(result){
546
// Code here never runs because there are rejected promises!
547
}, function(reason){
548
// reason.message === "promise2" because promise 2 became rejected before
549
// promise 1 became fulfilled
550
});
551
```
552
553
@method race
554
@for RSVP
555
@param {Array} promises array of promises to observe
556
@param {String} label optional string for describing the promise returned.
557
Useful for tooling.
558
@return {Promise} a promise that becomes fulfilled with the value the first
559
completed promises is resolved with if the first completed promise was
560
fulfilled, or rejected with the reason that the first completed promise
561
was rejected with.
562
*/
563
function race(promises) {
564
/*jshint validthis:true */
565
var Promise = this;
566
567
if (!isArray(promises)) {
568
throw new TypeError('You must pass an array to race.');
569
}
570
return new Promise(function(resolve, reject) {
571
var results = [], promise;
572
573
for (var i = 0; i < promises.length; i++) {
574
promise = promises[i];
575
576
if (promise && typeof promise.then === 'function') {
577
promise.then(resolve, reject);
578
} else {
579
resolve(promise);
580
}
581
}
582
});
583
}
584
585
__exports__.race = race;
586
});
587
define("promise/reject",
588
["exports"],
589
function(__exports__) {
590
"use strict";
591
/**
592
`RSVP.reject` returns a promise that will become rejected with the passed
593
`reason`. `RSVP.reject` is essentially shorthand for the following:
594
595
```javascript
596
var promise = new RSVP.Promise(function(resolve, reject){
597
reject(new Error('WHOOPS'));
598
});
599
600
promise.then(function(value){
601
// Code here doesn't run because the promise is rejected!
602
}, function(reason){
603
// reason.message === 'WHOOPS'
604
});
605
```
606
607
Instead of writing the above, your code now simply becomes the following:
608
609
```javascript
610
var promise = RSVP.reject(new Error('WHOOPS'));
611
612
promise.then(function(value){
613
// Code here doesn't run because the promise is rejected!
614
}, function(reason){
615
// reason.message === 'WHOOPS'
616
});
617
```
618
619
@method reject
620
@for RSVP
621
@param {Any} reason value that the returned promise will be rejected with.
622
@param {String} label optional string for identifying the returned promise.
623
Useful for tooling.
624
@return {Promise} a promise that will become rejected with the given
625
`reason`.
626
*/
627
function reject(reason) {
628
/*jshint validthis:true */
629
var Promise = this;
630
631
return new Promise(function (resolve, reject) {
632
reject(reason);
633
});
634
}
635
636
__exports__.reject = reject;
637
});
638
define("promise/resolve",
639
["exports"],
640
function(__exports__) {
641
"use strict";
642
function resolve(value) {
643
/*jshint validthis:true */
644
if (value && typeof value === 'object' && value.constructor === this) {
645
return value;
646
}
647
648
var Promise = this;
649
650
return new Promise(function(resolve) {
651
resolve(value);
652
});
653
}
654
655
__exports__.resolve = resolve;
656
});
657
define("promise/utils",
658
["exports"],
659
function(__exports__) {
660
"use strict";
661
function objectOrFunction(x) {
662
return isFunction(x) || (typeof x === "object" && x !== null);
663
}
664
665
function isFunction(x) {
666
return typeof x === "function";
667
}
668
669
function isArray(x) {
670
return Object.prototype.toString.call(x) === "[object Array]";
671
}
672
673
// Date.now is not available in browsers < IE9
674
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
675
var now = Date.now || function() { return new Date().getTime(); };
676
677
678
__exports__.objectOrFunction = objectOrFunction;
679
__exports__.isFunction = isFunction;
680
__exports__.isArray = isArray;
681
__exports__.now = now;
682
});
683
requireModule('promise/polyfill').polyfill();
684
}());
685