<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>fs on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/</link><description>Recent content in fs on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/index.xml" rel="self" type="application/rss+xml"/><item><title>File</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/</guid><content><![CDATA[&lt;h1 id=&#34;file&#34;&gt;File&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;File&lt;/code&gt; class represents a file with methods for reading, seeking, and obtaining file stats. It&amp;rsquo;s returned by the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/init-context/open/&#34;&gt;open&lt;/a&gt; function.&lt;/p&gt;
&lt;h2 id=&#34;properties&#34;&gt;Properties&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Property&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;path&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The absolute path to the file.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;methods&#34;&gt;Methods&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Method&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/read/&#34;&gt;read&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Reads up to &lt;code&gt;buffer.byteLength&lt;/code&gt; bytes from the file into the passed &lt;code&gt;buffer&lt;/code&gt;. Returns a promise resolving to the number of bytes read.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/seek/&#34;&gt;seek&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Sets the file position indicator for the file to the passed &lt;code&gt;offset&lt;/code&gt; bytes. Returns a promise resolving to the new offset.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/stat/&#34;&gt;stat&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Returns a promise resolving to a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/fileinfo/&#34;&gt;FileInfo&lt;/a&gt; object with information about the file.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open, SeekMode } from &amp;#39;k6/experimental/fs&amp;#39;;

