Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
642 bytes
|
Line | |
---|
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 |
---|
Note:
See
TracBrowser
for help on using the repository browser.