rxjs-rails 2.3.22 → 2.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +178 -146
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +1706 -1156
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +4 -4
  7. data/vendor/assets/javascripts/rx.all.js +1529 -1125
  8. data/vendor/assets/javascripts/rx.all.min.js +4 -3
  9. data/vendor/assets/javascripts/rx.async.compat.js +15 -79
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +15 -79
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +38 -15
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.binding.js +42 -54
  16. data/vendor/assets/javascripts/rx.binding.min.js +1 -1
  17. data/vendor/assets/javascripts/rx.coincidence.js +6 -6
  18. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
  19. data/vendor/assets/javascripts/rx.compat.js +1234 -828
  20. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  21. data/vendor/assets/javascripts/rx.experimental.js +12 -6
  22. data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
  23. data/vendor/assets/javascripts/rx.joinpatterns.js +15 -11
  24. data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -1
  25. data/vendor/assets/javascripts/rx.js +1159 -791
  26. data/vendor/assets/javascripts/rx.lite.compat.js +1264 -920
  27. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  28. data/vendor/assets/javascripts/rx.lite.extras.js +99 -27
  29. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
  30. data/vendor/assets/javascripts/rx.lite.js +1192 -886
  31. data/vendor/assets/javascripts/rx.lite.min.js +2 -2
  32. data/vendor/assets/javascripts/rx.min.js +2 -2
  33. data/vendor/assets/javascripts/rx.testing.js +64 -63
  34. data/vendor/assets/javascripts/rx.testing.min.js +1 -1
  35. data/vendor/assets/javascripts/rx.time.js +32 -35
  36. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  37. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75f8a3704009ca13830dd5a7f7a542958f13eee7
4
- data.tar.gz: 634ed81f173c1b043a6b97f3eeecf3336225863f
3
+ metadata.gz: 90154ee9f6e01a69adabc55546cb1e35cf0572c5
4
+ data.tar.gz: 62a601fb667ebbe045dee17411aa157298e948ce
5
5
  SHA512:
6
- metadata.gz: c36351353ad1c9d8b4958963f8d6236733e5fc9935d4994f512cbe3d4513b13072eacab7db128c7d3e431a981453ba0a3cdf0dcb5d36a9c437f47aa3d4ee093c
7
- data.tar.gz: 7a9f637b69dfc552f0077d83230b06ca67300e9a8222c8305ba86fd3889c4dda6f9d74d9d16be1e75debaf4198968bb146f487ff2a975784dd910fcc200657ec
6
+ metadata.gz: a837c658258ba780d10c2cd2fed6c3ecfc95df90826907e58fe3dd439df5e048aa8ae5a45fe30c5602cfedb3d4a15b7d4a41bc1b769723536ae7e1e23570fc1c
7
+ data.tar.gz: a36375a443c32495901f7d456c6e6afde84d040266f7cab76e6abe767c1cd871d4f03d78e0002f99882926f821c69d96d6420d9de1ad51eaf1fa919f00cd7b7c
@@ -1,6 +1,6 @@
1
1
  module Rxjs
2
2
  module Rails
3
- VERSION = "2.3.22"
3
+ VERSION = "2.3.25"
4
4
  end
5
5
  end
6
6
 
@@ -50,39 +50,21 @@
50
50
  isIterable = helpers.isIterable,
51
51
  observableFromPromise = Observable.fromPromise,
52
52
  observableFrom = Observable.from,
53
- deprecate = helpers.deprecate;
53
+ bindCallback = Rx.internals.bindCallback;
54
54
 
55
55
  // Defaults
56
56
  var argumentOutOfRange = 'Argument out of range',
57
57
  sequenceContainsNoElements = "Sequence contains no elements.";
58
58
 
