UNPKG

forerunnerdb

Version:

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

2,700 lines (737 loc) 34.9 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> <ul><li><a href="#aggregate"><span class="type-signature"></span>aggregate<span class="signature">(obj, path)</span><span class="type-signature"> &rarr; {Array}</span></a></li><li><a href="#clean"><span class="type-signature"></span>clean<span class="signature">(str)</span><span class="type-signature"> &rarr; {*}</span></a></li><li><a href="#countKeys"><span class="type-signature"></span>countKeys<span class="signature">(testObj)</span><span class="type-signature"> &rarr; {Number}</span></a></li><li><a href="#countObjectPaths"><span class="type-signature"></span>countObjectPaths<span class="signature">(testKeys, testObj)</span><span class="type-signature"> &rarr; {Object}</span></a></li><li><a href="#get"><span class="type-signature"></span>get<span class="signature">(obj, path)</span><span class="type-signature"> &rarr; {*}</span></a></li><li><a href="#hasObjectPaths"><span class="type-signature"></span>hasObjectPaths<span class="signature">(testKeys, testObj)</span><span class="type-signature"> &rarr; {Boolean}</span></a></li><li><a href="#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></a></li><li><a href="#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></a></li><li><a href="#parseArr"><span class="type-signature"></span>parseArr<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></a></li><li><a href="#path"><span class="type-signature"></span>path<span class="signature">(path<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></a></li><li><a href="#push"><span class="type-signature"></span>push<span class="signature">(obj, path, val)</span><span class="type-signature"> &rarr; {*}</span></a></li><li><a href="#set"><span class="type-signature"></span>set<span class="signature">(obj, path, val)</span><span class="type-signature"> &rarr; {*}</span></a></li><li><a href="#set"><span class="type-signature"></span>set<span class="signature">(obj, path, val)</span><span class="type-signature"> &rarr; {*}</span></a></li><li><a href="#value"><span class="type-signature"></span>value<span class="signature">(obj, path<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></a></li></ul> <h4 class="name" id="aggregate"><span class="type-signature"></span>aggregate<span class="signature">(obj, path)</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Retrieves all the values inside an object based on the passed path string. Will automatically traverse any arrays it encounters and assumes array indexes are not part of the specifed 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> | <span class="param-type">Array</span> </td> <td class="description last">An object or array of objects to scan paths for.</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 string delimited by a period.</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#line290">line 290</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> An array of values found at the end of each path termination. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <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#line527">line 527</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="get"><span class="type-signature"></span>get<span class="signature">(obj, path)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Gets a single value from the passed object and given 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 inspect.</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 retrieve data from.</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="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#line458">line 458</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. The options object accepts an "ignore" field with a regular expression as the value. If any key matches the expression it is not included in the results. The options object accepts a boolean "verbose" field. If set to true the results will include all paths leading up to endpoints as well as they endpoints themselves. </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#line211">line 211</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#line420">line 420</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#line255">line 255</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#line497">line 497</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>, options<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> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">An optional options object.</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#line340">line 340</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="Collection.html">Collection</a></li><li><a href="CollectionGroup.html">CollectionGroup</a></li><li><a href="Condition.html">Condition</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="Index2d.html">Index2d</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="MyModule.html">MyModule</a></li><li><a href="NodeApiClient.html">NodeApiClient</a></li><li><a href="NodeApiServer.html">NodeApiServer</a></li><li><a href="NodeRAS.html">NodeRAS</a></li><li><a href="Odm.html">Odm</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="Overview.html">Overview</a></li><li><a href="Overview_init.html">init</a></li><li><a href="Path.html">Path</a></li><li><a href="Persist.html">Persist</a></li><li><a href="Procedure.html">Procedure</a></li><li><a href="ReactorIO.html">ReactorIO</a></li><li><a href="Section.html">Section</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="Common.html">Common</a></li><li><a href="Constants.html">Constants</a></li><li><a href="Events.html">Events</a></li><li><a href="Matching.html">Matching</a></li><li><a href="Shared.html">Shared</a></li><li><a href="Sorting.html">Sorting</a></li><li><a href="Tags.html">Tags</a></li><li><a href="Triggers.html">Triggers</a></li><li><a href="Updating.html">Updating</a></li></ul><h3><a href="global.html">Global</a></h3> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Mar 01 2018 11:34:23 GMT+0000 (GMT) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>