Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isBuffer from lodash-es doesn't work #5827

Open
ggrace22 opened this issue Mar 4, 2024 · 1 comment
Open

isBuffer from lodash-es doesn't work #5827

ggrace22 opened this issue Mar 4, 2024 · 1 comment

Comments

@ggrace22
Copy link

ggrace22 commented Mar 4, 2024

import { isBuffer } from 'lodash-es';

console.log(isBuffer(Buffer.from("Hello")));
Output : false (should be true)

console.log(Buffer.isBuffer(Buffer.from("Hello")));
Output : true

Can someone please take a look on this ?

@berakoc
Copy link

berakoc commented Mar 27, 2024

It seems that lodash uses native isBuffer and if not found a predicate which always returns false.

const isBuffer = typeof nativeIsBuffer === 'function' ? nativeIsBuffer : () => false;

One way to find the issue is to assure that native global object is the one you are using in the second example.
const nativeIsBuffer = root?.Buffer?.isBuffer;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants