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

Implement the File API's File.seek method #3148

Closed
Tracked by #3141
oleiade opened this issue Jun 27, 2023 · 1 comment · Fixed by #3309
Closed
Tracked by #3141

Implement the File API's File.seek method #3148

oleiade opened this issue Jun 27, 2023 · 1 comment · Fixed by #3309
Assignees
Milestone

Comments

@oleiade
Copy link
Member

oleiade commented Jun 27, 2023

As part of #3141, implementing the agreed-upon design for k6's File API, we intend to implement a File.seek method.

The seek method seeks the file to handle to the given offset under the mode provided by whence. The call resolves with the new position within the resource (offset from the start, in bytes).

prototype

interface File {
    seek(offset: number, whence: SeekMode): Promise<number>
}

enum SeekMode {
    Current = 1
    End = 2
    Start = 0
}

example

const file = fs.openSync("fou.txt")
const cursorPosition = await file.seek(6, fs.SeekMode.Start)
@oleiade
Copy link
Member Author

oleiade commented Nov 13, 2023

Implemented by #3309

@oleiade oleiade closed this as completed Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant