Created
April 26, 2017 16:41
-
-
Save cvazac/c1d1925663e323e318b93c4e7cdb1557 to your computer and use it in GitHub Desktop.
checkNatives
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 isNativeFunction(fn) { | |
return typeof fn === 'function' && fn.toString && !fn.hasOwnProperty('toString') && | |
/\[native code\]/.test(String(fn)) | |
} | |
function checkNatives(fns) { | |
var results = [] | |
for (var i = 0; i < fns.length; i++) { | |
results[i] = { | |
fn: fns[i], | |
native: isNativeFunction(fns[i]) | |
} | |
} | |
return results | |
} | |
console.info(checkNatives([setTimeout, XMLHttpRequest])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment