/
Closure.js
36 lines (34 loc) · 1.09 KB
/
Closure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*****************************************************************************
*
*****************************************************************************/
CLASS( "utils.Closure")
.DEFINITION( function() {
this.constructor = function( target, executable) {
var args = [].slice.call( arguments, 2);
this.target = target;
this.executable = executable;
this.args = args;
this.execute = function() {
var _args = [].slice.call( arguments);
executable.apply( target, args.concat( _args));
};
this.compare = function( in_closure) {
if( this.target != in_closure.target) return false;
if( this.executable != in_closure.executable) return false;
if( this.args.length != in_closure.args.length) return false;
for( var i = 0; i < this.args.length; i++) {
if( this.args[ i] != in_closure.args[ i]) return false;
}
return true;
};
};
})
.STATIC( function() {
this.wrap = function( target, executable) {
var args = [].slice.call( arguments, 2);
return function() {
var _args = [].slice.call( arguments);
executable.apply( target, args.concat( _args));
};
};
});