Skip to content

Buffer.indexOf returns the wrong value when the value parameter is passed as number #17555

@tiagohm

Description

@tiagohm

What version of Bun is running?

1.2.3

What platform is your computer?

Linux 6.9.3-76060903-generic x86_64 x86_64

What steps can reproduce the bug?

const buf = Buffer.from('abcde')
console.log(buf.indexOf('e', 4)) // Prints 4
console.log(buf.indexOf(101, 4)) // Prints 0

What is the expected behavior?

Both should return same index: 4.

What do you see instead?

When a byteOffset is passed and the value parameter is a number, it seems to return an index starting from the byteOffset.

Additional information

This bug does not occur in v1.2.2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions