Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('outputs a compatible Observable', done => {
const a = stream()
const values = []
const observable = Observable.from(a)
observable.subscribe({
next(x) {
values.push(x)
},
complete(x) {
expect(values).toEqual([1, 2, 3])
done()
},
})
send(a, [1, 2, 3, ''])
})
observer.complete();
})
.subscribe(val => assert(typeof val === 'number'));
/**
* Observable.of
*/
Observable.of(1, 2, 3)
.subscribe(val => assert(typeof val === 'number'));
/**
* Observable.from
*/
Observable.from(Observable.of(1, 2, 3))
.subscribe(val => assert(typeof val === 'number'));
Observable.from([1, 2, 3])
.subscribe(val => assert(typeof val === 'number'));
Observable.from({
subscribe(observer: ZenObservable.SubscriptionObserver) {
[1, 2, 3].forEach(one => observer.next(one));
observer.complete();
},
[Symbol.observable](this: ZenObservable.ObservableLike) {
return this;
}
})
.subscribe(val => assert(typeof val === 'number'));
/**
* Observable.of
*/
Observable.of(1, 2, 3)
.subscribe(val => assert(typeof val === 'number'));
/**
* Observable.from
*/
Observable.from(Observable.of(1, 2, 3))
.subscribe(val => assert(typeof val === 'number'));
Observable.from([1, 2, 3])
.subscribe(val => assert(typeof val === 'number'));
Observable.from({
subscribe(observer: ZenObservable.SubscriptionObserver) {
[1, 2, 3].forEach(one => observer.next(one));
observer.complete();
},
[Symbol.observable](this: ZenObservable.ObservableLike) {
return this;
}
})
.subscribe(val => assert(typeof val === 'number'));
Observable.from({
[Symbol.observable]() {
return Observable.of(1, 2, 3);
client.unsubscribe(t);
this._topicClient.delete(t);
if (
!Array.from(this._topicClient.values()).some(c => c === client)
) {
this.disconnect(client.clientId);
}
}
this._topicObservers.delete(t);
});
};
});
return Observable.from(result).map(value => {
const topic = this.getTopicForValue(value);
const alias = this._topicAlias.get(topic);
value.data = Object.entries(value.data).reduce(
(obj, [origKey, val]) => (
(obj[(alias || origKey) as string] = val), obj
),
{}
);
return value;
});
}
}
export function codestyle(cb) {
return Observable.from(globVinyl(config.glob))
.filter(makeFilter(config.ignorefile))
.map(readVinyl)
.map(prettierFormat)
.map(writeVinyl)
.reduce(reduceResult)
.subscribe(result => printResult(result, cb))
}
export function codestyleIsValid(cb) {
return Observable.from(globVinyl(config.glob))
.filter(makeFilter(config.ignorefile))
.map(readVinyl)
.map(prettierCheck)
.reduce(reduceResult)
.subscribe(result => printResult(result, cb))
}