@@ -11,7 +11,7 @@ const suite = new Benchmark.Suite();
11
11
const serializer = new JSONAPISerializer ( ) ;
12
12
const serializerConvert = new JSONAPISerializer ( {
13
13
convertCase : 'kebab-case' ,
14
- unconvertCase : 'camelCase'
14
+ unconvertCase : 'camelCase' ,
15
15
} ) ;
16
16
17
17
const data = [
@@ -27,32 +27,32 @@ const data = [
27
27
lastName : 'Maggio' ,
28
28
29
29
age : '80' ,
30
- gender : 'male'
30
+ gender : 'male' ,
31
31
} ,
32
32
tags : [ '1' , '2' ] ,
33
33
photos : [
34
34
'ed70cf44-9a34-4878-84e6-0c0e4a450cfe' ,
35
35
'24ba3666-a593-498c-9f5d-55a4ee08c72e' ,
36
- 'f386492d-df61-4573-b4e3-54f6f5d08acf'
36
+ 'f386492d-df61-4573-b4e3-54f6f5d08acf' ,
37
37
] ,
38
38
comments : [
39
39
{
40
40
_id : '1' ,
41
41
body : 'First !' ,
42
- created : '2015-08-14T18:42:16.475Z'
42
+ created : '2015-08-14T18:42:16.475Z' ,
43
43
} ,
44
44
{
45
45
_id : '2' ,
46
46
body : 'I Like !' ,
47
- created : '2015-09-14T18:42:12.475Z'
47
+ created : '2015-09-14T18:42:12.475Z' ,
48
48
} ,
49
49
{
50
50
_id : '3' ,
51
51
body : 'Awesome' ,
52
- created : '2015-09-15T18:42:12.475Z'
53
- }
54
- ]
55
- }
52
+ created : '2015-09-15T18:42:12.475Z' ,
53
+ } ,
54
+ ] ,
55
+ } ,
56
56
] ;
57
57
58
58
const articleSchema = {
@@ -62,7 +62,7 @@ const articleSchema = {
62
62
self ( d ) {
63
63
// Can be a function or a string value ex: { self: '/articles/1'}
64
64
return `/articles/${ d . id } ` ;
65
- }
65
+ } ,
66
66
} ,
67
67
relationships : {
68
68
// An object defining some relationships.
@@ -72,32 +72,32 @@ const articleSchema = {
72
72
// An object or a function that describes Relationships links
73
73
return {
74
74
self : `/articles/${ d . id } /relationships/author` ,
75
- related : `/articles/${ d . id } /author`
75
+ related : `/articles/${ d . id } /author` ,
76
76
} ;
77
- }
77
+ } ,
78
78
} ,
79
79
tags : {
80
- type : 'tag'
80
+ type : 'tag' ,
81
81
} ,
82
82
photos : {
83
- type : 'photo'
83
+ type : 'photo' ,
84
84
} ,
85
85
comments : {
86
86
type : 'comment' ,
87
- schema : 'only-body' // A custom schema
88
- }
87
+ schema : 'only-body' , // A custom schema
88
+ } ,
89
89
} ,
90
90
topLevelMeta ( d , extraData ) {
91
91
// An object or a function that describes top level meta.
92
92
return {
93
93
count : extraData . count ,
94
- total : d . length
94
+ total : d . length ,
95
95
} ;
96
96
} ,
97
97
topLevelLinks : {
98
98
// An object or a function that describes top level links.
99
- self : '/articles'
100
- }
99
+ self : '/articles' ,
100
+ } ,
101
101
} ;
102
102
serializer . register ( 'article' , articleSchema ) ;
103
103
serializerConvert . register ( 'article' , articleSchema ) ;
@@ -108,29 +108,29 @@ const peopleSchema = {
108
108
links : {
109
109
self ( d ) {
110
110
return `/peoples/${ d . id } ` ;
111
- }
112
- }
111
+ } ,
112
+ } ,
113
113
} ;
114
114
serializer . register ( 'people' , peopleSchema ) ;
115
115
serializerConvert . register ( 'people' , peopleSchema ) ;
116
116
117
117
// Register 'tag' type
118
118
const tagSchema = {
119
- id : 'id'
119
+ id : 'id' ,
120
120
} ;
121
121
serializer . register ( 'tag' , tagSchema ) ;
122
122
serializerConvert . register ( 'tag' , tagSchema ) ;
123
123
124
124
// Register 'photo' type
125
125
const photoSchema = {
126
- id : 'id'
126
+ id : 'id' ,
127
127
} ;
128
128
serializer . register ( 'photo' , photoSchema ) ;
129
129
serializerConvert . register ( 'photo' , photoSchema ) ;
130
130
131
131
// Register 'comment' type with a custom schema
132
132
const commentSchema = {
133
- id : '_id'
133
+ id : '_id' ,
134
134
} ;
135
135
serializer . register ( 'comment' , 'only-body' , commentSchema ) ;
136
136
serializerConvert . register ( 'comment' , 'only-body' , commentSchema ) ;
@@ -148,15 +148,15 @@ console.log('V8:', process.versions.v8);
148
148
149
149
let cpus = os
150
150
. cpus ( )
151
- . map ( cpu => cpu . model )
151
+ . map ( ( cpu ) => cpu . model )
152
152
. reduce ( ( o , model ) => {
153
153
if ( ! o [ model ] ) o [ model ] = 0 ;
154
154
o [ model ] += 1 ;
155
155
return o ;
156
156
} , { } ) ;
157
157
158
158
cpus = Object . keys ( cpus )
159
- . map ( key => `${ key } \u00d7 ${ cpus [ key ] } ` )
159
+ . map ( ( key ) => `${ key } \u00d7 ${ cpus [ key ] } ` )
160
160
. join ( '\n' ) ;
161
161
162
162
console . info ( cpus ) ;
@@ -170,7 +170,7 @@ suite
170
170
serializer . serializeAsync ( 'article' , data , { count : 2 } ) . then ( ( ) => {
171
171
deferred . resolve ( ) ;
172
172
} ) ;
173
- }
173
+ } ,
174
174
} )
175
175
. add ( 'serialize' , ( ) => {
176
176
serialized = serializer . serialize ( 'article' , data , { count : 2 } ) ;
@@ -184,7 +184,7 @@ suite
184
184
serializer . deserializeAsync ( 'article' , serialized ) . then ( ( ) => {
185
185
deferred . resolve ( ) ;
186
186
} ) ;
187
- }
187
+ } ,
188
188
} )
189
189
. add ( 'deserialize' , ( ) => {
190
190
serializer . deserialize ( 'article' , serialized ) ;
@@ -204,13 +204,13 @@ suite
204
204
status : '422' ,
205
205
source : { pointer : '/data/attributes/error' } ,
206
206
title : 'Error' ,
207
- detail : 'An error occured'
207
+ detail : 'An error occured' ,
208
208
} ;
209
209
210
210
serializer . serializeError ( jsonapiError ) ;
211
211
} )
212
212
// add listeners
213
- . on ( 'cycle' , event => {
213
+ . on ( 'cycle' , ( event ) => {
214
214
console . log ( String ( event . target ) ) ;
215
215
} )
216
216
. on ( 'complete' , ( ) => { } )
0 commit comments