Created
March 21, 2018 10:35
-
-
Save onyxblade/2acb79526b56b589fc03e9129d844d29 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
function lodash (obj) { | |
var createProxy = function (obj) { | |
return new Proxy(obj, { | |
get (target, name) { | |
if (_[name]) { | |
return function (...args) { | |
var result = _[name](target, ...args) | |
if (typeof result === 'object') { | |
return createProxy(result) | |
} else { | |
return result | |
} | |
} | |
} else { | |
return target[name] | |
} | |
} | |
}) | |
} | |
return createProxy(obj) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment