UNPKG

forerunnerdb

Version:

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

2,299 lines (585 loc) 29.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Mixin: Common</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: Common</h1> <section> <header> <h2>Common</h2> </header> <article> <div class="container-overview"> <div class="description">Provides commonly used methods to most classes in ForerunnerDB.</div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line31">line 31</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <ul><li><a href="#checksum"><span class="type-signature">(static) </span>checksum<span class="signature">(str)</span><span class="type-signature"> &rarr; {Number}</span></a></li><li><a href="#classIdentifier"><span class="type-signature">(static) </span>classIdentifier<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></a></li><li><a href="#convertToFdb"><span class="type-signature">(static) </span>convertToFdb<span class="signature">(obj)</span><span class="type-signature"></span></a></li><li><a href="#debounce"><span class="type-signature">(static) </span>debounce<span class="signature">(id, callback, timeout)</span><span class="type-signature"></span></a></li><li><a href="#decouple"><span class="type-signature">(static) </span>decouple<span class="signature">(data, copies<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></a></li><li><a href="#hash"><span class="type-signature">(static) </span>hash<span class="signature">(obj)</span><span class="type-signature"> &rarr; {String}</span></a></li><li><a href="#instanceIdentifier"><span class="type-signature">(static) </span>instanceIdentifier<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></a></li><li><a href="#isDropped"><span class="type-signature">(static) </span>isDropped<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></a></li><li><a href="#jParse"><span class="type-signature">(static) </span>jParse<span class="signature">(data)</span><span class="type-signature"> &rarr; {Object}</span></a></li><li><a href="#logIdentifier"><span class="type-signature">(static) </span>logIdentifier<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></a></li><li><a href="#make"><span class="type-signature">(static) </span>make<span class="signature">(val)</span><span class="type-signature"></span></a></li><li><a href="#objectId"><span class="type-signature">(static) </span>objectId<span class="signature">(str<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></a></li><li><a href="#store"><span class="type-signature">(static) </span>store<span class="signature">(key, val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></a></li><li><a href="#unStore"><span class="type-signature">(static) </span>unStore<span class="signature">(key)</span><span class="type-signature"> &rarr; {<a href="Common.html">Common</a>}</span></a></li></ul> <h4 class="name" id=".checksum"><span class="type-signature">(static) </span>checksum<span class="signature">(str)</span><span class="type-signature"> &rarr; {Number}</span></h4> <div class="description"> Returns a checksum of a 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>str</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">The string to checksum.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line342">line 342</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The checksum generated. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Number</span> </dd> </dl> <h4 class="name" id=".classIdentifier"><span class="type-signature">(static) </span>classIdentifier<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <div class="description"> Returns a string describing the class this instance is derived from. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line231">line 231</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> <h4 class="name" id=".convertToFdb"><span class="type-signature">(static) </span>convertToFdb<span class="signature">(obj)</span><span class="type-signature"></span></h4> <div class="description"> Converts a query object with MongoDB dot notation syntax to Forerunner's object notation syntax. </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 convert.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line258">line 258</a> </li></ul></dd> </dl> <h4 class="name" id=".debounce"><span class="type-signature">(static) </span>debounce<span class="signature">(id, callback, timeout)</span><span class="type-signature"></span></h4> <div class="description"> Registers a timed callback that will overwrite itself if the same id is used within the timeout period. Useful for de-bouncing fast-calls. </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>id</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">An ID for the call (use the same one to debounce the same calls).</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">The callback method to call on timeout.</td> </tr> <tr> <td class="name"><code>timeout</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">The timeout in milliseconds before the callback is called.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line311">line 311</a> </li></ul></dd> </dl> <h4 class="name" id=".decouple"><span class="type-signature">(static) </span>decouple<span class="signature">(data, copies<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Returns a non-referenced version of the passed object / array. </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>data</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> </td> <td class="description last">The object or array to return as a non-referenced version.</td> </tr> <tr> <td class="name"><code>copies</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Optional number of copies to produce. If specified, the return value will be an array of decoupled objects, each distinct from the other.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line97">line 97</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id=".hash"><span class="type-signature">(static) </span>hash<span class="signature">(obj)</span><span class="type-signature"> &rarr; {String}</span></h4> <div class="description"> Generates a unique hash for 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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to generate a hash for.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line174">line 174</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> <h4 class="name" id=".instanceIdentifier"><span class="type-signature">(static) </span>instanceIdentifier<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <div class="description"> Returns a string describing the instance by it's class name and instance object name. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line240">line 240</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The instance identifier. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> <h4 class="name" id=".isDropped"><span class="type-signature">(static) </span>isDropped<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Checks if the state is dropped. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line296">line 296</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True when dropped, false otherwise. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".jParse"><span class="type-signature">(static) </span>jParse<span class="signature">(data)</span><span class="type-signature"> &rarr; {Object}</span></h4> <div class="description"> Parses and returns data from stringified version. </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>data</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">The stringified version of data to parse.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line122">line 122</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The parsed JSON object from the data. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> </dd> </dl> <h4 class="name" id=".logIdentifier"><span class="type-signature">(static) </span>logIdentifier<span class="signature">()</span><span class="type-signature"> &rarr; {String}</span></h4> <div class="description"> Returns a string used to denote a console log against this instance, consisting of the class identifier and instance identifier. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line249">line 249</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The log identifier. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> <h4 class="name" id=".make"><span class="type-signature">(static) </span>make<span class="signature">(val)</span><span class="type-signature"></span></h4> <div class="description"> Generates a JSON serialisation-compatible object instance. After the instance has been passed through this method, it will be able to survive a JSON.stringify() and JSON.parse() cycle and still end up as an instance at the end. Further information about this process can be found in the ForerunnerDB wiki at: https://github.com/Irrelon/ForerunnerDB/wiki/Serialiser-&-Performance-Benchmarks </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>val</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The object instance such as "new Date()" or "new RegExp()".</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line43">line 43</a> </li></ul></dd> </dl> <h4 class="name" id=".objectId"><span class="type-signature">(static) </span>objectId<span class="signature">(str<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {String}</span></h4> <div class="description"> Generates a new 16-character hexadecimal unique ID or generates a new 16-character hexadecimal ID based on the passed string. Will always generate the same ID for the same 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>str</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">A string to generate the ID from.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line141">line 141</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> <h4 class="name" id=".store"><span class="type-signature">(static) </span>store<span class="signature">(key, val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Gets / sets data in the item store. The store can be used to set and retrieve data against a key. Useful for adding arbitrary key/value data to a collection / view etc and retrieving it later. </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>key</code></td> <td class="type"> <span class="param-type">String</span> | <span class="param-type">*</span> </td> <td class="attributes"> </td> <td class="description last">The key under which to store the passed value or retrieve the existing stored value.</td> </tr> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Optional value. If passed will overwrite the existing value stored against the specified key if one currently exists.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line58">line 58</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id=".unStore"><span class="type-signature">(static) </span>unStore<span class="signature">(key)</span><span class="type-signature"> &rarr; {<a href="Common.html">Common</a>}</span></h4> <div class="description"> Removes a previously stored key/value pair from the item store, set previously by using the store() method. </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>key</code></td> <td class="type"> <span class="param-type">String</span> | <span class="param-type">*</span> </td> <td class="description last">The key of the key/value pair to remove;</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line82">line 82</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Returns this for chaining. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Common.html">Common</a></span> </dd> </dl> <h3 class="subsection-title">Members</h3> <ul><li><a href="#debug"><span class="type-signature">(static) </span>debug<span class="type-signature"></span></a></li><li><a href="#jStringify"><span class="type-signature">(static) </span>jStringify<span class="type-signature"></span></a></li></ul> <h4 class="name" id=".debug"><span class="type-signature">(static) </span>debug<span class="type-signature"></span></h4> <div class="description"> Sets debug flag for a particular type that can enable debug message output to the console if required. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line191">line 191</a> </li></ul></dd> </dl> <h4 class="name" id=".jStringify"><span class="type-signature">(static) </span>jStringify<span class="type-signature"></span></h4> <div class="description"> Converts a JSON object into a stringified version. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Mixin.Common.js.html">Mixin.Common.js</a>, <a href="Mixin.Common.js.html#line131">line 131</a> </li></ul></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:22 GMT+0000 (GMT) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>