Consider replacing `qs` with `URLSearchParams`
wojtekmaj opened this issue · 2 comments
wojtekmaj commented
Is your feature request related to a problem?
qs
is pulling in 14 other dependencies with it: https://npmgraph.js.org/?q=qs@6.12.3, making swagger-js installing, evaluating and running slower than it could. On top of that, since qs is being maintained by you-know-who, changes are that even more needless dependencies will pop up in the dependency tree.
Describe the solution you'd like
Consider replacing qs
with URLSearchParams
.
Describe alternatives you've considered
Custom function like:
function stringify(obj) {
function stringifyInner(obj, parentKey) {
return Object.entries(obj).flatMap(([key, value]) => {
const fullKey = `${parentKey}[${key}]`;
if (typeof value === 'object') return stringifyInner(value, fullKey)
return [[fullKey, value]]
})
}
return new URLSearchParams(Object.entries(obj).flatMap(([k, v]) => {
if (typeof v === 'object') return stringifyInner(v, k)
return [[k, v]]
}));
}
if nested value support would be needed.
char0n commented
@wojtekmaj addressed in #3634. I would appreciated your review.