11import { obj_assign_props } from "./object.ts" ;
22import { isPromiseLike } from "./promise-helper.ts" ;
3- import { pureEvent } from "./pure_event.ts" ;
3+ import { pureEvent , PureEventWithApply } from "./pure_event.ts" ;
44
55/**
66 * 函数转化,一个新函数:它的第一个参数 将作为 原函数的 this
@@ -265,7 +265,7 @@ export const withEffect = <T extends object>(source: T, effect: Func<void, [T]>)
265265 * 执行副作用
266266 * @param sources
267267 */
268- export const applyEffect = ( ...sources : ( WithEffect | object ) [ ] ) => {
268+ export const applyEffect = ( ...sources : ( WithEffect | object ) [ ] ) : void => {
269269 for ( const source of sources ) {
270270 if ( effect_symbol in source ) {
271271 const effect = source [ effect_symbol ] ;
@@ -286,7 +286,14 @@ export const applyEffect = (...sources: (WithEffect | object)[]) => {
286286 * 每个函数的结果会通过 `returns` 事件的 `emit` 方法发出,数据格式为 `{ source: T; result: FuncCatch.Return<unknown, Func.Return<T>> }`。
287287 * `result` 是一个元组,成功时为 `[undefined, R]`,失败时为 `[E, undefined]`,并附带 `success`、`result` 和 `error` 属性。
288288 */
289- export const func_parallel_limit = < T extends Func < void > > ( funcs : Iterable < T > | AsyncIterable < T > , limit : number ) => {
289+ export const func_parallel_limit = < T extends Func < void > > (
290+ funcs : Iterable < T > | AsyncIterable < T > ,
291+ limit : number ,
292+ ) : PureEventWithApply < {
293+ source : T ;
294+ result : FuncCatch . Return < unknown , Func . Return < T > > ;
295+ } > &
296+ PromiseLike < void [ ] > => {
290297 const returns = pureEvent < { source : T ; result : FuncCatch . Return < unknown , Func . Return < T > > } > ( ) ;
291298 const func_iter = Symbol . asyncIterator in funcs ? funcs [ Symbol . asyncIterator ] ( ) : funcs [ Symbol . iterator ] ( ) ;
292299 const done = Promise . withResolvers < void [ ] > ( ) ;
0 commit comments