8000 Aff functional example · HowProgrammingWorks/Factory@4cfd697 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cfd697

Browse files
committed
Aff functional example
1 parent 5c10132 commit 4cfd697

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

JavaScript/4-function.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
const logger = (level = 'info') => {
4+
const colors = {
5+
warning: '\x1b[1;33m',
6+
error: '\x1b[0;31m',
7+
info: '\x1b[1;37m'
8+
};
9+
const color = colors[level] || colors.info;
10+
return s => {
11+
const date = new Date().toISOString();
12+
console.log(color + date + '\t' + s);
13+
};
14+
};
15+
16+
const warning = logger('warning');
17+
warning('Hello');

0 commit comments

Comments
 (0)
0