Skip to content

Commit

Permalink
style(buffer): fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Oct 6, 2015
1 parent b66592d commit af603bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions spec/operators/buffer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,52 +59,52 @@ describe('Observable.prototype.buffer', function () {
});
it('should work with error', function () {
var a = hot('---^-------#', null, new Error('too bad'));
var b = hot('---^--------')
var b = hot('---^--------');
var expected = '--------#';
expectObservable(a.buffer(b)).toBe(expected, null, new Error('too bad'));
});
it('should work with error and non-empty selector', function () {
var a = hot('---^-------#', null, new Error('too bad'));
var b = hot('---^---a----')
var b = hot('---^---a----');
var expected = '----a---#';
expectObservable(a.buffer(b)).toBe(expected, { a: [] }, new Error('too bad'));
});
it('should work with selector', function () {
// Buffer Boundaries Simple (RxJS 4)
var a = hot('--1--2--^--3--4--5---6----7--8--9---0---|');
var b = hot('--------^--a-------b---cd---------e---f---|')
var b = hot('--------^--a-------b---cd---------e---f---|');
var expected = '---a-------b---cd---------e---f-|';
expectObservable(a.buffer(b)).toBe(expected,
{ a: ['3'], b: ['4', '5'], c: ['6'], d: [], e: ['7', '8', '9'], f: ['0'] });
});
it('should work with selector completed', function () {
// Buffer Boundaries onCompletedBoundaries (RxJS 4)
var a = hot('--1--2--^--3--4--5---6----7--8--9---0---|');
var b = hot('--------^--a-------b---cd|')
var b = hot('--------^--a-------b---cd|');
var expected = '---a-------b---cd|';
expectObservable(a.buffer(b)).toBe(expected,
{ a: ['3'], b: ['4', '5'], c: ['6'], d: [] });
});
it('should work with non-empty and selector error', function () {
// Buffer Boundaries onErrorSource (RxJS 4)
var a = hot('--1--2--^--3-----#', {'3': 3}, new Error('too bad'));
var b = hot('--------^--a--b---')
var b = hot('--------^--a--b---');
var expected = '---a--b--#';
expectObservable(a.buffer(b)).toBe(expected,
{ a: [3], b: [] }, new Error('too bad'));
});
it('should work with non-empty and empty selector error', function () {
var obj = { a: true, b: true, c: true };
var a = hot('--1--2--^--3--4--5---6----7--8--9---0---|');
var b = hot('--------^----------------#', null, new Error('too bad'))
var b = hot('--------^----------------#', null, new Error('too bad'));
var expected = '-----------------#';
expectObservable(a.buffer(b)).toBe(expected, null, new Error('too bad'));
});
it('should work with non-empty and selector error', function () {
// Buffer Boundaries onErrorBoundaries (RxJS 4)
var obj = { a: true, b: true, c: true };
var a = hot('--1--2--^--3--4--5---6----7--8--9---0---|');
var b = hot('--------^--a-------b---c-#', obj, new Error('too bad'))
var b = hot('--------^--a-------b---c-#', obj, new Error('too bad'));
var expected = '---a-------b---c-#';
expectObservable(a.buffer(b)).toBe(expected,
{ a: ['3'], b: ['4', '5'], c: ['6'] }, new Error('too bad'));
Expand Down
20 changes: 10 additions & 10 deletions src/operators/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import bindCallback from '../util/bindCallback';
* buffers the incoming observable values until the passed `closingNotifier` emits a value, at which point
* it emits the buffer on the returned observable and starts a new buffer internally, awaiting the
* next time `closingNotifier` emits
*
*
* @param {Observable<any>} closingNotifier an observable, that signals the buffer to be emitted from the returned observable
* @returns {Observable<T[]>} an observable of buffers, which are arrays of values
*/
Expand All @@ -31,24 +31,24 @@ class BufferOperator<T, R> implements Operator<T, R> {

class BufferSubscriber<T> extends Subscriber<T> {
buffer: T[] = [];

constructor(destination: Subscriber<T>, closingNotifier: Observable<any>) {
super(destination);
this.add(closingNotifier._subscribe(new BufferClosingNotifierSubscriber(this)));
}

_next(value: T) {
this.buffer.push(value);
}

_error(err: any) {
this.destination.error(err);
}

_complete() {
this.destination.complete();
}

flushBuffer() {
const buffer = this.buffer;
this.buffer = [];
Expand All @@ -60,16 +60,16 @@ class BufferClosingNotifierSubscriber<T> extends Subscriber<T> {
constructor(private parent: BufferSubscriber<any>) {
super(null);
}

_next(value: T) {
this.parent.flushBuffer();
}

_error(err: any) {
this.parent.error(err);
}

_complete() {
this.parent.complete();
}
}
}

0 comments on commit af603bd

Please sign in to comment.