Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

elementAt.js 642B

123456789101112131415
  1. import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';
  2. import { filter } from './filter';
  3. import { throwIfEmpty } from './throwIfEmpty';
  4. import { defaultIfEmpty } from './defaultIfEmpty';
  5. import { take } from './take';
  6. export function elementAt(index, defaultValue) {
  7. if (index < 0) {
  8. throw new ArgumentOutOfRangeError();
  9. }
  10. const hasDefaultValue = arguments.length >= 2;
  11. return (source) => source.pipe(filter((v, i) => i === index), take(1), hasDefaultValue
  12. ? defaultIfEmpty(defaultValue)
  13. : throwIfEmpty(() => new ArgumentOutOfRangeError()));
  14. }
  15. //# sourceMappingURL=elementAt.js.map