a zip code crypto-currency system good for red ONLY

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. import { HttpBackend, HttpClientModule, HttpErrorResponse, HttpEventType, HttpHeaders, HttpResponse } from '@angular/common/http';
  7. import { Injectable, NgModule } from '@angular/core';
  8. import { Observable } from 'rxjs/Observable';
  9. /**
  10. * @fileoverview added by tsickle
  11. * @suppress {checkTypes} checked by tsc
  12. */
  13. /**
  14. * @license
  15. * Copyright Google Inc. All Rights Reserved.
  16. *
  17. * Use of this source code is governed by an MIT-style license that can be
  18. * found in the LICENSE file at https://angular.io/license
  19. */
  20. /**
  21. * Defines a matcher for requests based on URL, method, or both.
  22. *
  23. * \@stable
  24. * @record
  25. */
  26. /**
  27. * Controller to be injected into tests, that allows for mocking and flushing
  28. * of requests.
  29. *
  30. * \@stable
  31. * @abstract
  32. */
  33. class HttpTestingController {
  34. }
  35. /**
  36. * @fileoverview added by tsickle
  37. * @suppress {checkTypes} checked by tsc
  38. */
  39. /**
  40. * @license
  41. * Copyright Google Inc. All Rights Reserved.
  42. *
  43. * Use of this source code is governed by an MIT-style license that can be
  44. * found in the LICENSE file at https://angular.io/license
  45. */
  46. /**
  47. * A mock requests that was received and is ready to be answered.
  48. *
  49. * This interface allows access to the underlying `HttpRequest`, and allows
  50. * responding with `HttpEvent`s or `HttpErrorResponse`s.
  51. *
  52. * \@stable
  53. */
  54. class TestRequest {
  55. /**
  56. * @param {?} request
  57. * @param {?} observer
  58. */
  59. constructor(request, observer) {
  60. this.request = request;
  61. this.observer = observer;
  62. /**
  63. * \@internal set by `HttpClientTestingBackend`
  64. */
  65. this._cancelled = false;
  66. }
  67. /**
  68. * Whether the request was cancelled after it was sent.
  69. * @return {?}
  70. */
  71. get cancelled() { return this._cancelled; }
  72. /**
  73. * Resolve the request by returning a body plus additional HTTP information (such as response
  74. * headers) if provided.
  75. *
  76. * Both successful and unsuccessful responses can be delivered via `flush()`.
  77. * @param {?} body
  78. * @param {?=} opts
  79. * @return {?}
  80. */
  81. flush(body, opts = {}) {
  82. if (this.cancelled) {
  83. throw new Error(`Cannot flush a cancelled request.`);
  84. }
  85. const /** @type {?} */ url = this.request.urlWithParams;
  86. const /** @type {?} */ headers = (opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers);
  87. body = _maybeConvertBody(this.request.responseType, body);
  88. let /** @type {?} */ statusText = opts.statusText;
  89. let /** @type {?} */ status = opts.status !== undefined ? opts.status : 200;
  90. if (opts.status === undefined) {
  91. if (body === null) {
  92. status = 204;
  93. statusText = statusText || 'No Content';
  94. }
  95. else {
  96. statusText = statusText || 'OK';
  97. }
  98. }
  99. if (statusText === undefined) {
  100. throw new Error('statusText is required when setting a custom status.');
  101. }
  102. if (status >= 200 && status < 300) {
  103. this.observer.next(new HttpResponse({ body, headers, status, statusText, url }));
  104. this.observer.complete();
  105. }
  106. else {
  107. this.observer.error(new HttpErrorResponse({ error: body, headers, status, statusText, url }));
  108. }
  109. }
  110. /**
  111. * Resolve the request by returning an `ErrorEvent` (e.g. simulating a network failure).
  112. * @param {?} error
  113. * @param {?=} opts
  114. * @return {?}
  115. */
  116. error(error, opts = {}) {
  117. if (this.cancelled) {
  118. throw new Error(`Cannot return an error for a cancelled request.`);
  119. }
  120. if (opts.status && opts.status >= 200 && opts.status < 300) {
  121. throw new Error(`error() called with a successful status.`);
  122. }
  123. const /** @type {?} */ headers = (opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers);
  124. this.observer.error(new HttpErrorResponse({
  125. error,
  126. headers,
  127. status: opts.status || 0,
  128. statusText: opts.statusText || '',
  129. url: this.request.urlWithParams,
  130. }));
  131. }
  132. /**
  133. * Deliver an arbitrary `HttpEvent` (such as a progress event) on the response stream for this
  134. * request.
  135. * @param {?} event
  136. * @return {?}
  137. */
  138. event(event) {
  139. if (this.cancelled) {
  140. throw new Error(`Cannot send events to a cancelled request.`);
  141. }
  142. this.observer.next(event);
  143. }
  144. }
  145. /**
  146. * Helper function to convert a response body to an ArrayBuffer.
  147. * @param {?} body
  148. * @return {?}
  149. */
  150. function _toArrayBufferBody(body) {
  151. if (typeof ArrayBuffer === 'undefined') {
  152. throw new Error('ArrayBuffer responses are not supported on this platform.');
  153. }
  154. if (body instanceof ArrayBuffer) {
  155. return body;
  156. }
  157. throw new Error('Automatic conversion to ArrayBuffer is not supported for response type.');
  158. }
  159. /**
  160. * Helper function to convert a response body to a Blob.
  161. * @param {?} body
  162. * @return {?}
  163. */
  164. function _toBlob(body) {
  165. if (typeof Blob === 'undefined') {
  166. throw new Error('Blob responses are not supported on this platform.');
  167. }
  168. if (body instanceof Blob) {
  169. return body;
  170. }
  171. if (ArrayBuffer && body instanceof ArrayBuffer) {
  172. return new Blob([body]);
  173. }
  174. throw new Error('Automatic conversion to Blob is not supported for response type.');
  175. }
  176. /**
  177. * Helper function to convert a response body to JSON data.
  178. * @param {?} body
  179. * @param {?=} format
  180. * @return {?}
  181. */
  182. function _toJsonBody(body, format = 'JSON') {
  183. if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {
  184. throw new Error(`Automatic conversion to ${format} is not supported for ArrayBuffers.`);
  185. }
  186. if (typeof Blob !== 'undefined' && body instanceof Blob) {
  187. throw new Error(`Automatic conversion to ${format} is not supported for Blobs.`);
  188. }
  189. if (typeof body === 'string' || typeof body === 'number' || typeof body === 'object' ||
  190. Array.isArray(body)) {
  191. return body;
  192. }
  193. throw new Error(`Automatic conversion to ${format} is not supported for response type.`);
  194. }
  195. /**
  196. * Helper function to convert a response body to a string.
  197. * @param {?} body
  198. * @return {?}
  199. */
  200. function _toTextBody(body) {
  201. if (typeof body === 'string') {
  202. return body;
  203. }
  204. if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {
  205. throw new Error('Automatic conversion to text is not supported for ArrayBuffers.');
  206. }
  207. if (typeof Blob !== 'undefined' && body instanceof Blob) {
  208. throw new Error('Automatic conversion to text is not supported for Blobs.');
  209. }
  210. return JSON.stringify(_toJsonBody(body, 'text'));
  211. }
  212. /**
  213. * Convert a response body to the requested type.
  214. * @param {?} responseType
  215. * @param {?} body
  216. * @return {?}
  217. */
  218. function _maybeConvertBody(responseType, body) {
  219. if (body === null) {
  220. return null;
  221. }
  222. switch (responseType) {
  223. case 'arraybuffer':
  224. return _toArrayBufferBody(body);
  225. case 'blob':
  226. return _toBlob(body);
  227. case 'json':
  228. return _toJsonBody(body);
  229. case 'text':
  230. return _toTextBody(body);
  231. default:
  232. throw new Error(`Unsupported responseType: ${responseType}`);
  233. }
  234. }
  235. /**
  236. * @fileoverview added by tsickle
  237. * @suppress {checkTypes} checked by tsc
  238. */
  239. /**
  240. * @license
  241. * Copyright Google Inc. All Rights Reserved.
  242. *
  243. * Use of this source code is governed by an MIT-style license that can be
  244. * found in the LICENSE file at https://angular.io/license
  245. */
  246. /**
  247. * A testing backend for `HttpClient` which both acts as an `HttpBackend`
  248. * and as the `HttpTestingController`.
  249. *
  250. * `HttpClientTestingBackend` works by keeping a list of all open requests.
  251. * As requests come in, they're added to the list. Users can assert that specific
  252. * requests were made and then flush them. In the end, a verify() method asserts
  253. * that no unexpected requests were made.
  254. *
  255. * \@stable
  256. */
  257. class HttpClientTestingBackend {
  258. constructor() {
  259. /**
  260. * List of pending requests which have not yet been expected.
  261. */
  262. this.open = [];
  263. }
  264. /**
  265. * Handle an incoming request by queueing it in the list of open requests.
  266. * @param {?} req
  267. * @return {?}
  268. */
  269. handle(req) {
  270. return new Observable((observer) => {
  271. const /** @type {?} */ testReq = new TestRequest(req, observer);
  272. this.open.push(testReq);
  273. observer.next(/** @type {?} */ ({ type: HttpEventType.Sent }));
  274. return () => { testReq._cancelled = true; };
  275. });
  276. }
  277. /**
  278. * Helper function to search for requests in the list of open requests.
  279. * @param {?} match
  280. * @return {?}
  281. */
  282. _match(match) {
  283. if (typeof match === 'string') {
  284. return this.open.filter(testReq => testReq.request.urlWithParams === match);
  285. }
  286. else if (typeof match === 'function') {
  287. return this.open.filter(testReq => match(testReq.request));
  288. }
  289. else {
  290. return this.open.filter(testReq => (!match.method || testReq.request.method === match.method.toUpperCase()) &&
  291. (!match.url || testReq.request.urlWithParams === match.url));
  292. }
  293. }
  294. /**
  295. * Search for requests in the list of open requests, and return all that match
  296. * without asserting anything about the number of matches.
  297. * @param {?} match
  298. * @return {?}
  299. */
  300. match(match) {
  301. const /** @type {?} */ results = this._match(match);
  302. results.forEach(result => {
  303. const /** @type {?} */ index = this.open.indexOf(result);
  304. if (index !== -1) {
  305. this.open.splice(index, 1);
  306. }
  307. });
  308. return results;
  309. }
  310. /**
  311. * Expect that a single outstanding request matches the given matcher, and return
  312. * it.
  313. *
  314. * Requests returned through this API will no longer be in the list of open requests,
  315. * and thus will not match twice.
  316. * @param {?} match
  317. * @param {?=} description
  318. * @return {?}
  319. */
  320. expectOne(match, description) {
  321. description = description || this.descriptionFromMatcher(match);
  322. const /** @type {?} */ matches = this.match(match);
  323. if (matches.length > 1) {
  324. throw new Error(`Expected one matching request for criteria "${description}", found ${matches.length} requests.`);
  325. }
  326. if (matches.length === 0) {
  327. throw new Error(`Expected one matching request for criteria "${description}", found none.`);
  328. }
  329. return matches[0];
  330. }
  331. /**
  332. * Expect that no outstanding requests match the given matcher, and throw an error
  333. * if any do.
  334. * @param {?} match
  335. * @param {?=} description
  336. * @return {?}
  337. */
  338. expectNone(match, description) {
  339. description = description || this.descriptionFromMatcher(match);
  340. const /** @type {?} */ matches = this.match(match);
  341. if (matches.length > 0) {
  342. throw new Error(`Expected zero matching requests for criteria "${description}", found ${matches.length}.`);
  343. }
  344. }
  345. /**
  346. * Validate that there are no outstanding requests.
  347. * @param {?=} opts
  348. * @return {?}
  349. */
  350. verify(opts = {}) {
  351. let /** @type {?} */ open = this.open;
  352. // It's possible that some requests may be cancelled, and this is expected.
  353. // The user can ask to ignore open requests which have been cancelled.
  354. if (opts.ignoreCancelled) {
  355. open = open.filter(testReq => !testReq.cancelled);
  356. }
  357. if (open.length > 0) {
  358. // Show the methods and URLs of open requests in the error, for convenience.
  359. const /** @type {?} */ requests = open.map(testReq => {
  360. const /** @type {?} */ url = testReq.request.urlWithParams.split('?')[0];
  361. const /** @type {?} */ method = testReq.request.method;
  362. return `${method} ${url}`;
  363. })
  364. .join(', ');
  365. throw new Error(`Expected no open requests, found ${open.length}: ${requests}`);
  366. }
  367. }
  368. /**
  369. * @param {?} matcher
  370. * @return {?}
  371. */
  372. descriptionFromMatcher(matcher) {
  373. if (typeof matcher === 'string') {
  374. return `Match URL: ${matcher}`;
  375. }
  376. else if (typeof matcher === 'object') {
  377. const /** @type {?} */ method = matcher.method || '(any)';
  378. const /** @type {?} */ url = matcher.url || '(any)';
  379. return `Match method: ${method}, URL: ${url}`;
  380. }
  381. else {
  382. return `Match by function: ${matcher.name}`;
  383. }
  384. }
  385. }
  386. HttpClientTestingBackend.decorators = [
  387. { type: Injectable },
  388. ];
  389. /** @nocollapse */
  390. HttpClientTestingBackend.ctorParameters = () => [];
  391. /**
  392. * @fileoverview added by tsickle
  393. * @suppress {checkTypes} checked by tsc
  394. */
  395. /**
  396. * @license
  397. * Copyright Google Inc. All Rights Reserved.
  398. *
  399. * Use of this source code is governed by an MIT-style license that can be
  400. * found in the LICENSE file at https://angular.io/license
  401. */
  402. /**
  403. * Configures `HttpClientTestingBackend` as the `HttpBackend` used by `HttpClient`.
  404. *
  405. * Inject `HttpTestingController` to expect and flush requests in your tests.
  406. *
  407. * \@stable
  408. */
  409. class HttpClientTestingModule {
  410. }
  411. HttpClientTestingModule.decorators = [
  412. { type: NgModule, args: [{
  413. imports: [
  414. HttpClientModule,
  415. ],
  416. providers: [
  417. HttpClientTestingBackend,
  418. { provide: HttpBackend, useExisting: HttpClientTestingBackend },
  419. { provide: HttpTestingController, useExisting: HttpClientTestingBackend },
  420. ],
  421. },] },
  422. ];
  423. /** @nocollapse */
  424. HttpClientTestingModule.ctorParameters = () => [];
  425. /**
  426. * @fileoverview added by tsickle
  427. * @suppress {checkTypes} checked by tsc
  428. */
  429. /**
  430. * @license
  431. * Copyright Google Inc. All Rights Reserved.
  432. *
  433. * Use of this source code is governed by an MIT-style license that can be
  434. * found in the LICENSE file at https://angular.io/license
  435. */
  436. /**
  437. * @fileoverview added by tsickle
  438. * @suppress {checkTypes} checked by tsc
  439. */
  440. /**
  441. * Generated bundle index. Do not edit.
  442. */
  443. export { HttpTestingController, HttpClientTestingModule, TestRequest, HttpClientTestingBackend as ɵa };
  444. //# sourceMappingURL=testing.js.map