UNPKG

morefun-forerunnerdb

Version:

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

2,232 lines (573 loc) 27.5 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#line13">line 13</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Members</h3> <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#line176">line 176</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <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#line216">line 216</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#line243">line 243</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"><a href="global.html#function">function</a></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#line296">line 296</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#line79">line 79</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#line159">line 159</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#line225">line 225</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; {<a href="global.html#boolean">boolean</a>}</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#line281">line 281</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"><a href="global.html#boolean">boolean</a></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#line104">line 104</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=".jStringify"><span class="type-signature">(static) </span>jStringify<span class="signature">(data)</span><span class="type-signature"> &rarr; {String}</span></h4> <div class="description"> Converts a JSON object into a 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">Object</span> </td> <td class="description last">The data to stringify.</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#line113">line 113</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The stringified data. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</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#line234">line 234</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#line25">line 25</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#line126">line 126</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#line40">line 40</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#line64">line 64</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> </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="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="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="Procedure.html">Procedure</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="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="global.html#Shared">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>Global</h3><ul><li><a href="global.html#%2522boolean,function%2522">"boolean, function"</a></li><li><a href="global.html#%2522object,function%2522">"object, function"</a></li><li><a href="global.html#%2522object,object,function%2522">"object, object, 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#%2522string,object,function%2522">"string, object, function"</a></li><li><a href="global.html#%2522string,object,object,function%2522">"string, object, object, function"</a></li><li><a href="global.html#%2522string,string,function%2522">"string, string, function"</a></li><li><a href="global.html#%2522string,string,object,function%2522">"string, string, object, function"</a></li><li><a href="global.html#%2522string,string,object,object,function%2522">"string, string, object, object, function"</a></li><li><a href="global.html#access">access</a></li><li><a href="global.html#boolean">boolean</a></li><li><a href="global.html#checksum">checksum</a></li><li><a href="global.html#Condition">Condition</a></li><li><a href="global.html#function">function</a></li><li><a href="global.html#MyModule">MyModule</a></li><li><a href="global.html#name">name</a></li><li><a href="global.html#NodeRAS">NodeRAS</a></li><li><a href="global.html#Section">Section</a></li><li><a href="global.html#server">server</a></li><li><a href="global.html#setData">setData</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 15 2016 17:25:36 GMT+0100 (BST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>