the method knows shared as soon as you define it inside your closure ...
```
var lib;
(function () {
var shared;
shared = 'a shared value';
function wrap(method) {
return function () {
var args = [].slice.call(arguments);
args[0] = shared;
return method.aply(this, args);
};
}
lib = {
method: function method(foreignObject) {
var property;
for (property in foreignObject) {
if (foreignObject.hasOwnProperty('property')) {
if (typeof foreignObject[property] === 'function') {
foreignObject[property]
= wrap(foreignObject[property]);
}
}
}
}
};
}());
```
... take care ...
On Fri, Jul 25, 2014 at 1:25 PM, Michaël Rouges <[email protected]>
wrote:
> @Andrea :
>
> Yeah, I don't really want to rewrite the methods, I only want to share my
> "shared" variable with these methods.
>
> Furthermore, your code don't works because "method" don't knows "shared".
>
>
>
> Michaël Rouges - https://github.com/Lcfvs - @Lcfvs
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss