Written to avoid the noisome pattern of
input => {
const reference = expression with input
sideEffects(reference)
return reference
}
…which can instead be expressed as
give(me =>
input => {
sideEffects(
me(expression with input)
)
}
)
For functional scenarios where a non-yielding side effect expressions comprises the desired return value.
The value lies in avoiding 2 keywords and temporary assignment with 2 repetitions of 'reference' in preference for 2 generic references with one repetition.
The give(me => /**/)
pattern can be translated as, 'the return value for the following function is a nested expression (this one)'.
Straw man:
const doubles = values.map(
give(me =>
value => {
alert(
me(2 * value)
)
}
)
)