Skip to content

Commit 6f31de6

Browse files
committed
Got flow to pass'ish
1 parent 3c4cd98 commit 6f31de6

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

.flowconfig

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

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_command := mocha test --require=test/index --recursive
1515
# Files
1616

1717
lib_files := $(shell find lib -type f -name *.js)
18-
lib_asset_files := $(shell find lib -type f ! -name "*.js" ! -name ".eslintrc.*" ! -name "*.orig")
18+
lib_asset_files := $(shell find lib -type f ! -name "*.js" ! -name "*.js.flow" ! -name ".eslintrc.*" ! -name "*.orig")
1919

2020
build_files := $(lib_files:lib/%=build/%)
2121
build_asset_files := $(lib_asset_files:lib/%=build/%)

flow-typed/stream-async-iterator.js

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

lib/stream-async-iterator.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Iteration = {
2828
done: boolean;
2929
value: any;
3030
}
31+
3132
type Reject = (err: any) => void;
3233

3334
/**
@@ -99,13 +100,6 @@ export default class StreamAsyncIterator {
99100
_size: ?number;
100101
_rejections: Set<Reject>;
101102

102-
/**
103-
* @returns {StreamAsyncIterator} - this
104-
*/
105-
[Symbol.asyncIterator]() {
106-
return this;
107-
}
108-
109103
/**
110104
* Returns the next iteration of data. Rejects if the stream errored out.
111105
* @returns {Promise<StreamAsyncIterator~Iteration>}
@@ -169,3 +163,8 @@ export default class StreamAsyncIterator {
169163
})
170164
}
171165
}
166+
167+
Object.defineProperty(StreamAsyncIterator.prototype, (Symbol: any).asyncIterator, {
168+
configurable: true,
169+
value: function() {return this;}
170+
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('StreamAsyncIterator', function() {
1313
const fileStream = fs.createReadStream(filePath, {encoding: 'utf8'});
1414
const buff = [];
1515

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

@@ -25,7 +25,7 @@ describe('StreamAsyncIterator', function() {
2525
const fileStream = fs.createReadStream(filePath, {encoding: 'utf8'});
2626
const buff = [];
2727

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

0 commit comments

Comments
 (0)