Skip to content

Instantly share code, notes, and snippets.

@atlefren
Last active December 18, 2015 02:39
Show Gist options
  • Select an option

  • Save atlefren/5712243 to your computer and use it in GitHub Desktop.

Select an option

Save atlefren/5712243 to your computer and use it in GitHub Desktop.
query params handler. made for underscore
(function (lib) {
"use strict";
var QueryParams = function (initParams) {
var params = initParams || {};
function addParam(key, value) {
params[key] = value;
}
function toString() {
return _.map(params, function (value, key) {
return key + "=" + encodeURIComponent(value);
}).join("&");
}
return (function () {
return {
"add": addParam,
"get": toString
};
}());
};
lib.mixin({"QueryParams": QueryParams});
}(_));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment