|
1 | | -'use strinct'; |
| 1 | +'use strict'; |
2 | 2 |
|
3 | 3 | Function.prototype.curry = function(...args) { |
4 | 4 | return this.bind(null, ...args); |
5 | 5 | }; |
6 | 6 |
|
7 | | -let persons = [ |
| 7 | +const persons = [ |
8 | 8 | { name: 'Marcus Aurelius', city: 'Rome', born: 121 }, |
9 | 9 | { name: 'Victor Glushkov', city: 'Rostov on Don', born: 1923 }, |
10 | 10 | { name: 'Ibn Arabi', city: 'Murcia', born: 1165 }, |
11 | 11 | { name: 'Mao Zedong', city: 'Shaoshan', born: 1893 }, |
12 | 12 | { name: 'Rene Descartes', city: 'La Haye en Touraine', born: 1596 } |
13 | 13 | ]; |
14 | 14 |
|
15 | | -let md = { |
| 15 | +const md = { |
16 | 16 | name: ['name'], |
17 | 17 | place: ['city', upper, s => '<' + s + '>'], |
18 | 18 | age: ['born', age] |
19 | 19 | }; |
20 | 20 |
|
21 | | -let projection = (meta, obj) => (Object |
| 21 | +const projection = (meta, obj) => (Object |
22 | 22 | .keys(meta) |
23 | 23 | .reduce((hash, key) => (hash[key] = meta[key] |
24 | 24 | .reduce( |
25 | | - (val, fn, i) => i === 0 ? obj[fn] : fn(val), null |
| 25 | + (val, fn, i) => (i === 0 ? obj[fn] : fn(val)), null |
26 | 26 | ), hash), {} |
27 | 27 | ) |
28 | 28 | ); |
29 | 29 |
|
30 | | -let p1 = projection.curry(md); |
31 | | -let data = persons.map(p1); |
| 30 | +const p1 = projection.curry(md); |
| 31 | +const data = persons.map(p1); |
32 | 32 | console.dir(data); |
33 | 33 |
|
34 | 34 | function capitalize(s) { |
35 | | - return s.replace(/\w+/g, function(word) { |
36 | | - return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); |
37 | | - }); |
| 35 | + return s.replace(/\w+/g, (word) => |
| 36 | + word.charAt(0).toUpperCase() + word.substr(1).toLowerCase() |
| 37 | + ); |
38 | 38 | } |
39 | 39 |
|
40 | 40 | function upper(s) { |
|
0 commit comments