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: fp</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">fp</span></h1>
|
29 | <p class="source-link">Source: <a href="fp_index.js.html">fp/<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-fp.html#~compose">compose(arguments)</a></dt>
|
42 | <dd>
|
43 | </dd>
|
44 | <dt><a href="module-fp.html#~curry">curry(function)</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-fp.html#~mixCompose">mixCompose(chain, func)</a></dt>
|
52 | <dd>
|
53 | </dd>
|
54 | <dt><a href="module-fp.html#~pipe">pipe(arguments)</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="~compose"><span class="symbol-name">compose</span><span class="signature"><span class="signature-params">(arguments)</span> → <span class="signature-returns"> (function() or Promise)</span></span></h3>
|
69 | <p>Compose regular functions or promises generating a final function.</p>
|
70 | <ul>
|
71 | <li>Compose works from right to left.</li>
|
72 | <li>If you compose one single promise the final result will be a promise too.</li>
|
73 | <li>You can only compose functions with the same arity.</li>
|
74 | </ul>
|
75 | <section>
|
76 | <h4>
|
77 | Example
|
78 | </h4>
|
79 | <div>
|
80 | <pre class="prettyprint"><code>const sum3 = a => a+3
|
81 | const mult2 = a => a*2
|
82 | const sum2Async = a => Promise.resolve(a+2) // Simulate async response
|
83 |
|
84 | const sumAndMult = compose(sum3,mult2);
|
85 | sumAndMult(1) // -> (1*2)+3 = 5
|
86 |
|
87 | const sumAndMultAsync = compose(sum3,mult2,sum2Async);
|
88 | await sumAndMultAsync(1) // -> ((1+2)*2)+3 = 9</code></pre>
|
89 | </div>
|
90 | </section>
|
91 | <section>
|
92 | <h4>Parameter</h4>
|
93 | <table class="jsdoc-details-table">
|
94 | <thead>
|
95 | <tr>
|
96 | <th>Name</th>
|
97 | <th>Type</th>
|
98 | <th>Optional</th>
|
99 | <th>Description</th>
|
100 | </tr>
|
101 | </thead>
|
102 | <tbody>
|
103 | <tr>
|
104 | <td>
|
105 | <p>arguments</p>
|
106 | </td>
|
107 | <td>
|
108 | <p>(function() or Promise)</p>
|
109 | </td>
|
110 | <td>
|
111 | <p> </p>
|
112 | </td>
|
113 | <td>
|
114 | <p>N number of functions or promises.</p>
|
115 | </td>
|
116 | </tr>
|
117 | </tbody>
|
118 | </table>
|
119 | </section>
|
120 | <dl class="dl-compact">
|
121 | <dt>Returns</dt>
|
122 | <dd>
|
123 | <p><code>(function() or Promise)</code> <p>function or Promise that execute the all composed ones.</p>
|
124 | </p>
|
125 | </dd>
|
126 | </dl>
|
127 | <div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
|
128 | <h3 id="~curry"><span class="symbol-name">curry</span><span class="signature"><span class="signature-params">(function)</span> → <span class="signature-returns"> function()</span></span></h3>
|
129 | <p>Currify any function allowing the partial application of its arguments</p>
|
130 | <section>
|
131 | <h4>
|
132 | Example
|
133 | </h4>
|
134 | <div>
|
135 | <pre class="prettyprint"><code>const sum = curry((a,b) = a+b);
|
136 | const sum3 = sum(3);
|
137 | sum3(3) // -> 6
|
138 | sum(3,3) // -> 6
|
139 | sum(3)(3) // -> 6</code></pre>
|
140 | </div>
|
141 | </section>
|
142 | <section>
|
143 | <h4>Parameter</h4>
|
144 | <table class="jsdoc-details-table">
|
145 | <thead>
|
146 | <tr>
|
147 | <th>Name</th>
|
148 | <th>Type</th>
|
149 | <th>Optional</th>
|
150 | <th>Description</th>
|
151 | </tr>
|
152 | </thead>
|
153 | <tbody>
|
154 | <tr>
|
155 | <td>
|
156 | <p>function</p>
|
157 | </td>
|
158 | <td>
|
159 | <p>function()</p>
|
160 | </td>
|
161 | <td>
|
162 | <p> </p>
|
163 | </td>
|
164 | <td>
|
165 | <p>function with at least two arguments</p>
|
166 | </td>
|
167 | </tr>
|
168 | </tbody>
|
169 | </table>
|
170 | </section>
|
171 | <dl class="dl-compact">
|
172 | <dt>Returns</dt>
|
173 | <dd>
|
174 | <p><code>function()</code> <p>curried function.</p>
|
175 | </p>
|
176 | </dd>
|
177 | </dl>
|
178 | <div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
|
179 | <h3 id="~mixCompose"><span class="symbol-name">mixCompose</span><span class="signature"><span class="signature-params">(chain, func)</span></span></h3>
|
180 | <p>Reducer function used by <code>pipe</code> and <code>compose</code> functions to compose sync and async functions</p>
|
181 | <section>
|
182 | <h4>Parameters</h4>
|
183 | <table class="jsdoc-details-table">
|
184 | <thead>
|
185 | <tr>
|
186 | <th>Name</th>
|
187 | <th>Type</th>
|
188 | <th>Optional</th>
|
189 | <th>Description</th>
|
190 | </tr>
|
191 | </thead>
|
192 | <tbody>
|
193 | <tr>
|
194 | <td>
|
195 | <p>chain</p>
|
196 | </td>
|
197 | <td>
|
198 | <p>(function() or Promise)</p>
|
199 | </td>
|
200 | <td>
|
201 | <p> </p>
|
202 | </td>
|
203 | <td>
|
204 | <p>a chain of functions or promises</p>
|
205 | </td>
|
206 | </tr>
|
207 | <tr>
|
208 | <td>
|
209 | <p>func</p>
|
210 | </td>
|
211 | <td>
|
212 | <p>(function() or Promise)</p>
|
213 | </td>
|
214 | <td>
|
215 | <p> </p>
|
216 | </td>
|
217 | <td>
|
218 | <p>a new function or promise to add to the chain</p>
|
219 | </td>
|
220 | </tr>
|
221 | </tbody>
|
222 | </table>
|
223 | </section>
|
224 | <dl class="dl-compact">
|
225 | </dl>
|
226 | <div class="symbol-detail-labels"><span class="label label-inner">inner</span></div>
|
227 | <h3 id="~pipe"><span class="symbol-name">pipe</span><span class="signature"><span class="signature-params">(arguments)</span> → <span class="signature-returns"> (function() or Promise)</span></span></h3>
|
228 | <p>Compose regular functions or promises generating a final function.</p>
|
229 | <ul>
|
230 | <li>Compose works from left to right.</li>
|
231 | <li>If you compose one single promise the final result will be a promise too.</li>
|
232 | <li>You can only compose functions with the same arity.</li>
|
233 | </ul>
|
234 | <section>
|
235 | <h4>
|
236 | Example
|
237 | </h4>
|
238 | <div>
|
239 | <pre class="prettyprint"><code>const sum3 = a => a+3
|
240 | const mult2 = a => a*2
|
241 | const sum2Async = a => Promise.resolve(a+2) // Simulate async response
|
242 |
|
243 | const sumAndMult = pipe(sum3,mult2);
|
244 | sumAndMult(1) // -> (1+3)*2 = 8
|
245 |
|
246 | const sumAndMultAsync = pipe(sum3,mult2,sum2Async);
|
247 | await sumAndMultAsync(1) // -> ((1+3)*2)+2 = 10</code></pre>
|
248 | </div>
|
249 | </section>
|
250 | <section>
|
251 | <h4>Parameter</h4>
|
252 | <table class="jsdoc-details-table">
|
253 | <thead>
|
254 | <tr>
|
255 | <th>Name</th>
|
256 | <th>Type</th>
|
257 | <th>Optional</th>
|
258 | <th>Description</th>
|
259 | </tr>
|
260 | </thead>
|
261 | <tbody>
|
262 | <tr>
|
263 | <td>
|
264 | <p>arguments</p>
|
265 | </td>
|
266 | <td>
|
267 | <p>(function() or Promise)</p>
|
268 | </td>
|
269 | <td>
|
270 | <p> </p>
|
271 | </td>
|
272 | <td>
|
273 | <p>N number of functions or promises.</p>
|
274 | </td>
|
275 | </tr>
|
276 | </tbody>
|
277 | </table>
|
278 | </section>
|
279 | <dl class="dl-compact">
|
280 | <dt>Returns</dt>
|
281 | <dd>
|
282 | <p><code>(function() or Promise)</code> <p>function or Promise that execute the all composed ones.</p>
|
283 | </p>
|
284 | </dd>
|
285 | </dl>
|
286 | </section>
|
287 | </section>
|
288 | </div>
|
289 | </div>
|
290 | <nav id="jsdoc-toc-nav" role="navigation"></nav>
|
291 | </div>
|
292 | </div>
|
293 | <footer id="jsdoc-footer" class="jsdoc-footer">
|
294 | <div id="jsdoc-footer-container">
|
295 | <p>
|
296 | Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.2 on June 17, 2019.
|
297 | </p>
|
298 | </div>
|
299 | </footer>
|
300 | <script src="scripts/jquery.min.js"></script>
|
301 | <script src="scripts/jquery.cookie.js"></script>
|
302 | <script src="scripts/tree.jquery.js"></script>
|
303 | <script src="scripts/prettify.js"></script>
|
304 | <script src="scripts/jsdoc-toc.js"></script>
|
305 | <script src="scripts/linenumber.js"></script>
|
306 | <script src="scripts/scrollanchor.js"></script>
|
307 | </body>
|
308 |
|
309 | </html> |
\ | No newline at end of file |