UNPKG

@gravity-ui/data-source

Version:
33 lines 1.08 kB
/** * @description * * The function is intended to be used with the `fetch` parameter of the query data source config. * It is used to ignore the query data context and the query function context parameters. * * NOTE: When passed directly to the `fetch` parameter, typescript fails to infer the types of the `DataSource` fields. * It is better to define a constant first. * * @example * * function someFetchFunction(request: TRequest) {...} * * const fetchData = skipContext(someFetchFunction); * * const dataSource = makePlainQueryDataSource({ * ... * fetch: fetchData, * ... * }) * * @param fetch fetch function * @returns fetch function with the ignored query data source context and the query function context. */ export var skipContext = function skipContext(fetch) { return function (_0, _1) { for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } return fetch.apply(void 0, args); }; }; // #sourceMappingURL=skipContext.js.map