Skip to content

Commit faee5d0

Browse files
committed
Better type checking
1 parent 6f31de6 commit faee5d0

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

.flowconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
[libs]
2-
decls/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ build: node_modules ${build_files} ${build_asset_files} ${build_package_files}
4848

4949
# Tasks
5050

51-
full-test: lint test cover
51+
full-test: lint flow test cover
5252

5353
flow:
5454
flow

lib/stream-async-iterator.js.flow

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @flow
2+
3+
declare type StreamAsyncIteratorOptions = {
4+
size?: number;
5+
}
6+
7+
declare export default class StreamAsyncIterator<TData> {
8+
constructor(stream: stream$Readable, options?: StreamAsyncIteratorOptions): StreamAsyncIterator<TData>;
9+
@@asyncIterator(): $AsyncIterator<TData, void, void>;
10+
next(): Promise<IteratorResult<TData, void>>;
11+
}

lib/test/stream-async-iterator-tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ describe('StreamAsyncIterator', function() {
1111

1212
it('should iterate on a node stream', async () => {
1313
const fileStream = fs.createReadStream(filePath, {encoding: 'utf8'});
14-
const buff = [];
14+
const buff: Array<string> = [];
1515

16-
for await (const value of (new StreamAsyncIterator(fileStream): any)) {
16+
for await (const value of (new StreamAsyncIterator(fileStream): StreamAsyncIterator<string>)) {
1717
buff.push(value);
1818
}
1919

@@ -23,9 +23,9 @@ describe('StreamAsyncIterator', function() {
2323

2424
it('should iterate on a node stream with a size', async () => {
2525
const fileStream = fs.createReadStream(filePath, {encoding: 'utf8'});
26-
const buff = [];
26+
const buff: Array<string> = [];
2727

28-
for await (const value of (new StreamAsyncIterator(fileStream, {size: 16}): any)) {
28+
for await (const value of (new StreamAsyncIterator(fileStream, {size: 16}): StreamAsyncIterator<string>)) {
2929
buff.push(value);
3030
}
3131

0 commit comments

Comments
 (0)