20 lines
No EOL
689 B
JavaScript
20 lines
No EOL
689 B
JavaScript
import { EMPTY } from '../observable/empty';
|
|
import { operate } from '../util/lift';
|
|
import { createOperatorSubscriber } from './OperatorSubscriber';
|
|
export function take(count) {
|
|
return count <= 0
|
|
?
|
|
function () { return EMPTY; }
|
|
: operate(function (source, subscriber) {
|
|
var seen = 0;
|
|
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
if (++seen <= count) {
|
|
subscriber.next(value);
|
|
if (count <= seen) {
|
|
subscriber.complete();
|
|
}
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
//# sourceMappingURL=take.js.map
|