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

[1/2] Implement the fs.File.read operation #3219

Closed
wants to merge 7 commits into from

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Jul 20, 2023

What?

This Pull Request adds an read method to the k6/experimental/fs module's file object, as per #3145.
⚠️ This PR is based on the experimental/fs branch ⚠️

It allows to read a file into an ArrayBuffer.

The method resolves to either the number of bytes read during the operation or EOF (null) if there was nothing more to read.

It is possible for a read to successfully return with 0 bytes. This does not indicate EOF.

const f = fs.openSync('myfile.txt')

export default function () {
    const buf = new Uint8Array(100);
    const numberOfBytesRead = await file.read(buf); // 11 bytes
}

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make ci-like-lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

ref #3165
closes #3145

@oleiade oleiade self-assigned this Jul 20, 2023
@oleiade oleiade marked this pull request as draft July 20, 2023 15:21
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2023

Codecov Report

❗ No coverage uploaded for pull request base (experimental/fs@3e3e016). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 21131e2 differs from pull request most recent head fa92afc. Consider uploading reports for the commit fa92afc to get more accurate results

@@                Coverage Diff                 @@
##             experimental/fs    #3219   +/-   ##
==================================================
  Coverage                   ?   72.64%           
==================================================
  Files                      ?      263           
  Lines                      ?    20023           
  Branches                   ?        0           
==================================================
  Hits                       ?    14546           
  Misses                     ?     4557           
  Partials                   ?      920           
Flag Coverage Δ
ubuntu 72.64% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@oleiade oleiade added this to the v0.47.0 milestone Jul 25, 2023
@oleiade oleiade changed the title Experimental/fs read [1/2] Implement the fs.File.read operation Jul 25, 2023
@oleiade oleiade force-pushed the experimental/fs branch 2 times, most recently from 6a1658b to 9dd1a26 Compare August 24, 2023 12:56
@oleiade oleiade closed this Aug 29, 2023
@codebien codebien removed this from the v0.47.0 milestone Oct 2, 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 this pull request may close these issues.

3 participants