tricks
Version:
ES6 modules
10 lines (9 loc) • 345 B
JavaScript
// Param
// Explode/encode the parameters of an URL string/object
// @param string s, string to decode
export default (hash, delimiter = '&', seperator = '=', formatFunction = o => o) =>
Object.keys(hash).map(name => {
const value = formatFunction(hash[name]);
return name + (value !== null ? seperator + value : '');
}).join(delimiter)
;