Skip to content

Commit 16db6e7

Browse files
committed
standardized.
1 parent a7873f0 commit 16db6e7

File tree

4 files changed

+37
-36
lines changed

4 files changed

+37
-36
lines changed

bench.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ const benchmark = require('benchmark')
44
const suite = new benchmark.Suite()
55

66
const schema = {
7-
"title": "Example Schema",
8-
"type": "object",
9-
"properties": {
10-
"firstName": {
11-
"type": "string"
12-
},
13-
"lastName": {
14-
"type": "string"
15-
},
16-
"age": {
17-
"description": "Age in years",
18-
"type": "integer",
19-
"minimum": 0
20-
}
21-
},
22-
"required": ["firstName", "lastName"]
7+
'title': 'Example Schema',
8+
'type': 'object',
9+
'properties': {
10+
'firstName': {
11+
'type': 'string'
12+
},
13+
'lastName': {
14+
'type': 'string'
15+
},
16+
'age': {
17+
'description': 'Age in years',
18+
'type': 'integer',
19+
'minimum': 0
20+
}
21+
},
22+
'required': ['firstName', 'lastName']
2323
}
2424

2525
const obj = {

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict'
22

33
function build (schema) {
4+
/*eslint no-new-func: "off"*/
45

56
let code = `
67
'use strict'
78
let json = '{'
89
`
910

1011
Object.keys(schema.properties).forEach((key, i, a) => {
11-
1212
const type = schema.properties[key].type
1313

1414
code += `
@@ -20,17 +20,16 @@ function build (schema) {
2020
code += `
2121
json += '"' + obj.${key} + '"'
2222
`
23-
break;
23+
break
2424
case 'integer':
2525
code += `
2626
json += '' + obj.${key}
2727
`
28-
break;
28+
break
2929
default:
3030
throw new Error(`${type} unsupported`)
3131
}
3232

33-
3433
if (i < a.length - 1) {
3534
code += 'json += \',\''
3635
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"test": "standard && tap test.js"
88
},
9+
"precommit": "test",
910
"repository": {
1011
"type": "git",
1112
"url": "git+https://github.com/mcollina/fast-json-stringify.git"
@@ -25,6 +26,7 @@
2526
"devDependencies": {
2627
"benchmark": "^2.1.1",
2728
"is-my-json-valid": "^2.13.1",
29+
"pre-commit": "^1.1.3",
2830
"standard": "^7.1.2",
2931
"tap": "^6.2.0"
3032
}

test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ const test = require('tap').test
44
const build = require('.')
55

66
const example = {
7-
"title": "Example Schema",
8-
"type": "object",
9-
"properties": {
10-
"firstName": {
11-
"type": "string"
12-
},
13-
"lastName": {
14-
"type": "string"
15-
},
16-
"age": {
17-
"description": "Age in years",
18-
"type": "integer",
19-
"minimum": 0
20-
}
21-
},
22-
"required": ["firstName", "lastName"]
7+
'title': 'Example Schema',
8+
'type': 'object',
9+
'properties': {
10+
'firstName': {
11+
'type': 'string'
12+
},
13+
'lastName': {
14+
'type': 'string'
15+
},
16+
'age': {
17+
'description': 'Age in years',
18+
'type': 'integer',
19+
'minimum': 0
20+
}
21+
},
22+
'required': ['firstName', 'lastName']
2323
}
2424

2525
test('render a basic json', (t) => {

0 commit comments

Comments
 (0)