UNPKG

forerunnerdb

Version:

A NoSQL document store database for browsers and Node.js.

2,303 lines (623 loc) 27 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Path</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">Class: Path</h1> <section> <header> <h2> Path </h2> </header> <article> <div class="container-overview"> <h4 class="name" id="Path"><span class="type-signature"></span>new Path<span class="signature">(path<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Path object used to resolve object paths and retrieve data from objects by using paths. </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>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">The path to assign.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line11">line 11</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="clean"><span class="type-signature"></span>clean<span class="signature">(str)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Removes leading period (.) from string and returns it. </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>str</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">The string to clean.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line436">line 436</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="countKeys"><span class="type-signature"></span>countKeys<span class="signature">(testObj)</span><span class="type-signature"> &rarr; {Number}</span></h4> <div class="description"> Counts the total number of key endpoints in the passed object. </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>testObj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to count key endpoints for.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line76">line 76</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The number of endpoints. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Number</span> </dd> </dl> <h4 class="name" id="countObjectPaths"><span class="type-signature"></span>countObjectPaths<span class="signature">(testKeys, testObj)</span><span class="type-signature"> &rarr; {Object}</span></h4> <div class="description"> Tests if the passed object has the paths that are specified and that a value exists in those paths and if so returns the number matched. </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>testKeys</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object describing the paths to test for.</td> </tr> <tr> <td class="name"><code>testObj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to test paths against.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line102">line 102</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Stats on the matched keys </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> <h4 class="name" id="hasObjectPaths"><span class="type-signature"></span>hasObjectPaths<span class="signature">(testKeys, testObj)</span><span class="type-signature"> &rarr; {Boolean}</span></h4> <div class="description"> Tests if the passed object has the paths that are specified and that a value exists in those paths. </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>testKeys</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object describing the paths to test for.</td> </tr> <tr> <td class="name"><code>testObj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to test paths against.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line46">line 46</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True if the object paths exist. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Boolean</span> </dd> </dl> <h4 class="name" id="keyValue"><span class="type-signature"></span>keyValue<span class="signature">(obj, path<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Gets the value(s) that the object contains for the currently assigned path string with their associated keys. </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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> </td> <td class="description last">The object to evaluate the path against.</td> </tr> <tr> <td class="name"><code>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">A path to use instead of the existing one passed in path().</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line367">line 367</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> An array of values for the given path with the associated key. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="parse"><span class="type-signature"></span>parse<span class="signature">(obj, withValue<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4> <div class="description"> Takes a non-recursive object and converts the object hierarchy into a path string. </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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> </td> <td class="description last">The object to parse.</td> </tr> <tr> <td class="name"><code>withValue</code></td> <td class="type"> <span class="param-type">Boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">If true will include a 'value' key in the returned object that represents the value the object path points to.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line148">line 148</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> <h4 class="name" id="parseArr"><span class="type-signature"></span>parseArr<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Takes a non-recursive object and converts the object hierarchy into an array of path strings that allow you to target all possible paths in an object. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line203">line 203</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="path"><span class="type-signature"></span>path<span class="signature">(path<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> Gets / sets the given path for the Path instance. </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>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">The path to assign.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line29">line 29</a> </li></ul></dd> </dl> <h4 class="name" id="push"><span class="type-signature"></span>push<span class="signature">(obj, path, val)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Push a value to an array on an object for the specified path. </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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to update.</td> </tr> <tr> <td class="name"><code>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">The path to the array to push to.</td> </tr> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The value to push to the array at the object path.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line329">line 329</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="set"><span class="type-signature"></span>set<span class="signature">(obj, path, val)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Sets a value on an object for the specified path. </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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to update.</td> </tr> <tr> <td class="name"><code>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">The path to update.</td> </tr> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The value to set the object path to.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line406">line 406</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="set"><span class="type-signature"></span>set<span class="signature">(obj, path, val)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Sets a value on an object for the specified path. </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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to update.</td> </tr> <tr> <td class="name"><code>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">The path to update.</td> </tr> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The value to set the object path to.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line293">line 293</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="value"><span class="type-signature"></span>value<span class="signature">(obj, path<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Gets the value(s) that the object contains for the currently assigned path string. </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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> </td> <td class="description last">The object to evaluate the path against.</td> </tr> <tr> <td class="name"><code>path</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">A path to use instead of the existing one passed in path().</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Path.js.html">Path.js</a>, <a href="Path.js.html#line242">line 242</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> An array of values for the given path. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ActiveBucket.html">ActiveBucket</a></li><li><a href="Angular.html">Angular</a></li><li><a href="AutoBind.html">AutoBind</a></li><li><a href="BinaryTree.html">BinaryTree</a></li><li><a href="Collection.html">Collection</a></li><li><a href="CollectionGroup.html">CollectionGroup</a></li><li><a href="Core.html">Core</a></li><li><a href="Db.html">Db</a></li><li><a href="Document.html">Document</a></li><li><a href="Grid.html">Grid</a></li><li><a href="Highchart.html">Highchart</a></li><li><a href="IndexBinaryTree.html">IndexBinaryTree</a></li><li><a href="IndexHashMap.html">IndexHashMap</a></li><li><a href="Infinilist.html">Infinilist</a></li><li><a href="KeyValueStore.html">KeyValueStore</a></li><li><a href="Metrics.html">Metrics</a></li><li><a href="OldView.html">OldView</a></li><li><a href="Operation.html">Operation</a></li><li><a href="Overload.html">Overload</a></li><li><a href="Path.html">Path</a></li><li><a href="Persist.html">Persist</a></li><li><a href="ReactorIO.html">ReactorIO</a></li><li><a href="Serialiser.html">Serialiser</a></li><li><a href="Shared.overload.html">overload</a></li><li><a href="View.html">View</a></li></ul><h3>Mixins</h3><ul><li><a href="ChainReactor.html">ChainReactor</a></li><li><a href="crcTable.html">crcTable</a></li><li><a href="Shared.html">Shared</a></li></ul><h3>Global</h3><ul><li><a href="global.html#%2522boolean,function%2522">"boolean, function"</a></li><li><a href="global.html#%2522string,*,function%2522">"string, *, function"</a></li><li><a href="global.html#%2522string,function%2522">"string, function"</a></li><li><a href="global.html#boolean">boolean</a></li><li><a href="global.html#function">function</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a> on Thu Nov 19 2015 13:31:32 GMT+0000 (GMT) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>