forked from mafintosh/tar-stream
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: esbuild warning about ?? operator
Restores the [pre-typescript](https://github.com/alanshaw/it-tar/blob/f6e492a44070816c4989af89e1602e656a27ecd4/lte-reader.js#L20) behaviour of `lte-reader` to just checking that the `done` value is true. Adds tests to prevent regressions. Closes #67
- Loading branch information
1 parent
21e888f
commit 52a095e
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect } from 'aegir/chai' | ||
import { lteReader } from '../src/lte-reader.js' | ||
|
||
describe('lte-reader', () => { | ||
it('should read', async () => { | ||
const reader = lteReader([ | ||
Uint8Array.from([0, 1, 2, 3, 4]), | ||
Uint8Array.from([5, 6, 7, 8, 9]) | ||
]) | ||
|
||
const { value } = await reader.next(6) | ||
|
||
if (value == null) { | ||
throw new Error('No value received') | ||
} | ||
|
||
expect(value.subarray()).to.equalBytes(Uint8Array.from([0, 1, 2, 3, 4, 5])) | ||
}) | ||
|
||
it('should reject on under-read', async () => { | ||
const reader = lteReader([ | ||
Uint8Array.from([0, 1, 2, 3, 4]), | ||
Uint8Array.from([5, 6, 7, 8, 9]) | ||
]) | ||
|
||
await expect(reader.next(100)).to.eventually.be.rejected | ||
.with.property('code', 'ERR_UNDER_READ') | ||
}) | ||
}) |