UNPKG

ky

Version:

Tiny and elegant HTTP client based on the Fetch API

31 lines 998 B
import { kyOptionKeys, requestOptionsRegistry } from '../core/constants.js'; export const findUnknownOptions = (request, options) => { const unknownOptions = {}; for (const key in options) { if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) { unknownOptions[key] = options[key]; } } return unknownOptions; }; export const hasSearchParameters = (search) => { if (search === undefined) { return false; } // The `typeof array` still gives "object", so we need different checking for array. if (Array.isArray(search)) { return search.length > 0; } if (search instanceof URLSearchParams) { return search.size > 0; } // Record if (typeof search === 'object') { return Object.keys(search).length > 0; } if (typeof search === 'string') { return search.trim().length > 0; } return Boolean(search); }; //# sourceMappingURL=options.js.map