try {
const first = source.first();
// first yields any number of values, the first of which could be undefined.
} catch (ex) {
// invalid operation, there is no such thing as first.
}
Expected behavior:first throws an exception when no value is yielded from source.
Actual behavior:first ambiguously yields undefined if no value is yielded from source.
Additional information:first currently exhibits the ideal behavior of hypothetical firstOrDefault() / firstOrDefault(undefined) / first(undefined).
firstOrDefault can be implemented in terms of a first which throws on no yield, but first should not be implemented in terms of firstOrDefault.
If backwards compatibility is strictly necessary, suggest adding a flag to first, or creating new function firstOrError.
IxJS version: 2.5.3
Code to reproduce:
Expected behavior:
first
throws an exception when no value is yielded from source.Actual behavior:
first
ambiguously yieldsundefined
if no value is yielded from source.Additional information:
first
currently exhibits the ideal behavior of hypotheticalfirstOrDefault()
/firstOrDefault(undefined)
/first(undefined)
.firstOrDefault
can be implemented in terms of afirst
which throws on no yield, butfirst
should not be implemented in terms offirstOrDefault
.If backwards compatibility is strictly necessary, suggest adding a flag to
first
, or creating new functionfirstOrError
.