@@ -23,32 +23,32 @@ const data = [
23
23
lastName : 'Maggio' ,
24
24
25
25
age : '80' ,
26
- gender : 'male' ,
26
+ gender : 'male'
27
27
} ,
28
28
tags : [ '1' , '2' ] ,
29
29
photos : [
30
30
'ed70cf44-9a34-4878-84e6-0c0e4a450cfe' ,
31
31
'24ba3666-a593-498c-9f5d-55a4ee08c72e' ,
32
- 'f386492d-df61-4573-b4e3-54f6f5d08acf' ,
32
+ 'f386492d-df61-4573-b4e3-54f6f5d08acf'
33
33
] ,
34
34
comments : [
35
35
{
36
36
_id : '1' ,
37
37
body : 'First !' ,
38
- created : '2015-08-14T18:42:16.475Z' ,
38
+ created : '2015-08-14T18:42:16.475Z'
39
39
} ,
40
40
{
41
41
_id : '2' ,
42
42
body : 'I Like !' ,
43
- created : '2015-09-14T18:42:12.475Z' ,
43
+ created : '2015-09-14T18:42:12.475Z'
44
44
} ,
45
45
{
46
46
_id : '3' ,
47
47
body : 'Awesome' ,
48
- created : '2015-09-15T18:42:12.475Z' ,
49
- } ,
50
- ] ,
51
- } ,
48
+ created : '2015-09-15T18:42:12.475Z'
49
+ }
50
+ ]
51
+ }
52
52
] ;
53
53
54
54
serializer . register ( 'article' , {
@@ -58,7 +58,7 @@ serializer.register('article', {
58
58
self ( d ) {
59
59
// Can be a function or a string value ex: { self: '/articles/1'}
60
60
return `/articles/${ d . id } ` ;
61
- } ,
61
+ }
62
62
} ,
63
63
relationships : {
64
64
// An object defining some relationships.
@@ -68,32 +68,32 @@ serializer.register('article', {
68
68
// An object or a function that describes Relationships links
69
69
return {
70
70
self : `/articles/${ d . id } /relationships/author` ,
71
- related : `/articles/${ d . id } /author` ,
71
+ related : `/articles/${ d . id } /author`
72
72
} ;
73
- } ,
73
+ }
74
74
} ,
75
75
tags : {
76
- type : 'tag' ,
76
+ type : 'tag'
77
77
} ,
78
78
photos : {
79
- type : 'photo' ,
79
+ type : 'photo'
80
80
} ,
81
81
comments : {
82
82
type : 'comment' ,
83
- schema : 'only-body' , // A custom schema
84
- } ,
83
+ schema : 'only-body' // A custom schema
84
+ }
85
85
} ,
86
86
topLevelMeta ( d , extraData ) {
87
87
// An object or a function that describes top level meta.
88
88
return {
89
89
count : extraData . count ,
90
- total : d . length ,
90
+ total : d . length
91
91
} ;
92
92
} ,
93
93
topLevelLinks : {
94
94
// An object or a function that describes top level links.
95
- self : '/articles' , // Can be a function (with extra data argument) or a string value
96
- } ,
95
+ self : '/articles' // Can be a function (with extra data argument) or a string value
96
+ }
97
97
} ) ;
98
98
99
99
// Register 'people' type
@@ -102,23 +102,23 @@ serializer.register('people', {
102
102
links : {
103
103
self ( d ) {
104
104
return `/peoples/${ d . id } ` ;
105
- } ,
106
- } ,
105
+ }
106
+ }
107
107
} ) ;
108
108
109
109
// Register 'tag' type
110
110
serializer . register ( 'tag' , {
111
- id : 'id' ,
111
+ id : 'id'
112
112
} ) ;
113
113
114
114
// Register 'photo' type
115
115
serializer . register ( 'photo' , {
116
- id : 'id' ,
116
+ id : 'id'
117
117
} ) ;
118
118
119
119
// Register 'comment' type with a custom schema
120
120
serializer . register ( 'comment' , 'only-body' , {
121
- id : '_id' ,
121
+ id : '_id'
122
122
} ) ;
123
123
124
124
let serialized ;
@@ -131,13 +131,18 @@ console.log(`${os.type()} ${os.release()} ${os.arch()}`);
131
131
console . log ( 'Node.JS:' , process . versions . node ) ;
132
132
console . log ( 'V8:' , process . versions . v8 ) ;
133
133
134
- let cpus = os . cpus ( ) . map ( cpu => cpu . model ) . reduce ( ( o , model ) => {
135
- if ( ! o [ model ] ) o [ model ] = 0 ;
136
- o [ model ] += 1 ;
137
- return o ;
138
- } , { } ) ;
134
+ let cpus = os
135
+ . cpus ( )
136
+ . map ( cpu => cpu . model )
137
+ . reduce ( ( o , model ) => {
138
+ if ( ! o [ model ] ) o [ model ] = 0 ;
139
+ o [ model ] += 1 ;
140
+ return o ;
141
+ } , { } ) ;
139
142
140
- cpus = Object . keys ( cpus ) . map ( key => `${ key } \u00d7 ${ cpus [ key ] } ` ) . join ( '\n' ) ;
143
+ cpus = Object . keys ( cpus )
144
+ . map ( key => `${ key } \u00d7 ${ cpus [ key ] } ` )
145
+ . join ( '\n' ) ;
141
146
142
147
console . info ( cpus ) ;
143
148
@@ -147,17 +152,21 @@ suite
147
152
. add ( 'serializeAsync' , {
148
153
defer : true ,
149
154
fn ( deferred ) {
150
- serializer . serializeAsync ( 'article' , data , { count : 2 } ) . then ( ( ) => { deferred . resolve ( ) ; } ) ;
151
- } ,
155
+ serializer . serializeAsync ( 'article' , data , { count : 2 } ) . then ( ( ) => {
156
+ deferred . resolve ( ) ;
157
+ } ) ;
158
+ }
152
159
} )
153
160
. add ( 'serialize' , ( ) => {
154
161
serialized = serializer . serialize ( 'article' , data , { count : 2 } ) ;
155
162
} )
156
163
. add ( 'deserializeAsync' , {
157
164
defer : true ,
158
165
fn ( deferred ) {
159
- serializer . deserializeAsync ( 'article' , serialized ) . then ( ( ) => { deferred . resolve ( ) ; } ) ;
160
- } ,
166
+ serializer . deserializeAsync ( 'article' , serialized ) . then ( ( ) => {
167
+ deferred . resolve ( ) ;
168
+ } ) ;
169
+ }
161
170
} )
162
171
. add ( 'deserialize' , ( ) => {
163
172
serializer . deserialize ( 'article' , serialized ) ;
@@ -174,16 +183,15 @@ suite
174
183
status : '422' ,
175
184
source : { pointer : '/data/attributes/error' } ,
176
185
title : 'Error' ,
177
- detail : 'An error occured' ,
186
+ detail : 'An error occured'
178
187
} ;
179
188
180
189
serializer . serializeError ( jsonapiError ) ;
181
190
} )
182
191
// add listeners
183
- . on ( 'cycle' , ( event ) => {
192
+ . on ( 'cycle' , event => {
184
193
console . log ( String ( event . target ) ) ;
185
194
} )
186
- . on ( 'complete' , ( ) => {
187
- } )
188
- // run async
195
+ . on ( 'complete' , ( ) => { } )
196
+ // run async
189
197
. run ( { async : false } ) ;
0 commit comments