We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c36cf20 commit 6b682ecCopy full SHA for 6b682ec
JavaScript/maybe5.js
@@ -0,0 +1,11 @@
1
+'use strict';
2
+
3
+function maybe(x) {
4
+ return fn => maybe((x && fn) ? fn(x) : null);
5
+}
6
7
+maybe(5)(x => ++x)(console.log);
8
+maybe(5)(x => x * 2)(x => ++x)(console.log);
9
10
+maybe(5)(null)(console.log);
11
+maybe(null)(x => x * 2)(console.log);
0 commit comments