我的node项目首次提交!!!

This commit is contained in:
heiye111
2025-09-20 22:05:58 +08:00
commit 48600edffc
2539 changed files with 365006 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import cronometro from 'cronometro'
import fjs from 'fast-json-stringify'
import AjvCompiler from '../index.js'
const fjsSerialize = buildFJSSerializerFunction({
type: 'object',
properties: {
hello: { type: 'string' },
name: { type: 'string' }
}
})
const ajvSerialize = buildAJVSerializerFunction({
properties: {
hello: { type: 'string' },
name: { type: 'string' }
}
})
await cronometro({
'fast-json-stringify': function () {
fjsSerialize({ hello: 'Ciao', name: 'Manuel' })
},
'ajv serializer': function () {
ajvSerialize({ hello: 'Ciao', name: 'Manuel' })
}
})
function buildFJSSerializerFunction (schema) {
return fjs(schema)
}
function buildAJVSerializerFunction (schema) {
const factory = AjvCompiler({ jtdSerializer: true })
const compiler = factory({}, { customOptions: {} })
return compiler({ schema })
}