stack-sites
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "stack-sites", | ||
"description": "Returns current stack as call sites", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/bahmutov/stack-sites/issues", |
'use strict' | ||
const la = require('lazy-ass') | ||
const is = require('check-more-types') | ||
const parseStackLine = require('./parse-stack-line') | ||
function isNotEmpty (s) { | ||
return s | ||
} | ||
// s is like (/src/index.js:4:13) | ||
function parseAt (s) { | ||
const parts = s.replace(/\(/, '') | ||
.replace(/\)/, '') | ||
.trim() | ||
.split(':') | ||
la(parts.length === 3, 'invalid number of parts', s) | ||
return { | ||
filename: parts[0], | ||
line: parts[1], | ||
column: parts[2] | ||
} | ||
} | ||
function toSite (line) { | ||
la(is.unemptyString(line), 'invalid line', line) | ||
const parts = line.split(' ').filter(isNotEmpty) | ||
const at = parseAt(parts[2]) | ||
return { | ||
functionName: parts[1], | ||
filename: at.filename, | ||
line: Number(at.line), | ||
column: Number(at.column) | ||
} | ||
} | ||
function hasLineInfo (line) { | ||
@@ -50,5 +19,5 @@ return line.includes('(') && line.includes(')') | ||
.filter(isModule) | ||
.map(toSite) | ||
.map(parseStackLine) | ||
} | ||
module.exports = stackSites |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6475
4
55