I am write a compatibility layer over a legacy library function whose internal signature looks like —
function legacyLibraryFunction(context) {
context.foo.bar = "data"
return context
}
The new system however, doesn't recommend assigning custom properties directly to context
and instead recommends using the context.set()
method.
How do I pass context
from the new system to the old one so that context.foo="data"
ends up called context.set('foo', data)
instead?
I'm guessing I can use Object.defineProperty for this, but I don't really understand how.