source: frontend/node_modules/workbox-streams/concatenateToResponse.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 Copyright 2018 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8import { createHeaders } from './utils/createHeaders.js';
9import { concatenate } from './concatenate.js';
10import './_version.js';
11/**
12 * Takes multiple source Promises, each of which could resolve to a Response, a
13 * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit),
14 * along with a
15 * [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit).
16 *
17 * Returns an object exposing a Response whose body consists of each individual
18 * stream's data returned in sequence, along with a Promise which signals when
19 * the stream is finished (useful for passing to a FetchEvent's waitUntil()).
20 *
21 * @param {Array<Promise<workbox-streams.StreamSource>>} sourcePromises
22 * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,
23 * `'text/html'` will be used by default.
24 * @return {Object<{done: Promise, response: Response}>}
25 *
26 * @memberof workbox-streams
27 */
28function concatenateToResponse(sourcePromises, headersInit) {
29 const { done, stream } = concatenate(sourcePromises);
30 const headers = createHeaders(headersInit);
31 const response = new Response(stream, { headers });
32 return { done, response };
33}
34export { concatenateToResponse };
Note: See TracBrowser for help on using the repository browser.