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 607a788 commit 6d0220dCopy full SHA for 6d0220d
JavaScript/2-before-after.js
@@ -0,0 +1,25 @@
1
+'use strict';
2
+
3
+const wrap = (before, after, fn) => (
4
+ (...args) => after(fn(...before(...args)))
5
+);
6
7
+// Usage
8
9
+const func = (par1, par2) => {
10
+ console.dir({ method: { par1, par2 } });
11
+ return [par1, par2];
12
+};
13
14
+const before = (...args) => {
15
+ console.log('before');
16
+ return args;
17
18
19
+const after = (...args) => {
20
+ console.log('after');
21
22
23
24
+const cloned = wrap(before, after, func);
25
+cloned('Uno', 'Due');
0 commit comments