Skip to content

Instantly share code, notes, and snippets.

@koichik
Created April 15, 2011 09:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koichik/921465 to your computer and use it in GitHub Desktop.
Save koichik/921465 to your computer and use it in GitHub Desktop.
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