1 | <!doctype html>
|
2 | <html>
|
3 |
|
4 | <head>
|
5 | <meta name="generator" content="JSDoc 3.6.2">
|
6 | <meta charset="utf-8">
|
7 | <title>keyu 2.0.0 » Module: logic</title>
|
8 | <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
9 | <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
10 | <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
11 | <link href="css/baseline.css" rel="stylesheet">
|
12 | </head>
|
13 |
|
14 | <body onload="prettyPrint()">
|
15 | <nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
16 | <div id="jsdoc-navbar-container">
|
17 | <div id="jsdoc-navbar-content">
|
18 | <a href="index.html" class="jsdoc-navbar-package-name">keyu 2.<wbr>0.<wbr>0</a>
|
19 | </div>
|
20 | </div>
|
21 | </nav>
|
22 | <div id="jsdoc-body-container">
|
23 | <div id="jsdoc-content">
|
24 | <div id="jsdoc-content-container">
|
25 | <div id="jsdoc-main" role="main">
|
26 | <header class="page-header">
|
27 | <div class="symbol-detail-labels"><span class="label label-kind">module</span></div>
|
28 | <h1><small></small><span class="symbol-name">logic</span></h1>
|
29 | <p class="source-link">Source: <a href="logic_index.js.html">logic/<wbr>index.<wbr>js</a></p>
|
30 | <div class="symbol-description">
|
31 | </div>
|
32 | <dl class="dl-compact">
|
33 | </dl>
|
34 | </header>
|
35 | <section id="summary">
|
36 | <div class="summary-callout">
|
37 | <h2 class="summary-callout-heading">Methods</h2>
|
38 | <div class="summary-content">
|
39 | <div class="summary-column">
|
40 | <dl class="dl-summary-callout">
|
41 | <dt><a href="module-logic.html#~either">either(mainFn, failOver)</a></dt>
|
42 | <dd>
|
43 | </dd>
|
44 | <dt><a href="module-logic.html#~fnOrValue">fnOrValue(fnOrVal)</a></dt>
|
45 | <dd>
|
46 | </dd>
|
47 | </dl>
|
48 | </div>
|
49 | <div class="summary-column">
|
50 | <dl class="dl-summary-callout">
|
51 | <dt><a href="module-logic.html#~identity">identity(x)</a></dt>
|
52 | <dd>
|
53 | </dd>
|
54 | <dt><a href="module-logic.html#~not">not(fn)</a></dt>
|
55 | <dd>
|
56 | </dd>
|
57 | </dl>
|
58 | </div>
|
59 | <div class="summary-column">
|
60 | </div>
|
61 | </div>
|
62 | </div>
|
63 | </section>
|
64 | <section>
|
65 | <h2>Methods</h2>
|
66 | <section>
|
67 | <div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
|
68 | <h3 id="~either"><span class="symbol-name">either</span><span class="signature"><span class="signature-params">(mainFn, failOver)</span> → <span class="signature-returns"> function()</span></span></h3>
|
69 | <p>Will evaluate the first function, if it throws any exception will evaluate the second one.</p>
|
70 | <section>
|
71 | <h4>
|
72 | Examples
|
73 | </h4>
|
74 | <div>
|
75 | <pre class="prettyprint"><code>const jsonOr = either(parse.JSON,value => `Cannot parse ${value} as json`)
|
76 | jsonOr(null) // -> "Cannot parse null as json"</code></pre>
|
77 | </div>
|
78 | <div>
|
79 | <pre class="prettyprint"><code>const jsonOr = either(parse.JSON,33)
|
80 | jsonOr(null) // -> 33
|
81 | jsonOr('{"a":1}') // -> {a:1}</code></pre>
|
82 | </div>
|
83 | </section>
|
84 | <section>
|
85 | <h4>Parameters</h4>
|
86 | <table class="jsdoc-details-table">
|
87 | <thead>
|
88 | <tr>
|
89 | <th>Name</th>
|
90 | <th>Type</th>
|
91 | <th>Optional</th>
|
92 | <th>Description</th>
|
93 | </tr>
|
94 | </thead>
|
95 | <tbody>
|
96 | <tr>
|
97 | <td>
|
98 | <p>mainFn</p>
|
99 | </td>
|
100 | <td>
|
101 | <p>function()</p>
|
102 | </td>
|
103 | <td>
|
104 | <p> </p>
|
105 | </td>
|
106 | <td>
|
107 | <p>function to be executed.</p>
|
108 | </td>
|
109 | </tr>
|
110 | <tr>
|
111 | <td>
|
112 | <p>failOver</p>
|
113 | </td>
|
114 | <td>
|
115 | <p>(function() or any type)</p>
|
116 | </td>
|
117 | <td>
|
118 | <p> </p>
|
119 | </td>
|
120 | <td>
|
121 | <p>function or value to fail over if first one fails.</p>
|
122 | </td>
|
123 | </tr>
|
124 | </tbody>
|
125 | </table>
|
126 | </section>
|
127 | <dl class="dl-compact">
|
128 | <dt>Returns</dt>
|
129 | <dd>
|
130 | <p><code>function()</code> <p>excepting to receive fn arguments.</p>
|
131 | </p>
|
132 | </dd>
|
133 | </dl>
|
134 | <div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
|
135 | <h3 id="~fnOrValue"><span class="symbol-name">fnOrValue</span><span class="signature"><span class="signature-params">(fnOrVal)</span> → <span class="signature-returns"> any type</span></span></h3>
|
136 | <p>Given a value that can be a function if it's a function we call it passing the data to it
|
137 | if not we just return it</p>
|
138 | <section>
|
139 | <h4>
|
140 | Example
|
141 | </h4>
|
142 | <div>
|
143 | <pre class="prettyprint"><code>fnOrValue(3,4) // -> 3
|
144 | fnOrValue(4,null) // -> 4
|
145 | fnOrValue(x => x+1,4) // -> 5
|
146 | fnOrValue(x => x*2,4) // -> 8</code></pre>
|
147 | </div>
|
148 | </section>
|
149 | <section>
|
150 | <h4>Parameter</h4>
|
151 | <table class="jsdoc-details-table">
|
152 | <thead>
|
153 | <tr>
|
154 | <th>Name</th>
|
155 | <th>Type</th>
|
156 | <th>Optional</th>
|
157 | <th>Description</th>
|
158 | </tr>
|
159 | </thead>
|
160 | <tbody>
|
161 | <tr>
|
162 | <td>
|
163 | <p>fnOrVal</p>
|
164 | </td>
|
165 | <td>
|
166 | <p>(function() or any type)</p>
|
167 | </td>
|
168 | <td>
|
169 | <p> </p>
|
170 | </td>
|
171 | <td>
|
172 | <p>a function or any value</p>
|
173 | </td>
|
174 | </tr>
|
175 | </tbody>
|
176 | </table>
|
177 | </section>
|
178 | <dl class="dl-compact">
|
179 | <dt>Returns</dt>
|
180 | <dd>
|
181 | <p><code>any type</code> </p>
|
182 | </dd>
|
183 | </dl>
|
184 | <div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
|
185 | <h3 id="~identity"><span class="symbol-name">identity</span><span class="signature"><span class="signature-params">(x)</span> → <span class="signature-returns"> any type</span></span></h3>
|
186 | <p>Function that returns the passed value</p>
|
187 | <section>
|
188 | <h4>
|
189 | Example
|
190 | </h4>
|
191 | <div>
|
192 | <pre class="prettyprint"><code>[1,2].map(identity) // -> [1,2]</code></pre>
|
193 | </div>
|
194 | </section>
|
195 | <section>
|
196 | <h4>Parameter</h4>
|
197 | <table class="jsdoc-details-table">
|
198 | <thead>
|
199 | <tr>
|
200 | <th>Name</th>
|
201 | <th>Type</th>
|
202 | <th>Optional</th>
|
203 | <th>Description</th>
|
204 | </tr>
|
205 | </thead>
|
206 | <tbody>
|
207 | <tr>
|
208 | <td>
|
209 | <p>x</p>
|
210 | </td>
|
211 | <td>
|
212 | <p>any type</p>
|
213 | </td>
|
214 | <td>
|
215 | <p> </p>
|
216 | </td>
|
217 | <td>
|
218 | <p>any value</p>
|
219 | </td>
|
220 | </tr>
|
221 | </tbody>
|
222 | </table>
|
223 | </section>
|
224 | <dl class="dl-compact">
|
225 | <dt>Returns</dt>
|
226 | <dd>
|
227 | <p><code>any type</code> <p>any value</p>
|
228 | </p>
|
229 | </dd>
|
230 | </dl>
|
231 | <div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
|
232 | <h3 id="~not"><span class="symbol-name">not</span><span class="signature"><span class="signature-params">(fn)</span> → <span class="signature-returns"> Boolean</span></span></h3>
|
233 | <p>Function that negates any passed function value</p>
|
234 | <section>
|
235 | <h4>
|
236 | Example
|
237 | </h4>
|
238 | <div>
|
239 | <pre class="prettyprint"><code>const isNumber = not(isNaN)
|
240 | isNumber(33) // -> true</code></pre>
|
241 | </div>
|
242 | </section>
|
243 | <section>
|
244 | <h4>Parameter</h4>
|
245 | <table class="jsdoc-details-table">
|
246 | <thead>
|
247 | <tr>
|
248 | <th>Name</th>
|
249 | <th>Type</th>
|
250 | <th>Optional</th>
|
251 | <th>Description</th>
|
252 | </tr>
|
253 | </thead>
|
254 | <tbody>
|
255 | <tr>
|
256 | <td>
|
257 | <p>fn</p>
|
258 | </td>
|
259 | <td>
|
260 | <p>function()</p>
|
261 | </td>
|
262 | <td>
|
263 | <p> </p>
|
264 | </td>
|
265 | <td>
|
266 | <p>function to be negated</p>
|
267 | </td>
|
268 | </tr>
|
269 | </tbody>
|
270 | </table>
|
271 | </section>
|
272 | <dl class="dl-compact">
|
273 | <dt>Returns</dt>
|
274 | <dd>
|
275 | <p><code>Boolean</code> <p>negated boolean value</p>
|
276 | </p>
|
277 | </dd>
|
278 | </dl>
|
279 | </section>
|
280 | </section>
|
281 | </div>
|
282 | </div>
|
283 | <nav id="jsdoc-toc-nav" role="navigation"></nav>
|
284 | </div>
|
285 | </div>
|
286 | <footer id="jsdoc-footer" class="jsdoc-footer">
|
287 | <div id="jsdoc-footer-container">
|
288 | <p>
|
289 | Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.2 on June 17, 2019.
|
290 | </p>
|
291 | </div>
|
292 | </footer>
|
293 | <script src="scripts/jquery.min.js"></script>
|
294 | <script src="scripts/jquery.cookie.js"></script>
|
295 | <script src="scripts/tree.jquery.js"></script>
|
296 | <script src="scripts/prettify.js"></script>
|
297 | <script src="scripts/jsdoc-toc.js"></script>
|
298 | <script src="scripts/linenumber.js"></script>
|
299 | <script src="scripts/scrollanchor.js"></script>
|
300 | </body>
|
301 |
|
302 | </html> |
\ | No newline at end of file |