datasquirel/utils/functions/serialize-query.js

18 lines
407 B
JavaScript
Raw Normal View History

2024-10-18 04:49:04 +00:00
// @ts-check
/** @type {import("@/package-shared/types/general.td").SerializeQueryFnType} */
function serializeQuery({ query }) {
let str = "?";
const keys = Object.keys(query);
/** @type {string[]} */
const queryArr = [];
keys.forEach((key) => {
queryArr.push(`${key}=${query[key]}`);
});
str += queryArr.join("&");
return str;
}
module.exports = serializeQuery;