diff --git a/docs/sources/k6/next/javascript-api/k6-experimental/csv/Options.md b/docs/sources/k6/next/javascript-api/k6-experimental/csv/Options.md index 08d6012a98..23879fb4a4 100644 --- a/docs/sources/k6/next/javascript-api/k6-experimental/csv/Options.md +++ b/docs/sources/k6/next/javascript-api/k6-experimental/csv/Options.md @@ -25,17 +25,13 @@ The `Options` object describes the configuration available for the operation of import { open } from 'k6/experimental/fs'; import csv from 'k6/experimental/csv'; -let file; -let parser; -(async function () { - file = await open('data.csv'); - parser = new csv.Parser(file, { - delimiter: ',', - skipFirstLine: true, - fromLine: 2, - toLine: 8, - }); -})(); +const file = await open('data.csv'); +const parser = new csv.Parser(file, { + delimiter: ',', + skipFirstLine: true, + fromLine: 2, + toLine: 8, +}); export default async function () { // The `next` method attempts to read the next row from the CSV file. diff --git a/docs/sources/k6/next/javascript-api/k6-experimental/csv/Parser.md b/docs/sources/k6/next/javascript-api/k6-experimental/csv/Parser.md index d44309bb50..d2e1135f18 100644 --- a/docs/sources/k6/next/javascript-api/k6-experimental/csv/Parser.md +++ b/docs/sources/k6/next/javascript-api/k6-experimental/csv/Parser.md @@ -64,12 +64,8 @@ export const options = { iterations: 10, }; -let file; -let parser; -(async function () { - file = await open('data.csv'); - parser = new csv.Parser(file, { skipFirstLine: true }); -})(); +const file = await open('data.csv'); +const parser = new csv.Parser(file, { skipFirstLine: true }); export default async function () { // The `next` method attempts to read the next row from the CSV file. diff --git a/docs/sources/k6/next/javascript-api/k6-experimental/csv/_index.md b/docs/sources/k6/next/javascript-api/k6-experimental/csv/_index.md index a962fa0b30..b5628b6671 100644 --- a/docs/sources/k6/next/javascript-api/k6-experimental/csv/_index.md +++ b/docs/sources/k6/next/javascript-api/k6-experimental/csv/_index.md @@ -52,15 +52,11 @@ export const options = { iterations: 10, }; -let file; -let csvRecords; -(async function () { - file = await open('data.csv'); +const file = await open('data.csv'); - // The `csv.parse` function consumes the entire file at once and returns - // the parsed records as a `SharedArray` object. - csvRecords = await csv.parse(file, { delimiter: ',' }); -})(); +// The `csv.parse` function consumes the entire file at once and returns +// the parsed records as a `SharedArray` object. +const csvRecords = await csv.parse(file, { delimiter: ',' }); export default async function () { // `csvRecords` is a `SharedArray`. Each element is a record from the CSV file, represented as an array @@ -85,12 +81,11 @@ export const options = { iterations: 10, }; -let file; -let parser; -(async function () { - file = await open('data.csv'); - parser = new csv.Parser(file); -})(); +const file = await open('data.csv'); + +// The `csv.parse` function consumes the entire file at once and returns +// the parsed records as a `SharedArray` object. +const parser = new csv.Parser(file); export default async function () { // The parser `next` method attempts to read the next row from the CSV file. diff --git a/docs/sources/k6/next/javascript-api/k6-experimental/csv/parse.md b/docs/sources/k6/next/javascript-api/k6-experimental/csv/parse.md index 0a39d699b3..42fbbc1851 100644 --- a/docs/sources/k6/next/javascript-api/k6-experimental/csv/parse.md +++ b/docs/sources/k6/next/javascript-api/k6-experimental/csv/parse.md @@ -55,15 +55,11 @@ export const options = { iterations: 10, }; -let file; -let csvRecords; -(async function () { - file = await open('data.csv'); +const file = await open('data.csv'); - // The `csv.parse` function consumes the entire file at once and returns - // the parsed records as a `SharedArray` object. - csvRecords = await csv.parse(file, { skipFirstLine: true }); -})(); +// The `csv.parse` function consumes the entire file at once and returns +// the parsed records as a `SharedArray` object. +const csvRecords = await csv.parse(file, { skipFirstLine: true }); export default async function () { // `csvRecords` is a `SharedArray`. Each element is a record from the CSV file, represented as an array