UNPKG

16.1 kBJavaScriptView Raw
1/*
2 Copyright (c) Microsoft Corporation. All rights reserved.
3*/
4
5/*
6 Your use of this file is governed by the Microsoft Services Agreement http://go.microsoft.com/fwlink/?LinkId=266419.
7*/
8
9/*
10* @overview es6-promise - a tiny implementation of Promises/A+.
11* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
12* @license Licensed under MIT license
13* See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
14* @version 2.3.0
15*/
16
17
18// Sources:
19// osfweb: none
20// runtime: 16.0\13326.10000
21// core: 16.0\13326.10000
22// host: 16.0.13327.34950
23
24
25
26var __extends = (this && this.__extends) || (function () {
27 var extendStatics = function (d, b) {
28 extendStatics = Object.setPrototypeOf ||
29 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30 function (d, b) { for (var p in b)
31 if (b.hasOwnProperty(p))
32 d[p] = b[p]; };
33 return extendStatics(d, b);
34 };
35 return function (d, b) {
36 extendStatics(d, b);
37 function __() { this.constructor = d; }
38 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
39 };
40})();
41var OfficeExtension;
42(function (OfficeExtension) {
43 var _Internal;
44 (function (_Internal) {
45 _Internal.OfficeRequire = function () {
46 return null;
47 }();
48 })(_Internal = OfficeExtension._Internal || (OfficeExtension._Internal = {}));
49 (function (_Internal) {
50 var PromiseImpl;
51 (function (PromiseImpl) {
52 function Init() {
53 return (function () {
54 "use strict";
55 function lib$es6$promise$utils$$objectOrFunction(x) {
56 return typeof x === 'function' || (typeof x === 'object' && x !== null);
57 }
58 function lib$es6$promise$utils$$isFunction(x) {
59 return typeof x === 'function';
60 }
61 function lib$es6$promise$utils$$isMaybeThenable(x) {
62 return typeof x === 'object' && x !== null;
63 }
64 var lib$es6$promise$utils$$_isArray;
65 if (!Array.isArray) {
66 lib$es6$promise$utils$$_isArray = function (x) {
67 return Object.prototype.toString.call(x) === '[object Array]';
68 };
69 }
70 else {
71 lib$es6$promise$utils$$_isArray = Array.isArray;
72 }
73 var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
74 var lib$es6$promise$asap$$len = 0;
75 var lib$es6$promise$asap$$toString = {}.toString;
76 var lib$es6$promise$asap$$vertxNext;
77 var lib$es6$promise$asap$$customSchedulerFn;
78 var lib$es6$promise$asap$$asap = function asap(callback, arg) {
79 lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
80 lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
81 lib$es6$promise$asap$$len += 2;
82 if (lib$es6$promise$asap$$len === 2) {
83 if (lib$es6$promise$asap$$customSchedulerFn) {
84 lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
85 }
86 else {
87 lib$es6$promise$asap$$scheduleFlush();
88 }
89 }
90 };
91 function lib$es6$promise$asap$$setScheduler(scheduleFn) {
92 lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
93 }
94 function lib$es6$promise$asap$$setAsap(asapFn) {
95 lib$es6$promise$asap$$asap = asapFn;
96 }
97 var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
98 var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
99 var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
100 var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
101 var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
102 typeof importScripts !== 'undefined' &&
103 typeof MessageChannel !== 'undefined';
104 function lib$es6$promise$asap$$useNextTick() {
105 var nextTick = process.nextTick;
106 var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
107 if (Array.isArray(version) && version[1] === '0' && version[2] === '10') {
108 nextTick = window.setImmediate;
109 }
110 return function () {
111 nextTick(lib$es6$promise$asap$$flush);
112 };
113 }
114 function lib$es6$promise$asap$$useVertxTimer() {
115 return function () {
116 lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
117 };
118 }
119 function lib$es6$promise$asap$$useMutationObserver() {
120 var iterations = 0;
121 var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
122 var node = document.createTextNode('');
123 observer.observe(node, { characterData: true });
124 return function () {
125 node.data = (iterations = ++iterations % 2);
126 };
127 }
128 function lib$es6$promise$asap$$useMessageChannel() {
129 var channel = new MessageChannel();
130 channel.port1.onmessage = lib$es6$promise$asap$$flush;
131 return function () {
132 channel.port2.postMessage(0);
133 };
134 }
135 function lib$es6$promise$asap$$useSetTimeout() {
136 return function () {
137 setTimeout(lib$es6$promise$asap$$flush, 1);
138 };
139 }
140 var lib$es6$promise$asap$$queue = new Array(1000);
141 function lib$es6$promise$asap$$flush() {
142 for (var i = 0; i < lib$es6$promise$asap$$len; i += 2) {
143 var callback = lib$es6$promise$asap$$queue[i];
144 var arg = lib$es6$promise$asap$$queue[i + 1];
145 callback(arg);
146 lib$es6$promise$asap$$queue[i] = undefined;
147 lib$es6$promise$asap$$queue[i + 1] = undefined;
148 }
149 lib$es6$promise$asap$$len = 0;
150 }
151 var lib$es6$promise$asap$$scheduleFlush;
152 if (lib$es6$promise$asap$$isNode) {
153 lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
154 }
155 else if (lib$es6$promise$asap$$isWorker) {
156 lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
157 }
158 else {
159 lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
160 }
161 function lib$es6$promise$$internal$$noop() { }
162 var lib$es6$promise$$internal$$PENDING = void 0;
163 var lib$es6$promise$$internal$$FULFILLED = 1;
164 var lib$es6$promise$$internal$$REJECTED = 2;
165 var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
166 function lib$es6$promise$$internal$$selfFullfillment() {
167 return new TypeError("You cannot resolve a promise with itself");
168 }
169 function lib$es6$promise$$internal$$cannotReturnOwn() {
170 return new TypeError('A promises callback cannot return that same promise.');
171 }
172 function lib$es6$promise$$internal$$getThen(promise) {
173 try {
174 return promise.then;
175 }
176 catch (error) {
177 lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
178 return lib$es6$promise$$internal$$GET_THEN_ERROR;
179 }
180 }
181 function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
182 try {
183 then.call(value, fulfillmentHandler, rejectionHandler);
184 }
185 catch (e) {
186 return e;
187 }
188 }
189 function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
190 lib$es6$promise$asap$$asap(function (promise) {
191 var sealed = false;
192 var error = lib$es6$promise$$internal$$tryThen(then, thenable, function (value) {
193 if (sealed) {
194 return;
195 }
196 sealed = true;
197 if (thenable !== value) {
198 lib$es6$promise$$internal$$resolve(promise, value);
199 }
200 else {
201 lib$es6$promise$$internal$$fulfill(promise, value);
202 }
203 }, function (reason) {
204 if (sealed) {
205 return;
206 }
207 sealed = true;
208 lib$es6$promise$$internal$$reject(promise, reason);
209 }, 'Settle: ' + (promise._label || ' unknown promise'));
210 if (!sealed && error) {
211 sealed = true;
212 lib$es6$promise$$internal$$reject(promise, error);
213 }
214 }, promise);
215 }
216 function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
217 if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
218 lib$es6$promise$$internal$$fulfill(promise, thenable._result);
219 }
220 else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
221 lib$es6$promise$$internal$$reject(promise, thenable._result);
222 }
223 else {
224 lib$es6$promise$$internal$$subscribe(thenable, undefined, function (value) {
225 lib$es6$promise$$internal$$resolve(promise, value);
226 }, function (reason) {
227 lib$es6$promise$$internal$$reject(promise, reason);
228 });
229 }
230 }
231 function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
232 if (maybeThenable.constructor === promise.constructor) {
233 lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
234 }
235 else {
236 var then = lib$es6$promise$$internal$$getThen(maybeThenable);
237 if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
238 lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
239 }
240 else if (then === undefined) {
241 lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
242 }
243 else if (lib$es6$promise$utils$$isFunction(then)) {
244 lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
245 }
246 else {
247 lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
248 }
249 }
250 }
251 function lib$es6$promise$$internal$$resolve(promise, value) {
252 if (promise === value) {
253 lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFullfillment());
254 }
255 else if (lib$es6$promise$utils$$objectOrFunction(value)) {
256 lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
257 }
258 else {
259 lib$es6$promise$$internal$$fulfill(promise, value);
260 }
261 }
262 function lib$es6$promise$$internal$$publishRejection(promise) {
263 if (promise._onerror) {
264 promise._onerror(promise._result);
265 }
266 lib$es6$promise$$internal$$publish(promise);
267 }
268 function lib$es6$promise$$internal$$fulfill(promise, value) {
269 if (promise._state !== lib$es6$promise$$internal$$PENDING) {
270 return;
271 }
272 promise._result = value;
273 promise._state = lib$es6$promise$$internal$$FULFILLED;
274 if (promise._subscribers.length !== 0) {
275 lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
276 }
277 }
278 function lib$es6$promise$$internal$$reject(promise, reason) {
279 if (promise._state !== lib$es6$promise$$internal$$PENDING) {
280 return;
281 }
282 promise._state = lib$es6$promise$$internal$$REJECTED;
283 promise._result = reason;
284 lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
285 }
286 function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
287 var subscribers = parent._subscribers;
288 var length = subscribers.length;
289 parent._onerror = null;
290 subscribers[length] = child;
291 subscribers[length + lib$es6$promise$$internal$$FULF
\No newline at end of file