UNPKG

@backstage/backend-defaults

Version:

Backend defaults used by Backstage backend apps

40 lines (36 loc) 901 B
'use strict'; var stream = require('stream'); var web = require('stream/web'); function parseLastModified(value) { if (!value) { return void 0; } try { const result = new Date(value); result.toISOString(); return result; } catch { return void 0; } } function responseToReadable(response) { return response.body ? stream.Readable.from(toWeb(response.body)) : new stream.PassThrough().end(); } function toWeb(responseBody) { const reader = responseBody.getReader(); return new web.ReadableStream({ async pull(controller) { const { value, done } = await reader.read(); if (value) { controller.enqueue(value); } if (done) { controller.close(); } } }); } exports.parseLastModified = parseLastModified; exports.responseToReadable = responseToReadable; exports.toWeb = toWeb; //# sourceMappingURL=util.cjs.js.map