-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement reduceLazy
(#239)
#245
Conversation
reduce(f, iterable as any); | ||
} | ||
return (iterable: Iterable<unknown> | AsyncIterable<unknown>) => | ||
reduce(f, seed, iterable as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any idea to overcome this, and reduce
also uses as any
so I just simply suppress them.
Actually it's common to use anyscript(😆) for implementation if type signatures are sufficiently provided.
) => IterableInfer<T> | Promise<IterableInfer<T>>, | ||
): (iterable: T) => ReturnValueType<T, IterableInfer<T>>; | ||
f: AsyncReducer<IterableInfer<T>, IterableInfer<T>>, | ||
): (iterable: T) => ReturnValueType<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReturnValueType<T>
is equivalent to ReturnValueType<T, IterableInfer<T>>
. See ReturnValueType.ts
.
Note that test succeed for |
* {@link https://github.com/marpple/FxTS/issues/239 | #related issue} | ||
* | ||
* For backward compatibility, `reduce` can support partial lazy form. | ||
* You may want to use `reduceLazy` to use `seed`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* You may want to use `reduceLazy` to use `seed`. | |
* You may want to use {@link https://fxts.dev/docs/reduceLazy | reduceLazy} to use `seed`. |
expect(reduce([])).toEqual("seed"); | ||
}); | ||
|
||
it("should be occured error when the given `iterable` is an empty array and initial value is absent", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it("should be occured error when the given `iterable` is an empty array and initial value is absent", () => { | |
it("should be occurred error when the given `iterable` is an empty array and initial value is absent", () => { |
LGTM👍 |
Fixes #239
reduce
asSyncReducer
andAsyncReducer
reduce
andreduceLazy
reduceLazy
reduce
covers lazy cases 100%, but it wasn'treduce
with rich dedicated typesreduceLazy
SyncReducer
vsAsyncReducer
Iterable
vsAsyncIterable
reduce
reduce