Skip to content

Instantly share code, notes, and snippets.

@protosam
Created June 6, 2017 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save protosam/63ef5b8810889ebbb40fa20efd588dc8 to your computer and use it in GitHub Desktop.
Save protosam/63ef5b8810889ebbb40fa20efd588dc8 to your computer and use it in GitHub Desktop.
// 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