a zip code crypto-currency system good for red ONLY

first.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /** PURE_IMPORTS_START .._operators_first PURE_IMPORTS_END */
  2. import { first as higherOrder } from '../operators/first';
  3. /**
  4. * Emits only the first value (or the first value that meets some condition)
  5. * emitted by the source Observable.
  6. *
  7. * <span class="informal">Emits only the first value. Or emits only the first
  8. * value that passes some test.</span>
  9. *
  10. * <img src="./img/first.png" width="100%">
  11. *
  12. * If called with no arguments, `first` emits the first value of the source
  13. * Observable, then completes. If called with a `predicate` function, `first`
  14. * emits the first value of the source that matches the specified condition. It
  15. * may also take a `resultSelector` function to produce the output value from
  16. * the input value, and a `defaultValue` to emit in case the source completes
  17. * before it is able to emit a valid value. Throws an error if `defaultValue`
  18. * was not provided and a matching element is not found.
  19. *
  20. * @example <caption>Emit only the first click that happens on the DOM</caption>
  21. * var clicks = Rx.Observable.fromEvent(document, 'click');
  22. * var result = clicks.first();
  23. * result.subscribe(x => console.log(x));
  24. *
  25. * @example <caption>Emits the first click that happens on a DIV</caption>
  26. * var clicks = Rx.Observable.fromEvent(document, 'click');
  27. * var result = clicks.first(ev => ev.target.tagName === 'DIV');
  28. * result.subscribe(x => console.log(x));
  29. *
  30. * @see {@link filter}
  31. * @see {@link find}
  32. * @see {@link take}
  33. *
  34. * @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
  35. * callback if the Observable completes before any `next` notification was sent.
  36. *
  37. * @param {function(value: T, index: number, source: Observable<T>): boolean} [predicate]
  38. * An optional function called with each item to test for condition matching.
  39. * @param {function(value: T, index: number): R} [resultSelector] A function to
  40. * produce the value on the output Observable based on the values
  41. * and the indices of the source Observable. The arguments passed to this
  42. * function are:
  43. * - `value`: the value that was emitted on the source.
  44. * - `index`: the "index" of the value from the source.
  45. * @param {R} [defaultValue] The default value emitted in case no valid value
  46. * was found on the source.
  47. * @return {Observable<T|R>} An Observable of the first item that matches the
  48. * condition.
  49. * @method first
  50. * @owner Observable
  51. */
  52. export function first(predicate, resultSelector, defaultValue) {
  53. return higherOrder(predicate, resultSelector, defaultValue)(this);
  54. }
  55. //# sourceMappingURL=first.js.map