Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ function build (schema, options) {
}
}

if (options.debugMode) {
options.mode = 'debug'
}

if (options.mode === 'debug') {
return {
validator,
Expand Down
22 changes: 5 additions & 17 deletions test/debug-mode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function build (opts) {

test('activate debug mode', t => {
t.plan(5)
const debugMode = build({ debugMode: true })
const debugMode = build({ mode: 'debug' })

t.assert.ok(typeof debugMode === 'object')
t.assert.ok(debugMode.ajv instanceof Ajv)
Expand All @@ -31,21 +31,9 @@ test('activate debug mode', t => {
t.assert.ok(typeof debugMode.code === 'string')
})

test('activate debug mode truthy', t => {
t.plan(5)

const debugMode = build({ debugMode: 'yes' })

t.assert.ok(typeof debugMode === 'object')
t.assert.ok(typeof debugMode.code === 'string')
t.assert.ok(debugMode.ajv instanceof Ajv)
t.assert.ok(debugMode.validator instanceof Validator)
t.assert.ok(debugMode.serializer instanceof Serializer)
})

test('to string auto-consistent', t => {
t.plan(6)
const debugMode = build({ debugMode: 1 })
const debugMode = build({ mode: 'debug' })

t.assert.ok(typeof debugMode === 'object')
t.assert.ok(typeof debugMode.code === 'string')
Expand Down Expand Up @@ -73,7 +61,7 @@ test('to string auto-consistent with ajv', t => {
}]
}
}
}, { debugMode: 1 })
}, { mode: 'debug' })

t.assert.ok(typeof debugMode === 'object')
t.assert.ok(typeof debugMode.code === 'string')
Expand Down Expand Up @@ -102,7 +90,7 @@ test('to string auto-consistent with ajv-formats', t => {
}]
}
}
}, { debugMode: 1 })
}, { mode: 'debug' })

t.assert.ok(typeof debugMode === 'object')

Expand All @@ -115,7 +103,7 @@ test('to string auto-consistent with ajv-formats', t => {
test('debug should restore the same serializer instance', t => {
t.plan(1)

const debugMode = fjs({ type: 'integer' }, { debugMode: 1, rounding: 'ceil' })
const debugMode = fjs({ type: 'integer' }, { mode: 'debug', rounding: 'ceil' })
const compiled = fjs.restore(debugMode)
t.assert.equal(compiled(3.95), 4)
})
Expand Down
12 changes: 0 additions & 12 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,10 @@ declare namespace build {
* @default 'trunc'
*/
rounding?: 'ceil' | 'floor' | 'round' | 'trunc'
/**
* @deprecated
* Enable debug mode. Please use `mode: "debug"` instead
*/
debugMode?: boolean
/**
* Running mode of fast-json-stringify
*/
mode?: 'debug' | 'standalone'

/**
* Large arrays are defined as arrays containing, by default, `20000`
* elements or more. That value can be adjusted via the option parameter
Expand All @@ -180,7 +174,6 @@ declare namespace build {
* @default 20000
*/
largeArraySize?: number | string | BigInt

/**
* Specify the function on how large Arrays should be stringified.
*
Expand All @@ -200,10 +193,6 @@ interface DebugOption extends build.Options {
mode: 'debug'
}

interface DeprecateDebugOption extends build.Options {
debugMode: true
}

interface StandaloneOption extends build.Options {
mode: 'standalone'
}
Expand All @@ -217,7 +206,6 @@ type IntegerCoercible = number | BigInt
* @param options The options to use (optional)
*/
declare function build (schema: build.AnySchema, options: DebugOption): { code: string, ajv: Ajv }
declare function build (schema: build.AnySchema, options: DeprecateDebugOption): { code: string, ajv: Ajv }
declare function build (schema: build.AnySchema, options: StandaloneOption): string
declare function build (schema: build.AnySchema, options?: build.Options): <TDoc = any>(doc: TDoc) => any
declare function build (schema: build.StringSchema, options?: build.Options): <TDoc extends StringCoercible = StringCoercible>(doc: TDoc) => string
Expand Down
Loading