Created
April 15, 2011 09:35
-
-
Save koichik/921465 to your computer and use it in GitHub Desktop.
getLineNumber
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
// http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi | |
function customPrepareStackTrace(error, structuredStackTrace) { | |
return structuredStackTrace[0].getLineNumber(); | |
}; | |
function getLineNumber() { | |
var original = Error.prepareStackTrace; | |
Error.prepareStackTrace = customPrepareStackTrace; | |
var error = {}; | |
Error.captureStackTrace(error, getLineNumber); | |
var lineNumber = error.stack; | |
Error.prepareStackTrace = original; | |
return lineNumber; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment