Skip to content

Commit 49d1478

Browse files
authored
Merge pull request #549 from yovanoc/remove-iterall
feat: remove iterall
2 parents 7c5b4fa + 1d3fe0e commit 49d1478

File tree

6 files changed

+16
-25
lines changed

6 files changed

+16
-25
lines changed

package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
"prepublish": "tsc",
3737
"prepublishOnly": "npm run test"
3838
},
39-
"dependencies": {
40-
"iterall": "^1.3.0"
41-
},
4239
"peerDependencies": {
4340
"graphql-subscriptions": "^1.0.0 || ^2.0.0"
4441
},

src/pubsub-async-iterator.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $$asyncIterator } from 'iterall';
21
import { PubSubEngine } from 'graphql-subscriptions';
32

43
/**
@@ -30,7 +29,7 @@ import { PubSubEngine } from 'graphql-subscriptions';
3029
* @property pubsub @type {PubSubEngine}
3130
* The PubSubEngine whose events will be observed.
3231
*/
33-
export class PubSubAsyncIterator<T> implements AsyncIterator<T> {
32+
export class PubSubAsyncIterator<T> implements AsyncIterableIterator<T> {
3433

3534
constructor(pubsub: PubSubEngine, eventNames: string | string[], options?: unknown) {
3635
this.pubsub = pubsub;
@@ -56,7 +55,7 @@ export class PubSubAsyncIterator<T> implements AsyncIterator<T> {
5655
return Promise.reject(error);
5756
}
5857

59-
public [$$asyncIterator]() {
58+
public [Symbol.asyncIterator]() {
6059
return this;
6160
}
6261

src/test/integration-tests.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as chai from 'chai';
22
import * as chaiAsPromised from 'chai-as-promised';
33
import { mock } from 'simple-mock';
44
import { parse, GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLFieldResolver } from 'graphql';
5-
import { isAsyncIterable } from 'iterall';
65
import { subscribe } from 'graphql/subscription';
76

87
import { RedisPubSub } from '../redis-pubsub';
@@ -83,7 +82,7 @@ describe('PubSubAsyncIterator', function() {
8382
subscribe({ schema, document: query})
8483
.then(ai => {
8584
// tslint:disable-next-line:no-unused-expression
86-
expect(isAsyncIterable(ai)).to.be.true;
85+
expect(ai[Symbol.asyncIterator]).not.to.be.undefined;
8786

8887
const r = (ai as AsyncIterator<any>).next();
8988
setTimeout(() => pubsub.publish(FIRST_EVENT, {}), 50);
@@ -97,8 +96,8 @@ describe('PubSubAsyncIterator', function() {
9796
it('should allow pattern subscriptions', () =>
9897
subscribe({ schema, document: patternQuery })
9998
.then(ai => {
100-
// tslint:disable-next-line:no-unused-expression
101-
expect(isAsyncIterable(ai)).to.be.true;
99+
// tslint:disable-next-line:no-unused-expression
100+
expect(ai[Symbol.asyncIterator]).not.to.be.undefined;
102101

103102
const r = (ai as AsyncIterator<any>).next();
104103
setTimeout(() => pubsub.publish(SECOND_EVENT, {}), 50);
@@ -112,8 +111,8 @@ describe('PubSubAsyncIterator', function() {
112111
it('should clear event handlers', () =>
113112
subscribe({ schema, document: query})
114113
.then(ai => {
115-
// tslint:disable-next-line:no-unused-expression
116-
expect(isAsyncIterable(ai)).to.be.true;
114+
// tslint:disable-next-line:no-unused-expression
115+
expect(ai[Symbol.asyncIterator]).not.to.be.undefined;
117116

118117
pubsub.publish(FIRST_EVENT, {});
119118

src/test/tests.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as chai from 'chai';
22
import * as chaiAsPromised from 'chai-as-promised';
33
import { spy, restore, stub } from 'simple-mock';
4-
import { isAsyncIterable } from 'iterall';
54
import { RedisPubSub } from '../redis-pubsub';
65
import * as IORedis from 'ioredis';
76

@@ -429,9 +428,9 @@ describe('PubSubAsyncIterator', () => {
429428
const eventName = 'test';
430429
const iterator = pubSub.asyncIterator(eventName);
431430
// tslint:disable-next-line:no-unused-expression
432-
expect(iterator).to.exist;
433-
// tslint:disable-next-line:no-unused-expression
434-
expect(isAsyncIterable(iterator)).to.be.true;
431+
expect(iterator).to.exist;
432+
// tslint:disable-next-line:no-unused-expression
433+
expect(iterator[Symbol.asyncIterator]).not.to.be.undefined;
435434
});
436435

437436
it('should trigger event on asyncIterator when published', done => {

src/with-filter.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { $$asyncIterator } from 'iterall';
2-
31
export type FilterFn = (rootValue?: any, args?: any, context?: any, info?: any) => boolean;
42

5-
export const withFilter = (asyncIteratorFn: () => AsyncIterator<any>, filterFn: FilterFn) => {
3+
export const withFilter = (asyncIteratorFn: () => AsyncIterableIterator<any>, filterFn: FilterFn) => {
64
return (rootValue: any, args: any, context: any, info: any): AsyncIterator<any> => {
75
const asyncIterator = asyncIteratorFn();
86

@@ -33,7 +31,7 @@ export const withFilter = (asyncIteratorFn: () => AsyncIterator<any>, filterFn:
3331
throw(error) {
3432
return asyncIterator.throw(error);
3533
},
36-
[$$asyncIterator]() {
34+
[Symbol.asyncIterator]() {
3735
return this;
3836
},
3937
} as any;

0 commit comments

Comments
 (0)