To use the over
function from the Lodash library in TypeScript, you first need to install it via npm:
index.ts19 chars2 lines
You then import the function and define the functions you want to "over" (apply the function to):
index.ts218 chars9 lines
In this example, the over
function is applied to getSum
and getProduct
, which are both functions that take two arguments (a
and b
) and return a value. The over
function returns a new function that takes the same arguments as the original functions, and applies each function to the arguments given. In this case, when overFunc
is called with arguments 2
and 3
, it applies getSum(2, 3)
and getProduct(2, 3)
, and returns the array [5, 6]
.
gistlibby LogSnag