UNPKG

wretch

Version:

A tiny wrapper built around fetch with an intuitive syntax.

26 lines 979 B
export function extractContentType(headers = {}) { const normalizedHeaders = headers instanceof Array ? Object.fromEntries(headers) : headers; for (const k in normalizedHeaders) { if (k.toLowerCase() === "content-type") return normalizedHeaders[k]; } } export function isLikelyJsonMime(value) { return /^application\/.*json/.test(value); } export const mix = (one, two, mergeArrays = false) => { const acc = { ...one }; for (const key in two) { if (!Object.prototype.hasOwnProperty.call(two, key)) continue; const value = one[key]; const newValue = two[key]; acc[key] = Array.isArray(value) && Array.isArray(newValue) ? mergeArrays ? [...value, ...newValue] : newValue : typeof value === "object" && typeof newValue === "object" ? mix(value, newValue, mergeArrays) : newValue; } return acc; }; //# sourceMappingURL=utils.js.map