Front end of the Slack clone application.

lie.polyfill.js 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
  2. 'use strict';
  3. var immediate = _dereq_('immediate');
  4. /* istanbul ignore next */
  5. function INTERNAL() {}
  6. var handlers = {};
  7. var REJECTED = ['REJECTED'];
  8. var FULFILLED = ['FULFILLED'];
  9. var PENDING = ['PENDING'];
  10. module.exports = exports = Promise;
  11. function Promise(resolver) {
  12. if (typeof resolver !== 'function') {
  13. throw new TypeError('resolver must be a function');
  14. }
  15. this.state = PENDING;
  16. this.queue = [];
  17. this.outcome = void 0;
  18. if (resolver !== INTERNAL) {
  19. safelyResolveThenable(this, resolver);
  20. }
  21. }
  22. Promise.prototype["catch"] = function (onRejected) {
  23. return this.then(null, onRejected);
  24. };
  25. Promise.prototype.then = function (onFulfilled, onRejected) {
  26. if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||
  27. typeof onRejected !== 'function' && this.state === REJECTED) {
  28. return this;
  29. }
  30. var promise = new this.constructor(INTERNAL);
  31. if (this.state !== PENDING) {
  32. var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
  33. unwrap(promise, resolver, this.outcome);
  34. } else {
  35. this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
  36. }
  37. return promise;
  38. };
  39. function QueueItem(promise, onFulfilled, onRejected) {
  40. this.promise = promise;
  41. if (typeof onFulfilled === 'function') {
  42. this.onFulfilled = onFulfilled;
  43. this.callFulfilled = this.otherCallFulfilled;
  44. }
  45. if (typeof onRejected === 'function') {
  46. this.onRejected = onRejected;
  47. this.callRejected = this.otherCallRejected;
  48. }
  49. }
  50. QueueItem.prototype.callFulfilled = function (value) {
  51. handlers.resolve(this.promise, value);
  52. };
  53. QueueItem.prototype.otherCallFulfilled = function (value) {
  54. unwrap(this.promise, this.onFulfilled, value);
  55. };
  56. QueueItem.prototype.callRejected = function (value) {
  57. handlers.reject(this.promise, value);
  58. };
  59. QueueItem.prototype.otherCallRejected = function (value) {
  60. unwrap(this.promise, this.onRejected, value);
  61. };
  62. function unwrap(promise, func, value) {
  63. immediate(function () {
  64. var returnValue;
  65. try {
  66. returnValue = func(value);
  67. } catch (e) {
  68. return handlers.reject(promise, e);
  69. }
  70. if (returnValue === promise) {
  71. handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));
  72. } else {
  73. handlers.resolve(promise, returnValue);
  74. }
  75. });
  76. }
  77. handlers.resolve = function (self, value) {
  78. var result = tryCatch(getThen, value);
  79. if (result.status === 'error') {
  80. return handlers.reject(self, result.value);
  81. }
  82. var thenable = result.value;
  83. if (thenable) {
  84. safelyResolveThenable(self, thenable);
  85. } else {
  86. self.state = FULFILLED;
  87. self.outcome = value;
  88. var i = -1;
  89. var len = self.queue.length;
  90. while (++i < len) {
  91. self.queue[i].callFulfilled(value);
  92. }
  93. }
  94. return self;
  95. };
  96. handlers.reject = function (self, error) {
  97. self.state = REJECTED;
  98. self.outcome = error;
  99. var i = -1;
  100. var len = self.queue.length;
  101. while (++i < len) {
  102. self.queue[i].callRejected(error);
  103. }
  104. return self;
  105. };
  106. function getThen(obj) {
  107. // Make sure we only access the accessor once as required by the spec
  108. var then = obj && obj.then;
  109. if (obj && typeof obj === 'object' && typeof then === 'function') {
  110. return function appyThen() {
  111. then.apply(obj, arguments);
  112. };
  113. }
  114. }
  115. function safelyResolveThenable(self, thenable) {
  116. // Either fulfill, reject or reject with error
  117. var called = false;
  118. function onError(value) {
  119. if (called) {
  120. return;
  121. }
  122. called = true;
  123. handlers.reject(self, value);
  124. }
  125. function onSuccess(value) {
  126. if (called) {
  127. return;
  128. }
  129. called = true;
  130. handlers.resolve(self, value);
  131. }
  132. function tryToUnwrap() {
  133. thenable(onSuccess, onError);
  134. }
  135. var result = tryCatch(tryToUnwrap);
  136. if (result.status === 'error') {
  137. onError(result.value);
  138. }
  139. }
  140. function tryCatch(func, value) {
  141. var out = {};
  142. try {
  143. out.value = func(value);
  144. out.status = 'success';
  145. } catch (e) {
  146. out.status = 'error';
  147. out.value = e;
  148. }
  149. return out;
  150. }
  151. exports.resolve = resolve;
  152. function resolve(value) {
  153. if (value instanceof this) {
  154. return value;
  155. }
  156. return handlers.resolve(new this(INTERNAL), value);
  157. }
  158. exports.reject = reject;
  159. function reject(reason) {
  160. var promise = new this(INTERNAL);
  161. return handlers.reject(promise, reason);
  162. }
  163. exports.all = all;
  164. function all(iterable) {
  165. var self = this;
  166. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  167. return this.reject(new TypeError('must be an array'));
  168. }
  169. var len = iterable.length;
  170. var called = false;
  171. if (!len) {
  172. return this.resolve([]);
  173. }
  174. var values = new Array(len);
  175. var resolved = 0;
  176. var i = -1;
  177. var promise = new this(INTERNAL);
  178. while (++i < len) {
  179. allResolver(iterable[i], i);
  180. }
  181. return promise;
  182. function allResolver(value, i) {
  183. self.resolve(value).then(resolveFromAll, function (error) {
  184. if (!called) {
  185. called = true;
  186. handlers.reject(promise, error);
  187. }
  188. });
  189. function resolveFromAll(outValue) {
  190. values[i] = outValue;
  191. if (++resolved === len && !called) {
  192. called = true;
  193. handlers.resolve(promise, values);
  194. }
  195. }
  196. }
  197. }
  198. exports.race = race;
  199. function race(iterable) {
  200. var self = this;
  201. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  202. return this.reject(new TypeError('must be an array'));
  203. }
  204. var len = iterable.length;
  205. var called = false;
  206. if (!len) {
  207. return this.resolve([]);
  208. }
  209. var i = -1;
  210. var promise = new this(INTERNAL);
  211. while (++i < len) {
  212. resolver(iterable[i]);
  213. }
  214. return promise;
  215. function resolver(value) {
  216. self.resolve(value).then(function (response) {
  217. if (!called) {
  218. called = true;
  219. handlers.resolve(promise, response);
  220. }
  221. }, function (error) {
  222. if (!called) {
  223. called = true;
  224. handlers.reject(promise, error);
  225. }
  226. });
  227. }
  228. }
  229. },{"immediate":2}],2:[function(_dereq_,module,exports){
  230. (function (global){
  231. 'use strict';
  232. var Mutation = global.MutationObserver || global.WebKitMutationObserver;
  233. var scheduleDrain;
  234. {
  235. if (Mutation) {
  236. var called = 0;
  237. var observer = new Mutation(nextTick);
  238. var element = global.document.createTextNode('');
  239. observer.observe(element, {
  240. characterData: true
  241. });
  242. scheduleDrain = function () {
  243. element.data = (called = ++called % 2);
  244. };
  245. } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
  246. var channel = new global.MessageChannel();
  247. channel.port1.onmessage = nextTick;
  248. scheduleDrain = function () {
  249. channel.port2.postMessage(0);
  250. };
  251. } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
  252. scheduleDrain = function () {
  253. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  254. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  255. var scriptEl = global.document.createElement('script');
  256. scriptEl.onreadystatechange = function () {
  257. nextTick();
  258. scriptEl.onreadystatechange = null;
  259. scriptEl.parentNode.removeChild(scriptEl);
  260. scriptEl = null;
  261. };
  262. global.document.documentElement.appendChild(scriptEl);
  263. };
  264. } else {
  265. scheduleDrain = function () {
  266. setTimeout(nextTick, 0);
  267. };
  268. }
  269. }
  270. var draining;
  271. var queue = [];
  272. //named nextTick for less confusing stack traces
  273. function nextTick() {
  274. draining = true;
  275. var i, oldQueue;
  276. var len = queue.length;
  277. while (len) {
  278. oldQueue = queue;
  279. queue = [];
  280. i = -1;
  281. while (++i < len) {
  282. oldQueue[i]();
  283. }
  284. len = queue.length;
  285. }
  286. draining = false;
  287. }
  288. module.exports = immediate;
  289. function immediate(task) {
  290. if (queue.push(task) === 1 && !draining) {
  291. scheduleDrain();
  292. }
  293. }
  294. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  295. },{}],3:[function(_dereq_,module,exports){
  296. (function (global){
  297. 'use strict';
  298. if (typeof global.Promise !== 'function') {
  299. global.Promise = _dereq_('./lib');
  300. }
  301. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  302. },{"./lib":1}]},{},[3]);