a zip code crypto-currency system good for red ONLY

distinctUntilChanged.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { distinctUntilChanged as higherOrder } from '../operators/distinctUntilChanged';
  2. /* tslint:enable:max-line-length */
  3. /**
  4. * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from the previous item.
  5. *
  6. * If a comparator function is provided, then it will be called for each item to test for whether or not that value should be emitted.
  7. *
  8. * If a comparator function is not provided, an equality check is used by default.
  9. *
  10. * @example <caption>A simple example with numbers</caption>
  11. * Observable.of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4)
  12. * .distinctUntilChanged()
  13. * .subscribe(x => console.log(x)); // 1, 2, 1, 2, 3, 4
  14. *
  15. * @example <caption>An example using a compare function</caption>
  16. * interface Person {
  17. * age: number,
  18. * name: string
  19. * }
  20. *
  21. * Observable.of<Person>(
  22. * { age: 4, name: 'Foo'},
  23. * { age: 7, name: 'Bar'},
  24. * { age: 5, name: 'Foo'})
  25. * { age: 6, name: 'Foo'})
  26. * .distinctUntilChanged((p: Person, q: Person) => p.name === q.name)
  27. * .subscribe(x => console.log(x));
  28. *
  29. * // displays:
  30. * // { age: 4, name: 'Foo' }
  31. * // { age: 7, name: 'Bar' }
  32. * // { age: 5, name: 'Foo' }
  33. *
  34. * @see {@link distinct}
  35. * @see {@link distinctUntilKeyChanged}
  36. *
  37. * @param {function} [compare] Optional comparison function called to test if an item is distinct from the previous item in the source.
  38. * @return {Observable} An Observable that emits items from the source Observable with distinct values.
  39. * @method distinctUntilChanged
  40. * @owner Observable
  41. */
  42. export function distinctUntilChanged(compare, keySelector) {
  43. return higherOrder(compare, keySelector)(this);
  44. }
  45. //# sourceMappingURL=distinctUntilChanged.js.map