@coveo/platform-client
Version:
The main goal of this package is to provide an easy to configure and straightforward way of querying Coveo Cloud APIs using JavaScript.
27 lines • 888 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizePaginatedOptions = void 0;
const normalizePaginatedOptions = (options) => {
if (isDeprecatedPaginated(options)) {
return options;
}
else {
const { perPage: _, ...copiedOptions } = { ...options, pageSize: options?.perPage };
return copiedOptions;
}
};
exports.normalizePaginatedOptions = normalizePaginatedOptions;
const isDeprecatedPaginated = (options) => {
if (!options) {
return false;
}
const keys = Object.keys(options);
if (!keys.includes('perPage')) {
return true;
}
if (keys.includes('pageSize')) {
throw new Error('The Pagination options are invalid: both pageSize and perPage have been set. Use only one of them.');
}
return false;
};
//# sourceMappingURL=normalizePaginatedOptions.js.map