Created
June 6, 2017 16:13
-
-
Save protosam/63ef5b8810889ebbb40fa20efd588dc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// something I am playing with right now... | |
var S_ = null; | |
var S__calls = []; | |
var S = function(){ | |
self.S__calls.push([name, Array.prototype.slice.call(arguments)]); | |
self.S_ = new Proxy({},{ | |
get: function(target, name){ | |
console.log(name); | |
if(name in target){ | |
return self.S__calls; | |
} | |
self.S__calls.push([name, null]); | |
return function(){ | |
args = Array.prototype.slice.call(arguments); | |
for(var i=0; i<args.length;i++){ | |
if(typeof(args[i])=='function'){ | |
args[i] = ["__/function__", args[i].toString()]; | |
}else{ | |
args[i] = args[i]; | |
} | |
} | |
self.S__calls[self.S__calls.length-1][1] = args; | |
return self.S_; | |
} | |
}, | |
set: function(target, name, value){ | |
// does nothing yet. | |
} | |
}); | |
return self.S_; | |
} | |
console.log(S('first').a('hello').world().afn(function(){/*syntax*/}).length) | |
// digest function maybe? | |
console.log(JSON.stringify(S__calls)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment