{"version":3,"file":"with-options.cjs","names":["options"],"sources":["../../../src/rest/helpers/with-options.ts"],"sourcesContent":["import type { RequestTransformer } from '../../index.js';\nimport type { RestCommand } from '../types.js';\n\n/**\n * Add arbitrary options to a fetch request\n *\n * @param getOptions\n * @param onRequest\n *\n * @returns\n */\nexport function withOptions<Schema, Output>(\n\tgetOptions: RestCommand<Output, Schema>,\n\textraOptions: RequestTransformer | Partial<RequestInit>,\n): RestCommand<Output, Schema> {\n\treturn () => {\n\t\tconst options = getOptions();\n\n\t\tif (typeof extraOptions === 'function') {\n\t\t\toptions.onRequest = extraOptions;\n\t\t} else {\n\t\t\toptions.onRequest = (options) => ({\n\t\t\t\t...options,\n\t\t\t\t...extraOptions,\n\t\t\t});\n\t\t}\n\n\t\treturn options;\n\t};\n}\n"],"mappings":"AAWA,SAAgB,EACf,EACA,EAC8B,CAC9B,UAAa,CACZ,IAAM,EAAU,GAAY,CAW5B,OATI,OAAO,GAAiB,WAC3B,EAAQ,UAAY,EAEpB,EAAQ,UAAa,IAAa,CACjC,GAAGA,EACH,GAAG,EACH,EAGK"}