Skip to content

Commit cb909e5

Browse files
committed
explainer: Add examples from ramda.js
1 parent dd3c568 commit cb909e5

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,25 @@ Only minor formatting changes have been made to the status-quo examples.
532532
<tr>
533533
<td>
534534

535+
```js
536+
return equals(
537+
take(prefix.length, list),
538+
prefix,
539+
);
540+
```
541+
From [ramda.js][].
542+
543+
<td>
544+
545+
```js
546+
return list
547+
|> take(prefix.length, %)
548+
|> equals(%, prefix);
549+
```
550+
551+
<tr>
552+
<td>
553+
535554
```js
536555
var minLoc = Object.keys(
537556
grunt.config(
@@ -635,6 +654,55 @@ return data
635654
<tr>
636655
<td>
637656

657+
```js
658+
return xf['@@transducer/result'](
659+
obj[methodName](
660+
bind(xf['@@transducer/step'], xf),
661+
acc,
662+
),
663+
);
664+
```
665+
From [ramda.js][].
666+
667+
<td>
668+
669+
```js
670+
return xf
671+
|> bind(%[@@transducer/step'], %)
672+
|> obj[methodName](%, acc)
673+
|> xf['@@transducer/result'](%);
674+
```
675+
676+
<tr>
677+
<td>
678+
679+
```js
680+
try {
681+
return tryer.apply(this, arguments);
682+
} catch (e) {
683+
return catcher.apply(this,
684+
_concat([e], arguments),
685+
);
686+
}
687+
```
688+
From [ramda.js][].
689+
690+
<td>
691+
692+
```js
693+
try {
694+
return arguments
695+
|> tryer.apply(this, %);
696+
} catch (e) {
697+
return arguments
698+
|> _concat([e], arguments)
699+
|> catcher.apply(this, %);
700+
}
701+
```
702+
703+
<tr>
704+
<td>
705+
638706
```js
639707
const entries =
640708
Object.entries(
@@ -761,6 +829,32 @@ return self
761829
<tr>
762830
<td>
763831
832+
```js
833+
return _reduce(
834+
xf(
835+
typeof fn === 'function'
836+
? _xwrap(fn)
837+
: fn,
838+
),
839+
acc, list,
840+
);
841+
```
842+
From [ramda.js][].
843+
844+
<td>
845+
846+
```js
847+
return fn
848+
|> typeof % === 'function'
849+
? _xwrap(%)
850+
: %
851+
|> xf(%)
852+
|> _reduce(%, acc, list);
853+
```
854+
855+
<tr>
856+
<td>
857+
764858
```js
765859
if (obj == null) return 0;
766860
return isArrayLike(obj)
@@ -835,6 +929,7 @@ return context
835929

836930
</table>
837931

932+
[ramda.js]: https://github.com/ramda/ramda/blob/v0.27.1/dist/ramda.js
838933
[node/deps/npm/lib/unpublish.js]: https://github.com/nodejs/node/blob/v16.x/deps/npm/lib/unpublish.js
839934
[node/deps/v8/test/mjsunit/regress/regress-crbug-158185.js]: https://github.com/nodejs/node/blob/v16.x/deps/v8/test/mjsunit/regress/regress-crbug-158185.js
840935
[express/lib/response.js]: https://github.com/expressjs/express/blob/5.0/lib/response.js

0 commit comments

Comments
 (0)