2 var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var Subscriber_1 = require("../Subscriber");
17 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
18 var empty_1 = require("../observable/empty");
19 function takeLast(count) {
20 return function takeLastOperatorFunction(source) {
22 return empty_1.empty();
25 return source.lift(new TakeLastOperator(count));
29 exports.takeLast = takeLast;
30 var TakeLastOperator = (function () {
31 function TakeLastOperator(total) {
34 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
37 TakeLastOperator.prototype.call = function (subscriber, source) {
38 return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
40 return TakeLastOperator;
42 var TakeLastSubscriber = (function (_super) {
43 __extends(TakeLastSubscriber, _super);
44 function TakeLastSubscriber(destination, total) {
45 var _this = _super.call(this, destination) || this;
47 _this.ring = new Array();
51 TakeLastSubscriber.prototype._next = function (value) {
53 var total = this.total;
54 var count = this.count++;
55 if (ring.length < total) {
59 var index = count % total;
63 TakeLastSubscriber.prototype._complete = function () {
64 var destination = this.destination;
65 var count = this.count;
67 var total = this.count >= this.total ? this.total : this.count;
69 for (var i = 0; i < total; i++) {
70 var idx = (count++) % total;
71 destination.next(ring[idx]);
74 destination.complete();
76 return TakeLastSubscriber;
77 }(Subscriber_1.Subscriber));
78 //# sourceMappingURL=takeLast.js.map