59
- observableProto.finalValue = function () {
60
- var source = this;
61
- return new AnonymousObservable(function (observer) {
62
- var hasValue = false, value;
63
- return source.subscribe(function (x) {
64
- hasValue = true;
65
- value = x;
66
- }, observer.onError.bind(observer), function () {
67
- if (!hasValue) {
68
- observer.onError(new Error(sequenceContainsNoElements));
69
- } else {
70
- observer.onNext(value);
71
- observer.onCompleted();
72
- }
73
- });
74
- }, source);
75
- };
76
-
77
59
  function extremaBy(source, keySelector, comparer) {
78
- return new AnonymousObservable(function (observer) {
60
+ return new AnonymousObservable(function (o) {
79
61
  var hasValue = false, lastKey = null, list = [];
80
62
  return source.subscribe(function (x) {
81
63
  var comparison, key;
82
64
  try {
83
65
  key = keySelector(x);
84
66
  } catch (ex) {
85
- observer.onError(ex);
67
+ o.onError(ex);
86
68
  return;
87
69
  }
88
70
  comparison = 0;
@@ -93,7 +75,7 @@
93
75
  try {
94
76
  comparison = comparer(key, lastKey);
95
77
  } catch (ex1) {
96
- observer.onError(ex1);
78
+ o.onError(ex1);
97
79
  return;
98
80
  }
99
81
  }
@@ -102,9 +84,9 @@
102
84
  list = [];
103
85
  }
104
86
  if (comparison >= 0) { list.push(x); }
105
- }, observer.onError.bind(observer), function () {
106
- observer.onNext(list);
107
- observer.onCompleted();
87
+ }, function (e) { o.onError(e); }, function () {
88
+ o.onNext(list);
89
+ o.onCompleted();
108
90
  });
109
91
  }, source);
110
92
  }
@@ -123,16 +105,41 @@
123
105
  * @returns {Observable} An observable sequence containing a single element with the final accumulator value.
124
106
  */
125
107
  observableProto.aggregate = function () {
126
- deprecate('aggregate', 'reduce');
127
- var seed, hasSeed, accumulator;
108
+ //deprecate('aggregate', 'reduce');
109
+ var hasSeed = false, accumulator, seed, source = this;
128
110
  if (arguments.length === 2) {
129
- seed = arguments[0];
130
111
  hasSeed = true;
112
+ seed = arguments[0];
131
113
  accumulator = arguments[1];
132
114
  } else {
133
115
  accumulator = arguments[0];
134
116
  }
135
- return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
117
+ return new AnonymousObservable(function (o) {
118
+ var hasAccumulation, accumulation, hasValue;
119
+ return source.subscribe (
120
+ function (x) {
121
+ !hasValue && (hasValue = true);
122
+ try {
123
+ if (hasAccumulation) {
124
+ accumulation = accumulator(accumulation, x);
125
+ } else {
126
+ accumulation = hasSeed ? accumulator(seed, x) : x;
127
+ hasAccumulation = true;
128
+ }
129
+ } catch (e) {
130
+ o.onError(e);
131
+ return;
132
+ }
133
+ },
134
+ function (e) { o.onError(e); },
135
+ function () {
136
+ hasValue && o.onNext(accumulation);
137
+ !hasValue && hasSeed && o.onNext(seed);
138
+ !hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
139
+ o.onCompleted();
140
+ }
141
+ );
142
+ }, source);
136
143
  };
137
144
 
138
145
  /**
@@ -143,12 +150,37 @@
143
150
  * @returns {Observable} An observable sequence containing a single element with the final accumulator value.
144
151
  */
145
152
  observableProto.reduce = function (accumulator) {
146
- var seed, hasSeed;
153
+ var hasSeed = false, seed, source = this;
147
154
  if (arguments.length === 2) {
148
155
  hasSeed = true;
149
156
  seed = arguments[1];
150
157
  }
151
- return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
158
+ return new AnonymousObservable(function (o) {
159
+ var hasAccumulation, accumulation, hasValue;
160
+ return source.subscribe (
161
+ function (x) {
162
+ !hasValue && (hasValue = true);
163
+ try {
164
+ if (hasAccumulation) {
165
+ accumulation = accumulator(accumulation, x);
166
+ } else {
167
+ accumulation = hasSeed ? accumulator(seed, x) : x;
168
+ hasAccumulation = true;
169
+ }
170
+ } catch (e) {
171
+ o.onError(e);
172
+ return;
173
+ }
174
+ },
175
+ function (e) { o.onError(e); },
176
+ function () {
177
+ hasValue && o.onNext(accumulation);
178
+ !hasValue && hasSeed && o.onNext(seed);
179
+ !hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
180
+ o.onCompleted();
181
+ }
182
+ );
183
+ }, source);
152
184
  };
153
185
 
154
186
  /**
@@ -164,7 +196,7 @@
164
196
  return source.subscribe(function () {
165
197
  observer.onNext(true);
166
198
  observer.onCompleted();
167
- }, observer.onError.bind(observer), function () {
199
+ }, function (e) { observer.onError(e); }, function () {
168
200
  observer.onNext(false);
169
201
  observer.onCompleted();
170
202
  });
@@ -173,7 +205,7 @@
173
205
 
174
206
  /** @deprecated use #some instead */
