-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30% faster startup and faster validation (#159)
- Loading branch information
Showing
4 changed files
with
1,799 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict' | ||
|
||
const Ajv = require('ajv') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const pack = require('ajv-pack') | ||
|
||
const ajv = new Ajv({ | ||
sourceCode: true // this option is required by ajv-pack | ||
}) | ||
|
||
const validate = ajv.compile(require('ajv/lib/refs/json-schema-draft-07.json')) | ||
|
||
let moduleCode = `// This file is autogenerated by ${path.basename(__filename)}, do not edit | ||
function nop () { return true } | ||
${pack(ajv, validate).replace(/root\.refVal\[0\]/gm, 'nop')} | ||
` | ||
|
||
fs.writeFileSync(path.join(__dirname, 'schema-validator.js'), moduleCode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.