| 1 |
import { EMPTY } from '../observable/empty'; |
| 2 |
import { operate } from '../util/lift'; |
| 3 |
import { createOperatorSubscriber } from './OperatorSubscriber'; |
| 4 |
export function take(count) { |
| 5 |
return count <= 0 |
| 6 |
? |
| 7 |
function () { return EMPTY; } |
| 8 |
: operate(function (source, subscriber) { |
| 9 |
var seen = 0; |
| 10 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 11 |
if (++seen <= count) { |
| 12 |
subscriber.next(value); |
| 13 |
if (count <= seen) { |
| 14 |
subscriber.complete(); |
| 15 |
} |
| 16 |
} |
| 17 |
})); |
| 18 |
}); |
| 19 |
} |
| 20 |
//# sourceMappingURL=take.js.map |