Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Open source

SeekMode

The SeekMode enum specifies the position from which to seek in a file.

Members

MemberValueDescription
Start0Seek from the start of the file.
Current1Seek from the current position in the file.
End2Seek from the end of the file.

Example

JavaScript
import { open, SeekMode } from 'k6/experimental/fs';

let file;
(async function () {
  file = await open('bonjour.txt');
})();

export default async function () {
  // Seek 6 bytes from the start of the file
  await file.seek(6, SeekMode.Start);

  // Seek 2 more bytes from the current position
  await file.seek(2, SeekMode.Current);

  // Seek backwards 2 bytes from the end of the file
  await file.seek(-2, SeekMode.End);
}