Interface IloopCallbacks<Titem, TidxKey, Tinput, TmapItemReturn, TmapKeyReturn>

The sole purpose of callbacks to exist here in IloopCallbacks, separately from ILoopOptions, is due to a Zen/TypeScript limitation, that doesn't properly infer the type of a callback's arguments (it ignores the options, probably cause they belong to same type interface before it has been initialized).

So, in order to have perfect automatic inference of args, callbacks have to be in a separate 3rd argument in loop() parameters, loop(input, options, callbacks) eg

loop(input, {props: true}, { map: (val, prop) => val *2 })

instead of the desired (but type-breaking)

loop(input, {props: true, map: (val, prop) => val *2 }) // BREAKS TypeScript type inference of callback args

Implementation-wise & at runtime, the 2 are equivalent

Type Parameters

  • Titem
  • TidxKey
  • Tinput
  • TmapItemReturn = any
  • TmapKeyReturn = any

Properties

filter in IloopCallbacks

map in IloopCallbacks

mapKeys in IloopCallbacks

take?: number | TakeCallback<Titem, TidxKey, Tinput>

take in IloopCallbacks