@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
22 lines (17 loc) • 552 B
JavaScript
;
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
// src/stringifyQueryObject/index.ts
function stringifyQueryObject(queryParameters) {
if (!queryParameters)
return "";
return Object.entries(queryParameters).reduce((queryString, [key, val]) => {
const symbol = queryString.length === 0 ? "?" : "&";
queryString += typeof val === "string" ? `${symbol}${key}=${val}` : "";
return queryString;
}, "");
}
exports.stringifyQueryObject = stringifyQueryObject;