175
207
  observableProto.any = function () {
176
- deprecate('any', 'some');
208
+ //deprecate('any', 'some');
177
209
  return this.some.apply(this, arguments);
178
210
  };
179
211
 
@@ -197,60 +229,65 @@
197
229
 
198
230
  /** @deprecated use #every instead */
199
231
  observableProto.all = function () {
200
- deprecate('all', 'every');
232
+ //deprecate('all', 'every');
201
233
  return this.every.apply(this, arguments);
202
234
  };
203
235
 
204
236
  /**
205
- * Determines whether an observable sequence contains a specified element with an optional equality comparer.
237
+ * Determines whether an observable sequence includes a specified element with an optional equality comparer.
206
238
  * @param searchElement The value to locate in the source sequence.
207
239
  * @param {Number} [fromIndex] An equality comparer to compare elements.
208
- * @returns {Observable} An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value from the given index.
240
+ * @returns {Observable} An observable sequence containing a single element determining whether the source sequence includes an element that has the specified value from the given index.
209
241
  */
210
- observableProto.contains = function (searchElement, fromIndex) {
242
+ observableProto.includes = function (searchElement, fromIndex) {
211
243
  var source = this;
212
244
  function comparer(a, b) {
213
245
  return (a === 0 && b === 0) || (a === b || (isNaN(a) && isNaN(b)));
214
246
  }
215
- return new AnonymousObservable(function (observer) {
247
+ return new AnonymousObservable(function (o) {
216
248
  var i = 0, n = +fromIndex || 0;
217
249
  Math.abs(n) === Infinity && (n = 0);
218
250
  if (n < 0) {
219
- observer.onNext(false);
220
- observer.onCompleted();
251
+ o.onNext(false);
252
+ o.onCompleted();
221
253
  return disposableEmpty;
222
254
  }
223
255
  return source.subscribe(
224
256
  function (x) {
225
257
  if (i++ >= n && comparer(x, searchElement)) {
226
- observer.onNext(true);
227
- observer.onCompleted();
258
+ o.onNext(true);
259
+ o.onCompleted();
228
260
  }
229
261
  },
230
- observer.onError.bind(observer),
262
+ function (e) { o.onError(e); },
231
263
  function () {
232
- observer.onNext(false);
233
- observer.onCompleted();
264
+ o.onNext(false);
265
+ o.onCompleted();
234
266
  });
235
267
  }, this);
236
268
  };
237
269
 
238
- /**
239
- * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
240
- * @example
241
- * res = source.count();
242
- * res = source.count(function (x) { return x > 3; });
243
- * @param {Function} [predicate]A function to test each element for a condition.
244
- * @param {Any} [thisArg] Object to use as this when executing callback.
245
- * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.
246
- */
247
- observableProto.count = function (predicate, thisArg) {
248
- return predicate ?
249
- this.where(predicate, thisArg).count() :
250
- this.aggregate(0, function (count) {
251
- return count + 1;
252
- });
253
- };
270
+ /**
271
+ * @deprecated use #includes instead.
272
+ */
273
+ observableProto.contains = function (searchElement, fromIndex) {
274
+ //deprecate('contains', 'includes');
275
+ observableProto.includes(searchElement, fromIndex);
276
+ };
277
+ /**
278
+ * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.
279
+ * @example
280
+ * res = source.count();
281
+ * res = source.count(function (x) { return x > 3; });
282
+ * @param {Function} [predicate]A function to test each element for a condition.
283
+ * @param {Any} [thisArg] Object to use as this when executing callback.
284
+ * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.
285
+ */
286
+ observableProto.count = function (predicate, thisArg) {
287
+ return predicate ?
288
+ this.filter(predicate, thisArg).count() :
289
+ this.reduce(function (count) { return count + 1; }, 0);
290
+ };
254
291
 
255
292
  /**
256
293
  * Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.
@@ -260,26 +297,26 @@
260
297
  */
261
298
  observableProto.indexOf = function(searchElement, fromIndex) {
262
299
  var source = this;
263
- return new AnonymousObservable(function (observer) {
300
+ return new AnonymousObservable(function (o) {
264
301
  var i = 0, n = +fromIndex || 0;
265
302
  Math.abs(n) === Infinity && (n = 0);
266
303
  if (n < 0) {
267
- observer.onNext(-1);
268
- observer.onCompleted();
304
+ o.onNext(-1);
305
+ o.onCompleted();
269
306
  return disposableEmpty;
270
307
  }
271
308
  return source.subscribe(
272
309
  function (x) {
273
310
  if (i >= n && x === searchElement) {
274
- observer.onNext(i);
275
- observer.onCompleted();
311
+ o.onNext(i);
312
+ o.onCompleted();
276
313
  }
277
314
  i++;
278
315
  },
279
- observer.onError.bind(observer),
316
+ function (e) { o.onError(e); },
280
317
  function () {
281
- observer.onNext(-1);
282
- observer.onCompleted();
318
+ o.onNext(-1);
319
+ o.onCompleted();
283
320
  });
284
321
  }, source);
285
322
  };
@@ -293,9 +330,7 @@
293
330
  observableProto.sum = function (keySelector, thisArg) {
294
331
  return keySelector && isFunction(keySelector) ?
295
332
  this.map(keySelector, thisArg).sum() :
296
- this.reduce(function (prev, curr) {
297
- return prev + curr;
298
- }, 0);
333
+ this.reduce(function (prev, curr) { return prev + curr; }, 0);
299
334
  };
300
335
 
301
336
  /**
@@ -358,16 +393,14 @@
358
393
  */
359
394
  observableProto.average = function (keySelector, thisArg) {
360
395
  return keySelector && isFunction(keySelector) ?
361
- this.select(keySelector, thisArg).average() :
362
- this.scan({sum: 0, count: 0 }, function (prev, cur) {
396
+ this.map(keySelector, thisArg).average() :
397
+ this.reduce(function (prev, cur) {
363
398
  return {
364
399
  sum: prev.sum + cur,
365
400
  count: prev.count + 1
366
401
  };
367
- }).finalValue().map(function (s) {
368
- if (s.count === 0) {
369
- throw new Error('The input sequence was empty');
370
- }
402
+ }, {sum: 0, count: 0 }).map(function (s) {
403
+ if (s.count === 0) { throw new Error(sequenceContainsNoElements); }
371
404
  return s.sum / s.count;
372
405
  });
373
406
  };
@@ -387,7 +420,7 @@
387
420
  observableProto.sequenceEqual = function (second, comparer) {
388
421
  var first = this;
389
422
  comparer || (comparer = defaultComparer);
390
- return new AnonymousObservable(function (observer) {
423
+ return new AnonymousObservable(function (o) {
391
424
  var donel = false, doner = false, ql = [], qr = [];
392
425
  var subscription1 = first.subscribe(function (x) {
393
426
  var equal, v;
@@ -396,28 +429,28 @@
396
429
  try {
397
430
  equal = comparer(v, x);
398
431
  } catch (e) {
399
- observer.onError(e);
432
+ o.onError(e);
400
433
  return;
401
434
  }
402
435
  if (!equal) {
403
- observer.onNext(false);
404
- observer.onCompleted();
436
+ o.onNext(false);
437
+ o.onCompleted();
405
438
  }
406
439
  } else if (doner) {
407
- observer.onNext(false);
408
- observer.onCompleted();
440
+ o.onNext(false);
441
+ o.onCompleted();
409
442
  } else {
410
443
  ql.push(x);
411
444
  }
412
- }, observer.onError.bind(observer), function () {
445
+ }, function(e) { o.onError(e); }, function () {
413
446
  donel = true;
414
447
  if (ql.length === 0) {
415
448
  if (qr.length > 0) {
416
- observer.onNext(false);
417
- observer.onCompleted();
449
+ o.onNext(false);
450
+ o.onCompleted();
418
451
  } else if (doner) {
419
- observer.onNext(true);
420
- observer.onCompleted();
452
+ o.onNext(true);
453
+ o.onCompleted();
421
454
  }
422
455
  }
423
456
  });
@@ -431,28 +464,28 @@
431
464
  try {
432
465
  equal = comparer(v, x);
433
466
  } catch (exception) {
434
- observer.onError(exception);
467
+ o.onError(exception);
435
468
  return;
436
469
  }
437
470
  if (!equal) {
438
- observer.onNext(false);
439
- observer.onCompleted();
471
+ o.onNext(false);
472
+ o.onCompleted();
440
473
  }
441
474
  } else if (donel) {
442
- observer.onNext(false);
443
- observer.onCompleted();
475
+ o.onNext(false);
476
+ o.onCompleted();
444
477
  } else {
445
478
  qr.push(x);
446
479
  }
447
- }, observer.onError.bind(observer), function () {
480
+ }, function(e) { o.onError(e); }, function () {
448
481
  doner = true;
449
482
  if (qr.length === 0) {
450
483
  if (ql.length > 0) {
451
- observer.onNext(false);
452
- observer.onCompleted();
484
+ o.onNext(false);
485
+ o.onCompleted();
453
486
  } else if (donel) {
454
- observer.onNext(true);
455
- observer.onCompleted();
487
+ o.onNext(true);
488
+ o.onCompleted();
456
489
  }
457
490
  }
458
491
  });
@@ -462,19 +495,19 @@
462
495
 
463
496
  function elementAtOrDefault(source, index, hasDefault, defaultValue) {
464
497
  if (index < 0) { throw new Error(argumentOutOfRange); }
465
- return new AnonymousObservable(function (observer) {
498
+ return new AnonymousObservable(function (o) {
466
499
  var i = index;
467
500
  return source.subscribe(function (x) {
468
501
  if (i-- === 0) {
469
- observer.onNext(x);
470
- observer.onCompleted();
502
+ o.onNext(x);
503
+ o.onCompleted();
471
504
  }
472
- }, observer.onError.bind(observer), function () {
505
+ }, function (e) { o.onError(e); }, function () {
473
506
  if (!hasDefault) {
474
- observer.onError(new Error(argumentOutOfRange));
507
+ o.onError(new Error(argumentOutOfRange));
475
508
  } else {
476
- observer.onNext(defaultValue);
477
- observer.onCompleted();
509
+ o.onNext(defaultValue);
510
+ o.onCompleted();
478
511
  }
479
512
  });
480
513
  }, source);
@@ -505,21 +538,21 @@
505
538
  };
506
539
 
507
540
  function singleOrDefaultAsync(source, hasDefault, defaultValue) {
508
- return new AnonymousObservable(function (observer) {
541
+ return new AnonymousObservable(function (o) {
509
542
  var value = defaultValue, seenValue = false;
510
543
  return source.subscribe(function (x) {
511
544
  if (seenValue) {
512
- observer.onError(new Error('Sequence contains more than one element'));
545
+ o.onError(new Error('Sequence contains more than one element'));
513
546
  } else {
514
547
  value = x;
515
548
  seenValue = true;
516
549
  }
517
- }, observer.onError.bind(observer), function () {
550
+ }, function (e) { o.onError(e); }, function () {
518
551
  if (!seenValue && !hasDefault) {
519
- observer.onError(new Error(sequenceContainsNoElements));
552
+ o.onError(new Error(sequenceContainsNoElements));
520
553
  } else {
521
- observer.onNext(value);
522
- observer.onCompleted();
554
+ o.onNext(value);
555
+ o.onCompleted();
523
556
  }
524
557
  });
525
558
  }, source);
@@ -552,21 +585,21 @@
552
585
  */
553
586
  observableProto.singleOrDefault = function (predicate, defaultValue, thisArg) {
554
587
  return predicate && isFunction(predicate) ?
555
- this.where(predicate, thisArg).singleOrDefault(null, defaultValue) :
588
+ this.filter(predicate, thisArg).singleOrDefault(null, defaultValue) :
556
589
  singleOrDefaultAsync(this, true, defaultValue);
557
590
  };
558
591
 
559
592
  function firstOrDefaultAsync(source, hasDefault, defaultValue) {
560
- return new AnonymousObservable(function (observer) {
593
+ return new AnonymousObservable(function (o) {
561
594
  return source.subscribe(function (x) {
562
- observer.onNext(x);
563
- observer.onCompleted();
564
- }, observer.onError.bind(observer), function () {
595
+ o.onNext(x);
596
+ o.onCompleted();
597
+ }, function (e) { o.onError(e); }, function () {
565
598
  if (!hasDefault) {
566
- observer.onError(new Error(sequenceContainsNoElements));
599
+ o.onError(new Error(sequenceContainsNoElements));
567
600
  } else {
568
- observer.onNext(defaultValue);
569
- observer.onCompleted();
601
+ o.onNext(defaultValue);
602
+ o.onCompleted();
570
603
  }
571
604
  });
572
605
  }, source);
@@ -601,17 +634,17 @@
601
634
  };
602
635
 
603
636
  function lastOrDefaultAsync(source, hasDefault, defaultValue) {
604
- return new AnonymousObservable(function (observer) {
637
+ return new AnonymousObservable(function (o) {
605
638
  var value = defaultValue, seenValue = false;
606
639
  return source.subscribe(function (x) {
607
640
  value = x;
608
641
  seenValue = true;
609
- }, observer.onError.bind(observer), function () {
642
+ }, function (e) { o.onError(e); }, function () {
610
643
  if (!seenValue && !hasDefault) {
611
- observer.onError(new Error(sequenceContainsNoElements));
644
+ o.onError(new Error(sequenceContainsNoElements));
612
645
  } else {
613
- observer.onNext(value);
614
- observer.onCompleted();
646
+ o.onNext(value);
647
+ o.onCompleted();
615
648
  }
616
649
  });
617
650
  }, source);
@@ -643,25 +676,26 @@
643
676
  };
644
677
 
645
678
  function findValue (source, predicate, thisArg, yieldIndex) {
646
- return new AnonymousObservable(function (observer) {
679
+ var callback = bindCallback(predicate, thisArg, 3);
680
+ return new AnonymousObservable(function (o) {
647
681
  var i = 0;
648
682
  return source.subscribe(function (x) {
649
683
  var shouldRun;
650
684
  try {
651
- shouldRun = predicate.call(thisArg, x, i, source);
685
+ shouldRun = callback(x, i, source);
652
686
  } catch (e) {
653
- observer.onError(e);
687
+ o.onError(e);
654
688
  return;
655
689
  }
656
690
  if (shouldRun) {
657
- observer.onNext(yieldIndex ? i : x);
658
- observer.onCompleted();
691
+ o.onNext(yieldIndex ? i : x);
692
+ o.onCompleted();
659
693
  } else {
660
694
  i++;
661
695
  }
662
- }, observer.onError.bind(observer), function () {
663
- observer.onNext(yieldIndex ? -1 : undefined);
664
- observer.onCompleted();
696
+ }, function (e) { o.onError(e); }, function () {
697
+ o.onNext(yieldIndex ? -1 : undefined);
698
+ o.onCompleted();
665
699
  });
666
700
  }, source);
667
701
  }
@@ -687,7 +721,6 @@
687
721
  return findValue(this, predicate, thisArg, true);
688
722
  };
689
723
 
690
-
691
724
  /**
692
725
  * Converts the observable sequence to a Set if it exists.
693
726
  * @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence.
@@ -695,19 +728,18 @@
695
728
  observableProto.toSet = function () {
696
729
  if (typeof root.Set === 'undefined') { throw new TypeError(); }
697
730
  var source = this;
698
- return new AnonymousObservable(function (observer) {
731
+ return new AnonymousObservable(function (o) {
699
732
  var s = new root.Set();
700
733
  return source.subscribe(
701
- s.add.bind(s),
702
- observer.onError.bind(observer),
734
+ function (x) { s.add(x); },
735
+ function (e) { o.onError(e); },
703
736
  function () {
704
- observer.onNext(s);
705
- observer.onCompleted();
737
+ o.onNext(s);
738
+ o.onCompleted();
706
739
  });
707
740
  }, source);
708
741
  };
709
742
 
710
-
711
743
  /**
712
744
  * Converts the observable sequence to a Map if it exists.
713
745
  * @param {Function} keySelector A function which produces the key for the Map.
@@ -717,7 +749,7 @@
717
749
  observableProto.toMap = function (keySelector, elementSelector) {
718
750
  if (typeof root.Map === 'undefined') { throw new TypeError(); }
719
751
  var source = this;
720
- return new AnonymousObservable(function (observer) {
752
+ return new AnonymousObservable(function (o) {
721
753
  var m = new root.Map();
722
754
  return source.subscribe(
723
755
  function (x) {
@@ -725,7 +757,7 @@
725
757
  try {
726
758
  key = keySelector(x);
727
759
  } catch (e) {
728
- observer.onError(e);
760
+ o.onError(e);
729
761
  return;
730
762
  }
731
763
 
@@ -734,17 +766,17 @@
734
766
  try {
735
767
  element = elementSelector(x);
736
768
  } catch (e) {
737
- observer.onError(e);
769
+ o.onError(e);
738
770
  return;
739
771
  }
740
772
  }
741
773
 
742
774
  m.set(key, element);
743
775
  },
744
- observer.onError.bind(observer),
776
+ function (e) { o.onError(e); },
745
777
  function () {
746
- observer.onNext(m);
747
- observer.onCompleted();
778
+ o.onNext(m);
779
+ o.onCompleted();
748
780
  });
749
781
  }, source);
750
782
  };