Skip to content

Commit

Permalink
Adds FuncName
Browse files Browse the repository at this point in the history
  • Loading branch information
Carles committed Jun 17, 2019
1 parent 80faaed commit 389330e
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 241 deletions.
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Breaking changes
- Changes signature `setPrecision` to `setPrecisionOr`

## New features
- Adds `IsNumber`: returns true if it is a real number.

## Improvements
- Improves `parseOr`
- **Bug** Fixes `floatOr` ...

## Minor things
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
[![install size](https://packagephobia.now.sh/badge?p=keyu)](https://packagephobia.now.sh/result?p=keyu)
[![Known Vulnerabilities](https://snyk.io/test/npm/keyu/badge.svg)](https://snyk.io/test/npm/keyu)

[![NPM](https://nodei.co/npm/keyu.png)](https://nodei.co/npm/keyu/)

**Keyu** (key utilities) provides **flexible** utilities to help you build **solid** projects <u>without repeating yourself</u>.
This library pretends to **fix** those **anoying things** that you find every day **when you write JavaScript**

Expand All @@ -15,9 +13,20 @@ The library helps you:
- Write functional programming code in javascript
- Combine sync and async functions easly
- Do safe conversions
- Check javascript types correctly
- Work with any kind of collection
- Apply complex concurrency patterns ([Rob Pike](https://www.youtube.com/watch?v=f6kdp27TYZs)).

Documentation: https://nerac.github.io/keyu/

Repository: https://github.com/nerac/keyu

License: [MIT](https://github.com/nerac/keyu/blob/master/LICENSE)

## Contribute

If you find yourself repeating over and over the same function maybe it should be here.
This repository is completely open to any kind of contribution that will simplify Javascript
developers time.

All contributors will be added
17 changes: 14 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ <h1>
<li>Write functional programming code in javascript</li>
<li>Combine sync and async functions easly</li>
<li>Do safe conversions</li>
<li>Check javascript types correctly</li>
<li>Work with any kind of collection</li>
<li>Apply complex concurrency patterns (<a href="https://www.youtube.com/watch?v=f6kdp27TYZs">Rob Pike</a>).</li>
</ul>
<p>Documentation: https://nerac.github.io/keyu/
Repository: https://github.com/nerac/keyu
License: <a href="https://github.com/nerac/keyu/blob/master/LICENSE">MIT</a></p>
<h2>Contribute</h2>
<p>If you find yourself repeating over and over the same function maybe it should be here.
This repository is completely open to any kind of contribution that will simplify Javascript
developers time.</p>
<p>All contributors will be added</p>
</article>
<div class="symbol-index">
<section>
Expand Down Expand Up @@ -303,7 +309,7 @@ <h2 id="types">types</h2>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="module-types.html#~isNil" class="!symbol-index-name">types~<wbr>isNil(num)</a>
<a href="module-types.html#~getFuncName" class="!symbol-index-name">types~<wbr>getFuncName([defaultValue])</a>
</dt>
<dd>
</dd>
Expand All @@ -312,19 +318,24 @@ <h2 id="types">types</h2>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="module-types.html#~isNumber" class="!symbol-index-name">types~<wbr>isNumber(num)</a>
<a href="module-types.html#~isNil" class="!symbol-index-name">types~<wbr>isNil(num)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="module-types.html#~isObject" class="!symbol-index-name">types~<wbr>isObject(num)</a>
<a href="module-types.html#~isNumber" class="!symbol-index-name">types~<wbr>isNumber(num)</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="module-types.html#~isObject" class="!symbol-index-name">types~<wbr>isObject(num)</a>
</dt>
<dd>
</dd>
</dl>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/logic_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h1>Source: logic/index.js</h1>
* @example
* [1,2].map(identity) // -&gt; [1,2]
* @method
*/
*/
const identity &#x3D; x &#x3D;&gt; x;
/** Function that negates any passed function value
* @argument {Function} fn function to be negated
Expand All @@ -80,7 +80,7 @@ <h1>Source: logic/index.js</h1>
* const isNumber &#x3D; not(isNaN)
* isNumber(33) // -&gt; true
* @method
*/
*/
const not &#x3D; fn &#x3D;&gt; (...args) &#x3D;&gt; !fn(...args);

module.exports &#x3D; { either, fnOrValue, identity, not };
Expand Down
228 changes: 1 addition & 227 deletions docs/module-logic.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ <h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-logic.html#~either">either(mainFn, failOver)</a></dt>
<dd>
</dd>
<dt><a href="module-logic.html#~either">either(mainFn, failOver)</a></dt>
<dd>
</dd>
Expand All @@ -51,26 +48,15 @@ <h2 class="summary-callout-heading">Methods</h2>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-logic.html#~fnOrValue">fnOrValue(fnOrVal)</a></dt>
<dd>
</dd>
<dt><a href="module-logic.html#~identity">identity(x)</a></dt>
<dd>
</dd>
<dt><a href="module-logic.html#~identity">identity(x)</a></dt>
<dt><a href="module-logic.html#~not">not(fn)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="module-logic.html#~not">not(fn)</a></dt>
<dd>
</dd>
<dt><a href="module-logic.html#~not">not(fn)</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
Expand Down Expand Up @@ -146,123 +132,6 @@ <h4>Parameters</h4>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
<h3 id="~either"><span class="symbol-name">either</span><span class="signature"><span class="signature-params">(mainFn, failOver)</span>&nbsp;&rarr; <span class="signature-returns"> function()</span></span></h3>
<p>Will evaluate the first function, if it throws any exception will evaluate the second one.</p>
<section>
<h4>
Examples
</h4>
<div>
<pre class="prettyprint"><code>const jsonOr &#x3D; either(parse.JSON,value &#x3D;&gt; &#x60;Cannot parse ${value} as json&#x60;)
jsonOr(null) // -&gt; &quot;Cannot parse null as json&quot;</code></pre>
</div>
<div>
<pre class="prettyprint"><code>const jsonOr &#x3D; either(parse.JSON,33)
jsonOr(null) // -&gt; 33
jsonOr(&#x27;{&quot;a&quot;:1}&#x27;) // -&gt; {a:1}</code></pre>
</div>
</section>
<section>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>mainFn</p>
</td>
<td>
<p>function()</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>function to be executed.</p>
</td>
</tr>
<tr>
<td>
<p>failOver</p>
</td>
<td>
<p>(function() or any type)</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>function or value to fail over if first one fails.</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>function()</code> <p>excepting to receive fn arguments.</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
<h3 id="~fnOrValue"><span class="symbol-name">fnOrValue</span><span class="signature"><span class="signature-params">(fnOrVal)</span>&nbsp;&rarr; <span class="signature-returns"> any type</span></span></h3>
<p>Given a value that can be a function if it's a function we call it passing the data to it
if not we just return it</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>fnOrValue(3,4) // -&gt; 3
fnOrValue(4,null) // -&gt; 4
fnOrValue(x &#x3D;&gt; x+1,4) // -&gt; 5
fnOrValue(x &#x3D;&gt; x*2,4) // -&gt; 8</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fnOrVal</p>
</td>
<td>
<p>(function() or any type)</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>a function or any value</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>any type</code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
<h3 id="~fnOrValue"><span class="symbol-name">fnOrValue</span><span class="signature"><span class="signature-params">(fnOrVal)</span>&nbsp;&rarr; <span class="signature-returns"> any type</span></span></h3>
<p>Given a value that can be a function if it's a function we call it passing the data to it
if not we just return it</p>
Expand Down Expand Up @@ -360,101 +229,6 @@ <h4>Parameter</h4>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
<h3 id="~identity"><span class="symbol-name">identity</span><span class="signature"><span class="signature-params">(x)</span>&nbsp;&rarr; <span class="signature-returns"> any type</span></span></h3>
<p>Function that returns the passed value</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>[1,2].map(identity) // -&gt; [1,2]</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>x</p>
</td>
<td>
<p>any type</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>any value</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>any type</code> <p>any value</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
<h3 id="~not"><span class="symbol-name">not</span><span class="signature"><span class="signature-params">(fn)</span>&nbsp;&rarr; <span class="signature-returns"> Boolean</span></span></h3>
<p>Function that negates any passed function value</p>
<section>
<h4>
Example
</h4>
<div>
<pre class="prettyprint"><code>const isNumber &#x3D; not(isNaN)
isNumber(33) // -&gt; true</code></pre>
</div>
</section>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>fn</p>
</td>
<td>
<p>function()</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>function to be negated</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Boolean</code> <p>negated boolean value</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
<h3 id="~not"><span class="symbol-name">not</span><span class="signature"><span class="signature-params">(fn)</span>&nbsp;&rarr; <span class="signature-returns"> Boolean</span></span></h3>
<p>Function that negates any passed function value</p>
<section>
Expand Down

0 comments on commit 389330e

Please sign in to comment.