const file = await open(&amp;#39;bonjour.txt&amp;#39;);

export default async function () {
  // Seek to the beginning of the file
  await file.seek(0, SeekMode.Start);

  // About information about the file
  const fileinfo = await file.stat();
  if (fileinfo.name != &amp;#39;bonjour.txt&amp;#39;) {
    throw new Error(&amp;#39;Unexpected file name&amp;#39;);
  }

  const buffer = new Uint8Array(4);

  let totalBytesRead = 0;
  while (true) {
    // Read into the buffer
    const bytesRead = await file.read(buffer);
    if (bytesRead == null) {
      // EOF
      break;
    }

    // Do something useful with the content of the buffer
    totalBytesRead &amp;#43;= bytesRead;

    // If bytesRead is less than the buffer size, we&amp;#39;ve read the whole file
    if (bytesRead &amp;lt; buffer.byteLength) {
      break;
    }
  }

  // Check that we read the expected number of bytes
  if (totalBytesRead != fileinfo.size) {
    throw new Error(&amp;#39;Unexpected number of bytes read&amp;#39;);
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="file">File&lt;/h1>
&lt;p>The &lt;code>File&lt;/code> class represents a file with methods for reading, seeking, and obtaining file stats. It&amp;rsquo;s returned by the
&lt;a href="/docs/k6/v2.3.x/javascript-api/init-context/open/">open&lt;/a> function.&lt;/p>
&lt;h2 id="properties">Properties&lt;/h2>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Property&lt;/th>
&lt;th style="text-align: left">Type&lt;/th>
&lt;th style="text-align: left">Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">path&lt;/td>
&lt;td style="text-align: left">string&lt;/td>
&lt;td style="text-align: left">The absolute path to the file.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h2 id="methods">Methods&lt;/h2>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Method&lt;/th>
&lt;th style="text-align: left">Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/read/">read&lt;/a>&lt;/td>
&lt;td style="text-align: left">Reads up to &lt;code>buffer.byteLength&lt;/code> bytes from the file into the passed &lt;code>buffer&lt;/code>. Returns a promise resolving to the number of bytes read.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/seek/">seek&lt;/a>&lt;/td>
&lt;td style="text-align: left">Sets the file position indicator for the file to the passed &lt;code>offset&lt;/code> bytes. Returns a promise resolving to the new offset.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/stat/">stat&lt;/a>&lt;/td>
&lt;td style="text-align: left">Returns a promise resolving to a
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/fileinfo/">FileInfo&lt;/a> object with information about the file.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h2 id="example">Example&lt;/h2>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import { open, SeekMode } from &amp;#39;k6/experimental/fs&amp;#39;;
const file = await open(&amp;#39;bonjour.txt&amp;#39;);
export default async function () {
// Seek to the beginning of the file
await file.seek(0, SeekMode.Start);
// About information about the file
const fileinfo = await file.stat();
if (fileinfo.name != &amp;#39;bonjour.txt&amp;#39;) {
throw new Error(&amp;#39;Unexpected file name&amp;#39;);
}
const buffer = new Uint8Array(4);
let totalBytesRead = 0;
while (true) {
// Read into the buffer
const bytesRead = await file.read(buffer);
if (bytesRead == null) {
// EOF
break;
}
// Do something useful with the content of the buffer
totalBytesRead &amp;#43;= bytesRead;
// If bytesRead is less than the buffer size, we&amp;#39;ve read the whole file
if (bytesRead &amp;lt; buffer.byteLength) {
break;
}
}
// Check that we read the expected number of bytes
if (totalBytesRead != fileinfo.size) {
throw new Error(&amp;#39;Unexpected number of bytes read&amp;#39;);
}
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>open</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/open/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/open/</guid><content><![CDATA[&lt;h1 id=&#34;open&#34;&gt;open&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;open&lt;/code&gt; function opens a file and returns a promise that resolves to a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/&#34;&gt;File&lt;/a&gt; instance. Unlike the traditional 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/init-context/open/&#34;&gt;open&lt;/a&gt; function, which loads a file multiple times into memory, the filesystem module reduces memory usage by loading the file as little possible, and sharing the same memory space between all VUs. This approach reduces the risk of encountering out-of-memory errors, especially in load tests involving large files.&lt;/p&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Parameter&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;path&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The path to the file to open. Relative paths are resolved relative to the k6 script.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;returns&#34;&gt;Returns&lt;/h2&gt;
&lt;p&gt;A promise resolving to a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/&#34;&gt;File&lt;/a&gt; instance.&lt;/p&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open } from &amp;#39;k6/experimental/fs&amp;#39;;

// k6 doesn&amp;#39;t support async in the init context. We use a top-level async function for `await`.
//
// Each Virtual User gets its own `file` copy.
// So, operations like `seek` or `read` won&amp;#39;t impact other VUs.
const file = await open(&amp;#39;bonjour.txt&amp;#39;);

export default async function () {
  // About information about the file
  const fileinfo = await file.stat();
  if (fileinfo.name != &amp;#39;bonjour.txt&amp;#39;) {
    throw new Error(&amp;#39;Unexpected file name&amp;#39;);
  }

  console.log(JSON.stringify(fileinfo));
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="open">open&lt;/h1>
&lt;p>The &lt;code>open&lt;/code> function opens a file and returns a promise that resolves to a
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/">File&lt;/a> instance. Unlike the traditional
&lt;a href="/docs/k6/v2.3.x/javascript-api/init-context/open/">open&lt;/a> function, which loads a file multiple times into memory, the filesystem module reduces memory usage by loading the file as little possible, and sharing the same memory space between all VUs. This approach reduces the risk of encountering out-of-memory errors, especially in load tests involving large files.&lt;/p></description></item><item><title>FileInfo</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/fileinfo/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/fileinfo/</guid><content><![CDATA[&lt;h1 id=&#34;fileinfo&#34;&gt;FileInfo&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;FileInfo&lt;/code&gt; class represents information about a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/&#34;&gt;file&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;properties&#34;&gt;Properties&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Property&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;name&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The name of the file.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;size&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;number&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The size of the file in bytes.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open, SeekMode } from &amp;#39;k6/experimental/fs&amp;#39;;

const file = await open(&amp;#39;bonjour.txt&amp;#39;);

export default async function () {
  // Retrieve information about the file
  const fileinfo = await file.stat();
  if (fileinfo.name != &amp;#39;bonjour.txt&amp;#39;) {
    throw new Error(&amp;#39;Unexpected file name&amp;#39;);
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="fileinfo">FileInfo&lt;/h1>
&lt;p>The &lt;code>FileInfo&lt;/code> class represents information about a
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/">file&lt;/a>.&lt;/p>
&lt;h2 id="properties">Properties&lt;/h2>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Property&lt;/th>
&lt;th style="text-align: left">Type&lt;/th>
&lt;th style="text-align: left">Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">name&lt;/td>
&lt;td style="text-align: left">string&lt;/td>
&lt;td style="text-align: left">The name of the file.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">size&lt;/td>
&lt;td style="text-align: left">number&lt;/td>
&lt;td style="text-align: left">The size of the file in bytes.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h2 id="example">Example&lt;/h2>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import { open, SeekMode } from &amp;#39;k6/experimental/fs&amp;#39;;
const file = await open(&amp;#39;bonjour.txt&amp;#39;);
export default async function () {
// Retrieve information about the file
const fileinfo = await file.stat();
if (fileinfo.name != &amp;#39;bonjour.txt&amp;#39;) {
throw new Error(&amp;#39;Unexpected file name&amp;#39;);
}
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>SeekMode</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/seekmode/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/seekmode/</guid><content><![CDATA[&lt;h1 id=&#34;seekmode&#34;&gt;SeekMode&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;SeekMode&lt;/code&gt; enum specifies the position from which to 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/seek/&#34;&gt;seek&lt;/a&gt; in a file.&lt;/p&gt;
&lt;h2 id=&#34;members&#34;&gt;Members&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Member&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Value&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Start&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;0&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Seek from the start of the file.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Current&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;1&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Seek from the current position in the file.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;End&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;2&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Seek from the end of the file.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open, SeekMode } from &amp;#39;k6/experimental/fs&amp;#39;;

const file = await open(&amp;#39;bonjour.txt&amp;#39;);

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);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="seekmode">SeekMode&lt;/h1>
&lt;p>The &lt;code>SeekMode&lt;/code> enum specifies the position from which to
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/seek/">seek&lt;/a> in a file.&lt;/p>
&lt;h2 id="members">Members&lt;/h2>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Member&lt;/th>
&lt;th style="text-align: left">Value&lt;/th>
&lt;th style="text-align: left">Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">Start&lt;/td>
&lt;td style="text-align: left">0&lt;/td>
&lt;td style="text-align: left">Seek from the start of the file.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">Current&lt;/td>
&lt;td style="text-align: left">1&lt;/td>
&lt;td style="text-align: left">Seek from the current position in the file.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">End&lt;/td>
&lt;td style="text-align: left">2&lt;/td>
&lt;td style="text-align: left">Seek from the end of the file.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h2 id="example">Example&lt;/h2>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import { open, SeekMode } from &amp;#39;k6/experimental/fs&amp;#39;;
const file = await open(&amp;#39;bonjour.txt&amp;#39;);
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);
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item></channel></rss>