Skip to content

Instantly share code, notes, and snippets.

@koichik
Created Apr 15, 2011
Embed
What would you like to do?
getLineNumber
// 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