Last active
July 14, 2016 13:21
-
-
Save cocoabox/21da690ef2529b7a84f160967a8f8aa6 to your computer and use it in GitHub Desktop.
JS でとある関数が nativeかどうか判定する
This file contains hidden or 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
| /** | |
| * detect if function is native | |
| * @param {function} func | |
| * @return {boolean|null} returns true if func is native, false if not, or null if func is not a function | |
| */ | |
| var isNative = function(func){ | |
| return typeof func!=="function" | |
| ?null | |
| :(null!==(""+func.toString()).match(/^\s*function\s*([^\s]+)\s*\{\s*\[native code\]\s*\}\s*$/)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment