Skip to content

Commit

Permalink
Add example of k6/experimental/fs module
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Jul 5, 2023
1 parent b99f3d9 commit 48d220a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/experimental/fs/bonjour.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bonjour, tout le monde!
14 changes: 14 additions & 0 deletions examples/experimental/fs/open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { open, File } from "k6/experimental/fs";

// As k6 does not support asynchronous code in the init context, yet, we need to
// use a top-level async function to be able to use the `await` keyword.
let file;
(async function () {
file = await open("bonjour.txt");
})();

export default async function () {
const stats = await file.stat();
console.log("the file name is: " + stats.name);
console.log("the file size is: " + stats.size);
}

0 comments on commit 48d220a

Please sign in to comment.