Seems as if you want to add an eventlistener for when move is called:
move = (function(old) {
var handlers = [];
function move() {
old.apply(this, arguments);
handlers.forEach(function(handler) { handler(); });
}
move.wasCalled = function(handler) { handlers.push(handler) };
return move;
};
})(move);
So you can use it as:
move.wasCalled(function() {
//...
});
move();
If you however want to determine synchronously if the function was added already, just set a property when move was called, it can be rewritten as:
move = (old => (...args) => {
move.wasCalled = true;
old(...args);
})(move);
Or for older environments:
move = (function(old) {
return function() {
move.wasCalled = true;
old.apply(null, arguments);
};
})(move);
So now
if(move.wasCalled) { /*...*/ }
actually works