UNPKG

flavor-js

Version:

FlavorJS the definitive JS natives chainable extensions methods (based on lodash & ES6)

1,788 lines (409 loc) 31 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>FlavorJS - Documentation</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.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FlavorJS.html">FlavorJS</a><ul class='methods'><li data-type='method'><a href="FlavorJS.html#delay">delay</a></li><li data-type='method'><a href="FlavorJS.html#extendArray">extendArray</a></li><li data-type='method'><a href="FlavorJS.html#extendBoolean">extendBoolean</a></li><li data-type='method'><a href="FlavorJS.html#extendDate">extendDate</a></li><li data-type='method'><a href="FlavorJS.html#extendFunction">extendFunction</a></li><li data-type='method'><a href="FlavorJS.html#extendLodash">extendLodash</a></li><li data-type='method'><a href="FlavorJS.html#extendNumber">extendNumber</a></li><li data-type='method'><a href="FlavorJS.html#extendObject">extendObject</a></li><li data-type='method'><a href="FlavorJS.html#extendPrototype">extendPrototype</a></li><li data-type='method'><a href="FlavorJS.html#extendPrototypeProperty">extendPrototypeProperty</a></li><li data-type='method'><a href="FlavorJS.html#extendString">extendString</a></li><li data-type='method'><a href="FlavorJS.html#init">init</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="array.html">array</a><ul class='methods'><li data-type='method'><a href="array.html#clone">clone</a></li><li data-type='method'><a href="array.html#concat">concat</a></li><li data-type='method'><a href="array.html#contains">contains</a></li><li data-type='method'><a href="array.html#containsBy">containsBy</a></li><li data-type='method'><a href="array.html#countBy">countBy</a></li><li data-type='method'><a href="array.html#cut">cut</a></li><li data-type='method'><a href="array.html#deepFindBy">deepFindBy</a></li><li data-type='method'><a href="array.html#deepMap">deepMap</a></li><li data-type='method'><a href="array.html#deepSortBy">deepSortBy</a></li><li data-type='method'><a href="array.html#diff">diff</a></li><li data-type='method'><a href="array.html#diffBy">diffBy</a></li><li data-type='method'><a href="array.html#distinct">distinct</a></li><li data-type='method'><a href="array.html#each">each</a></li><li data-type='method'><a href="array.html#filterBy">filterBy</a></li><li data-type='method'><a href="array.html#findBy">findBy</a></li><li data-type='method'><a href="array.html#first">first</a></li><li data-type='method'><a href="array.html#flatten">flatten</a></li><li data-type='method'><a href="array.html#indexBy">indexBy</a></li><li data-type='method'><a href="array.html#intersection">intersection</a></li><li data-type='method'><a href="array.html#isArray">isArray</a></li><li data-type='method'><a href="array.html#last">last</a></li><li data-type='method'><a href="array.html#lorem">lorem</a></li><li data-type='method'><a href="array.html#maxBy">maxBy</a></li><li data-type='method'><a href="array.html#pull">pull</a></li><li data-type='method'><a href="array.html#pullBy">pullBy</a></li><li data-type='method'><a href="array.html#random">random</a></li><li data-type='method'><a href="array.html#removeBy">removeBy</a></li><li data-type='method'><a href="array.html#shuffle">shuffle</a></li><li data-type='method'><a href="array.html#sortBy">sortBy</a></li><li data-type='method'><a href="array.html#split">split</a></li><li data-type='method'><a href="array.html#sum">sum</a></li><li data-type='method'><a href="array.html#tail">tail</a></li><li data-type='method'><a href="array.html#tail">tail</a></li><li data-type='method'><a href="array.html#union">union</a></li></ul></li><li><a href="boolean.html">boolean</a><ul class='methods'><li data-type='method'><a href="boolean.html#isBoolean">isBoolean</a></li><li data-type='method'><a href="boolean.html#random">random</a></li></ul></li><li><a href="date.html">date</a><ul class='methods'><li data-type='method'><a href="date.html#isDate">isDate</a></li><li data-type='method'><a href="date.html#random">random</a></li><li data-type='method'><a href="date.html#toTimestamp">toTimestamp</a></li></ul></li><li><a href="function.html">function</a><ul class='methods'><li data-type='method'><a href="function.html#isFunction">isFunction</a></li><li data-type='method'><a href="function.html#proxy">proxy</a></li></ul></li><li><a href="lodash.html">lodash</a><ul class='methods'><li data-type='method'><a href="lodash.html#deepFindBy">deepFindBy</a></li><li data-type='method'><a href="lodash.html#deepMap">deepMap</a></li><li data-type='method'><a href="lodash.html#deepOrderBy">deepOrderBy</a></li><li data-type='method'><a href="lodash.html#filterByValues">filterByValues</a></li><li data-type='method'><a href="lodash.html#isPercentage">isPercentage</a></li><li data-type='method'><a href="lodash.html#parsePercentage">parsePercentage</a></li><li data-type='method'><a href="lodash.html#pullAllByComparator">pullAllByComparator</a></li><li data-type='method'><a href="lodash.html#timesRange">timesRange</a></li><li data-type='method'><a href="lodash.html#timesReverse">timesReverse</a></li></ul></li><li><a href="number.html">number</a><ul class='methods'><li data-type='method'><a href="number.html#between">between</a></li><li data-type='method'><a href="number.html#degreeDiff">degreeDiff</a></li><li data-type='method'><a href="number.html#degreeDir">degreeDir</a></li><li data-type='method'><a href="number.html#degreeWrap">degreeWrap</a></li><li data-type='method'><a href="number.html#floor">floor</a></li><li data-type='method'><a href="number.html#fromRoman">fromRoman</a></li><li data-type='method'><a href="number.html#isNumber">isNumber</a></li><li data-type='method'><a href="number.html#parse">parse</a></li><li data-type='method'><a href="number.html#random">random</a></li><li data-type='method'><a href="number.html#range">range</a></li><li data-type='method'><a href="number.html#round">round</a></li><li data-type='method'><a href="number.html#round">round</a></li><li data-type='method'><a href="number.html#times">times</a></li><li data-type='method'><a href="number.html#toAbsolute">toAbsolute</a></li><li data-type='method'><a href="number.html#toCurrency">toCurrency</a></li><li data-type='method'><a href="number.html#toFileSize">toFileSize</a></li><li data-type='method'><a href="number.html#toRoman">toRoman</a></li><li data-type='method'><a href="number.html#toSymbolString">toSymbolString</a></li></ul></li><li><a href="object.html">object</a><ul class='methods'><li data-type='method'><a href="object.html#clone">clone</a></li><li data-type='method'><a href="object.html#each">each</a></li><li data-type='method'><a href="object.html#inherit">inherit</a></li><li data-type='method'><a href="object.html#isObject">isObject</a></li><li data-type='method'><a href="object.html#omit">omit</a></li><li data-type='method'><a href="object.html#path">path</a></li><li data-type='method'><a href="object.html#pick">pick</a></li></ul></li><li><a href="string.html">string</a><ul class='methods'><li data-type='method'><a href="string.html#camelCase">camelCase</a></li><li data-type='method'><a href="string.html#capitalize">capitalize</a></li><li data-type='method'><a href="string.html#contains">contains</a></li><li data-type='method'><a href="string.html#decodeURI">decodeURI</a></li><li data-type='method'><a href="string.html#encodeURI">encodeURI</a></li><li data-type='method'><a href="string.html#endsWith">endsWith</a></li><li data-type='method'><a href="string.html#escapeHTML">escapeHTML</a></li><li data-type='method'><a href="string.html#escapeHTML">escapeHTML</a></li><li data-type='method'><a href="string.html#extractDomain">extractDomain</a></li><li data-type='method'><a href="string.html#extractFileExtension">extractFileExtension</a></li><li data-type='method'><a href="string.html#extractQueryString">extractQueryString</a></li><li data-type='method'><a href="string.html#guid">guid</a></li><li data-type='method'><a href="string.html#isRoman">isRoman</a></li><li data-type='method'><a href="string.html#isString">isString</a></li><li data-type='method'><a href="string.html#isUrl">isUrl</a></li><li data-type='method'><a href="string.html#pad">pad</a></li><li data-type='method'><a href="string.html#padLeft">padLeft</a></li><li data-type='method'><a href="string.html#padRight">padRight</a></li><li data-type='method'><a href="string.html#parsePercentage">parsePercentage</a></li><li data-type='method'><a href="string.html#parsePercentage">parsePercentage</a></li><li data-type='method'><a href="string.html#replaceAll">replaceAll</a></li><li data-type='method'><a href="string.html#slugify">slugify</a></li><li data-type='method'><a href="string.html#startsWith">startsWith</a></li><li data-type='method'><a href="string.html#stripTags">stripTags</a></li><li data-type='method'><a href="string.html#toArray">toArray</a></li><li data-type='method'><a href="string.html#toInt">toInt</a></li></ul></li></ul><h3><a href="global.html">Global</a></h3> </nav> <div id="main"> <h1 class="page-title">FlavorJS</h1> <section> <header> <h2> FlavorJS </h2> <div class="class-description">FlavorJS the definitive JS natives chainable extensions methods</div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="FlavorJS"><span class="type-signature"></span>new FlavorJS<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line15">line 15</a> </li></ul></dd> </dl> <div class="description"> constructs FlavorJS class & extends the js natives </div> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="delay"><span class="type-signature"></span>delay<span class="signature">(fn, ms)</span><span class="type-signature"> &rarr; {<a href="function.html">function</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_core.js.html">Extensions/core.js</a>, <a href="Extensions_core.js.html#line4">line 4</a> </li></ul></dd> </dl> <div class="description"> delays a function by specified ms </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>ƒ.delay(function() { console.log('ended') }, 1000); // it logs 'ended' after 1000ms</code></pre> <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>fn</code></td> <td class="type"> <span class="param-type"><a href="function.html">function</a></span> </td> <td class="description last">function to invoke</td> </tr> <tr> <td class="name"><code>ms</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="description last">time to wait in milliseconds</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="function.html">function</a></span> </dd> </dl> <h4 class="name" id="extendArray"><span class="type-signature"></span>extendArray<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line164">line 164</a> </li></ul></dd> </dl> <div class="description"> extendArray </div> <h4 class="name" id="extendBoolean"><span class="type-signature"></span>extendBoolean<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line121">line 121</a> </li></ul></dd> </dl> <div class="description"> extendBoolean </div> <h4 class="name" id="extendDate"><span class="type-signature"></span>extendDate<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line142">line 142</a> </li></ul></dd> </dl> <div class="description"> extendDate </div> <h4 class="name" id="extendFunction"><span class="type-signature"></span>extendFunction<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line110">line 110</a> </li></ul></dd> </dl> <div class="description"> extendFunction </div> <h4 class="name" id="extendLodash"><span class="type-signature"></span>extendLodash<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line89">line 89</a> </li></ul></dd> </dl> <div class="description"> extendLodash </div> <h4 class="name" id="extendNumber"><span class="type-signature"></span>extendNumber<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line132">line 132</a> </li></ul></dd> </dl> <div class="description"> extendNumber </div> <h4 class="name" id="extendObject"><span class="type-signature"></span>extendObject<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line99">line 99</a> </li></ul></dd> </dl> <div class="description"> extendObject </div> <h4 class="name" id="extendPrototype"><span class="type-signature"></span>extendPrototype<span class="signature">(proto, extend)</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line75">line 75</a> </li></ul></dd> </dl> <div class="description"> merges all keys in extend plain object to the prototype ( </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>proto</code></td> <td class="type"> <span class="param-type"><a href="global.html#prototype">prototype</a></span> | <span class="param-type"><a href="object.html">object</a></span> </td> <td class="description last">the prototype/object to extend</td> </tr> <tr> <td class="name"><code>extend</code></td> <td class="type"> <span class="param-type"><a href="object.html">object</a></span> </td> <td class="description last">the extend object to be merged in prototype</td> </tr> </tbody> </table> <h4 class="name" id="extendPrototypeProperty"><span class="type-signature"></span>extendPrototypeProperty<span class="signature">(proto, prop, val, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line26">line 26</a> </li></ul></dd> </dl> <div class="description"> safe js native prototype extension using Object.defineProperty </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>proto</code></td> <td class="type"> <span class="param-type"><a href="global.html#prototype">prototype</a></span> | <span class="param-type"><a href="object.html">object</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the prototype/object to extend</td> </tr> <tr> <td class="name"><code>prop</code></td> <td class="type"> <span class="param-type"><a href="string.html">string</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the name of the property to be defined or modified</td> </tr> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">val to be used as value in the descriptor for the property, can be any kind of native (number, function, etc...) or what you want</td> </tr> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type"><a href="object.html">object</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>{}</code> </td> <td class="description last">options to be used as parameters in the descriptor for the property<br> possible options are (source documentation from <a href="https://developer.mozilla.org/it/docs/Web/JavaScript/Reference/Global_Objects/object/defineProperty" target="_blank">Javascript|MDN docs</a>)<br> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>configurable</code></td> <td class="type"> <span class="param-type"><a href="boolean.html">boolean</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">configurable - true if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding Object.</td> </tr> <tr> <td class="name"><code>enumerable</code></td> <td class="type"> <span class="param-type"><a href="boolean.html">boolean</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>false</code> </td> <td class="description last">enumerable - true if and only if this property shows up during enumeration of the properties on the corresponding Object.</td> </tr> <tr> <td class="name"><code>writable</code></td> <td class="type"> <span class="param-type"><a href="boolean.html">boolean</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">writable - true if and only if the value associated with the property may be changed with an assignment operator.</td> </tr> <tr> <td class="name"><code>get</code></td> <td class="type"> <span class="param-type"><a href="function.html">function</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">get - A function which serves as a getter for the property, or undefined if there is no getter. The function return will be used as the value of property.<br> for example...<br> <pre> function ClassName() { var privateProp = null; Object.defineProperty(this, 'publicProp', { get: function() { return privateProp; } }); } </pre></td> </tr> <tr> <td class="name"><code>set</code></td> <td class="type"> <span class="param-type"><a href="function.html">function</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">set - A function which serves as a setter for the property, or undefined if there is no setter. The function will receive as only argument the new value being assigned to the property.<br> for example...<br> <pre> function ClassName() { var privateProp = null; Object.defineProperty(this, 'publicProp', { set: function(value) { privateProp = value; } }); } </pre></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <h4 class="name" id="extendString"><span class="type-signature"></span>extendString<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line153">line 153</a> </li></ul></dd> </dl> <div class="description"> extendString </div> <h4 class="name" id="init"><span class="type-signature"></span>init<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="flavor.js.html">flavor.js</a>, <a href="flavor.js.html#line175">line 175</a> </li></ul></dd> </dl> <div class="description"> initialize all </div> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> on Fri Jun 14 2019 15:20:48 GMT+0200 (CEST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>