@liuhlightning/wx-pay
Version:
communicate to wx pay
25 lines • 763 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.paramsToString = paramsToString;
/**
* Parse the object to query string without encoding based on the ascii key order
*/
function paramsToString(data, param = {}) {
// avoid undefined value
const keys = Object.keys(data)
.filter((key) => data[key] !== undefined)
.sort();
// build a new params
const res = {};
for (const key of keys) {
const tempKey = param.lowerCase ? key.toLowerCase() : key;
res[tempKey] = data[key];
}
// build string
const strList = [];
for (const key in res) {
strList.push(`${key}=${res[key]}`);
}
return strList.join("&");
}
//# sourceMappingURL=paramsToString.js.map