File tree Expand file tree Collapse file tree 1 file changed +7
-22
lines changed
Expand file tree Collapse file tree 1 file changed +7
-22
lines changed Original file line number Diff line number Diff line change @@ -10,19 +10,22 @@ const persons = [
1010
1111const md = {
1212 name : [ 'name' ] ,
13- place : [ 'city' , s => '<' + upper ( s ) + '>' ] ,
13+ place : [ 'city' , s => '<' + s . toUpperCase ( ) + '>' ] ,
1414 born : [ 'born' ] ,
1515 age : [ 'born' , age ]
1616} ;
1717
18+ function age ( year ) {
19+ return new Date ( ) . getFullYear ( ) - new Date ( year + '' ) . getFullYear ( ) ;
20+ }
21+
1822const projection = ( meta ) => {
1923 const keys = Object . keys ( meta ) ;
2024 return obj => {
2125 const hash = { } ;
22- let def , val ;
2326 keys . forEach ( key => {
24- def = meta [ key ] ;
25- val = obj [ def [ 0 ] ] ;
27+ const def = meta [ key ] ;
28+ let val = obj [ def [ 0 ] ] ;
2629 if ( def . length > 1 ) val = def [ 1 ] ( val ) ;
2730 hash [ key ] = val ;
2831 } ) ;
@@ -33,21 +36,3 @@ const projection = (meta) => {
3336const p1 = projection ( md ) ;
3437const data = persons . map ( p1 ) ;
3538console . dir ( data ) ;
36-
37- function capitalize ( s ) {
38- return s . replace ( / \w + / g, ( word ) =>
39- word . charAt ( 0 ) . toUpperCase ( ) + word . substr ( 1 ) . toLowerCase ( )
40- ) ;
41- }
42-
43- function upper ( s ) {
44- return typeof ( s ) === 'string' ? s . toUpperCase ( ) : '' ;
45- }
46-
47- function age ( year ) {
48- return new Date ( ) . getFullYear ( ) - new Date ( year + '' ) . getFullYear ( ) ;
49- }
50-
51- function inc ( x ) {
52- return ++ x ;
53- }
You can’t perform that action at this time.
0 commit comments