how to use the wrap function from lodash in javascript

The wrap function from Lodash creates a function that wraps func to enable currying.

Here's an example of how to use it:

index.tsx
const wrapped = _.wrap(5, function(func, x) {
  return func(x);
});

console.log(wrapped(Math.sqrt)); // => 2.23606797749979
125 chars
6 lines

In this example, wrap is used to create a function wrapped that takes a function func as its argument, and returns a new function that takes a second argument x, applies func to x, and returns the result. In this case, we're passing Math.sqrt as the func argument to wrapped, and then calling wrapped(25) to apply Math.sqrt to the value 25.

Hope this helps!

gistlibby LogSnag