Last active
December 18, 2015 02:39
-
-
Save atlefren/5712243 to your computer and use it in GitHub Desktop.
query params handler. made for underscore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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