| 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 ? defaultIfEmpty(defaultValue) : throwIfEmpty(() => new ArgumentOutOfRangeError())); |
| 12 |
} |
| 13 |
//# sourceMappingURL=elementAt.js.map |