marbles
Version:
Front-end framework for routing, http, and data handling
730 lines (229 loc) • 10.7 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Mixin: QueryParams</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Mixin: QueryParams</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="Marbles.html">Marbles</a>.</span>
QueryParams
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="marbles.js.html">marbles.js</a>, <a href="marbles.js.html#line917">line 917</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="combineParams"><span class="type-signature">(static) </span>combineParams<span class="signature">(params, …others)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Combines the first params array with the contents of all the others. Duplicate params are pushed into the next param object they do not comflict with. The mutated params array is returned.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="attributes">
</td>
<td class="description last">An array of param objects</td>
</tr>
<tr>
<td class="name"><code>others</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<repeatable><br>
</td>
<td class="description last">Any number of param objects</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="marbles.js.html">marbles.js</a>, <a href="marbles.js.html#line982">line 982</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="deserializeParams"><span class="type-signature">(static) </span>deserializeParams<span class="signature">(queryString)</span><span class="type-signature"> → {Array}</span></h4>
</dt>
<dd>
<div class="description">
transforms a query string into an array of param objects (the first occurance of each param will be placed at index 0, the second at index 1, and so on).
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>queryString</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="marbles.js.html">marbles.js</a>, <a href="marbles.js.html#line933">line 933</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
params
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h5>Examples</h5>
<pre class="prettyprint"><code>Marbles.QueryParams.deserializeParams("?a=1&b=2&c=3");
//=> [{a: 1, b:2, c:3}]</code></pre>
<pre class="prettyprint"><code>Marbles.QueryParams.deserializeParams("a=1&b=2&c=3");
//=> [{a: 1, b:2, c:3}]</code></pre>
<pre class="prettyprint"><code>Marbles.QueryParams.deserializeParams("?a=1&a=2&b=3&c=4&c=5");
//=> [{a: 1, b:3, c:4}, {a: 2, c: 5}]</code></pre>
</dd>
<dt>
<h4 class="name" id="replaceParams"><span class="type-signature">(static) </span>replaceParams<span class="signature">(params, …others)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Combines the first params array with the contents of all the others. Duplicate params are overwritten if they are at the same params index.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="attributes">
</td>
<td class="description last">An array of param objects</td>
</tr>
<tr>
<td class="name"><code>others</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<repeatable><br>
</td>
<td class="description last">Any number of param objects</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="marbles.js.html">marbles.js</a>, <a href="marbles.js.html#line1021">line 1021</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="serializeParams"><span class="type-signature">(static) </span>serializeParams<span class="signature">(params)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Transforms an array of param objects into a query string.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">An array of param objects</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="marbles.js.html">marbles.js</a>, <a href="marbles.js.html#line1050">line 1050</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>Marbles.QueryParams.serializeParams([{a:1, b:2}, {a:3, b:4}]);
//= "?a=1&b=2&a=3&b=4"</code></pre>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Marbles.Collection.html">Collection</a></li><li><a href="Marbles.History.html">History</a></li><li><a href="Marbles.HTTPRequest.html">HTTPRequest</a></li><li><a href="Marbles.Model.html">Model</a></li><li><a href="Marbles.Object.html">Object</a></li><li><a href="Marbles.Router.html">Router</a></li><li><a href="Marbles.Store.html">Store</a></li></ul><h3>Namespaces</h3><ul><li><a href="Marbles.html">Marbles</a></li><li><a href="Marbles.HTTP.Middleware.html">Middleware</a></li><li><a href="Marbles.Utils.html">Utils</a></li></ul><h3>Mixins</h3><ul><li><a href="Marbles.Accessors.html">Accessors</a></li><li><a href="Marbles.Dispatcher.html">Dispatcher</a></li><li><a href="Marbles.Events.html">Events</a></li><li><a href="Marbles.HTTP.LinkHeader.html">LinkHeader</a></li><li><a href="Marbles.QueryParams.html">QueryParams</a></li><li><a href="Marbles.State.html">State</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Fri Jan 09 2015 21:26:15 GMT-0500 (EST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>