0

I've been running across this idea and struggle to understand its meaning.

This is one example:

'In terms of what they can express, callbacks and promises are equivalent. Callback-based functions can be wrapped to expose a promise-based interface, and vice versa.'

I'm less interested in the context of this example, than I am in what it means to 'wrap a function'.

clinzy25
  • 91
  • 8
  • "what it means to 'wrap a function'." - Nothing fancy. A wrapper is just a function that calls another function and possibly transforms its input or output or something else. – Sergio Tulentsev Mar 04 '21 at 14:41
  • 1
    The word means the same as it does in standard English. You put a promise around the call to the function that takes a calback. – Quentin Mar 04 '21 at 14:42
  • 2
    `parseInt` is a function. `parseHex = x => parseInt(x, 16)` is a function that wraps `parseInt` – VLAZ Mar 04 '21 at 14:51

0 Answers0