You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would have assumed a directory check could be done with if (file.data) but that isn't the case (including the JSDoc comments which states "file data (don't provide for directories)".
Instead it is if (file.data && file.data.length > 0) since the type for data is still marked as nullable but will send an empty array instead.
Additionally:
Parsed files array has two additional properties: size file size and text, a lazy getter that decodes data view as a string.
The parse functions return TarFileItem[] instead of ParsedTarFileItem[] which makes the TypeScript compiler believe these should be inaccessible. I'm not sure if these are intentionally inaccessible, but I think relying on file.type === 'directory' and file.type === 'file' is far more intuitive for differentiating these types.
I didn't make a PR since I think there are multiple API inconsistencies, so it might make sense to get a clear answer from a maintainer before making a change. Whether it is just an invalid property error, type error, or both.
Thanks for the awesome library!
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
Node.js 18
nanotar: 0.1.1
Reproduction
nanotar/test/index.test.ts
Line 58 in c1247bd
That may be unique to how the test was made, but otherwise you'll still get a defined empty Uint8Array. e.g.
Describe the bug
The documentation states:
I would have assumed a directory check could be done with
if (file.data)
but that isn't the case (including the JSDoc comments which states "file data (don't provide for directories)".Instead it is
if (file.data && file.data.length > 0)
since the type fordata
is still marked as nullable but will send an empty array instead.Additionally:
nanotar/src/parse.ts
Line 3 in c1247bd
The parse functions return
TarFileItem[]
instead ofParsedTarFileItem[]
which makes the TypeScript compiler believe these should be inaccessible. I'm not sure if these are intentionally inaccessible, but I think relying onfile.type === 'directory'
andfile.type === 'file'
is far more intuitive for differentiating these types.I didn't make a PR since I think there are multiple API inconsistencies, so it might make sense to get a clear answer from a maintainer before making a change. Whether it is just an invalid property error, type error, or both.
Thanks for the awesome library!
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: