Skip to content

Commit

Permalink
Add isBoolean utility
Browse files Browse the repository at this point in the history
  • Loading branch information
octet-stream committed Feb 14, 2024
1 parent 04d26a5 commit 29b4ed9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/objectToFormData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {pathToString, Path, type PathNotations} from "./utils/pathToString.js"
import {createIterator} from "./utils/createIterator.js"
import {isPlainObject} from "./utils/isPlainObject.js"
import {isFunction} from "./utils/isFunction.js"
import {isBoolean} from "./utils/isBoolean.js"
import type {Input} from "./Input.js"

/**
Expand Down Expand Up @@ -129,7 +130,7 @@ export const objectToFormData: ObjectToFormData = (

if (
optionsOrStrict && !(
isPlainObject(optionsOrStrict) || typeof optionsOrStrict === "boolean"
isPlainObject(optionsOrStrict) || isBoolean(optionsOrStrict)
)
) {
throw new TypeError(
Expand All @@ -142,7 +143,7 @@ export const objectToFormData: ObjectToFormData = (
strict = false,
FormData: CustomFormData = FormData,
normalizeValue = noopNormalizeValue
}: ObjectToFormDataOptions = typeof optionsOrStrict === "boolean"
}: ObjectToFormDataOptions = isBoolean(optionsOrStrict)
? {strict: optionsOrStrict}
: {...optionsOrStrict}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/isBoolean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const isBoolean = (
value: unknown
): value is boolean => typeof value === "boolean"

0 comments on commit 29b4ed9

Please sign in to comment.