Skip to content

Commit

Permalink
fix(utils): [isBuffer] cannot destructure property 'isBuffer'
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Jul 30, 2023
1 parent 90befbd commit 66c9298
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/utils/is-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* @module tutils/utils/isBuffer
*/

import type { Partial } from '#src/types'
import cast from './cast'
import isFunction from './is-function'
import equal from './equal'
import isObject from './is-object'

/**
Expand All @@ -19,12 +17,7 @@ import isObject from './is-object'
* @return {value is Buffer} `true` if `value` is a `Buffer`
*/
const isBuffer = (value: unknown): value is Buffer => {
if (!isObject(value)) return false

// get possible isBuffer function from constructor
const { isBuffer: check } = cast<Partial<typeof Buffer>>(value.constructor)

return isFunction(check) && check(value)
return isObject(value) && equal(Buffer, value.constructor)
}

export default isBuffer

0 comments on commit 66c9298

Please sign in to comment.