Files
med-notes/.pnpm-store/v10/files/33/0037d40821a95d934db7bf3413d0a4f789eca053558424cce25114184e956bedd0b9d3024b40883f95b63650ae53f6a5bb40230116166a386f6419e4fc3203
2025-05-09 05:30:08 +02:00

43 lines
918 B
Plaintext

import { deepEqual } from "./utils.js";
function retainSearchParams(keys) {
return ({ search, next }) => {
const result = next(search);
if (keys === true) {
return { ...search, ...result };
}
keys.forEach((key) => {
if (!(key in result)) {
result[key] = search[key];
}
});
return result;
};
}
function stripSearchParams(input) {
return ({ search, next }) => {
if (input === true) {
return {};
}
const result = next(search);
if (Array.isArray(input)) {
input.forEach((key) => {
delete result[key];
});
} else {
Object.entries(input).forEach(
([key, value]) => {
if (deepEqual(result[key], value)) {
delete result[key];
}
}
);
}
return result;
};
}
export {
retainSearchParams,
stripSearchParams
};
//# sourceMappingURL=searchMiddleware.js.map