-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
.nyc_output | ||
coverage | ||
tmp | ||
.idea |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { isAbsolute, join, dirname } = require('path') | ||
const { readFileSync } = require('fs') | ||
/** | ||
* Extract the sourcemap url from a source file | ||
* reference: https://sourcemaps.info/spec.html | ||
* @param {String} file - compilation target file | ||
* @returns {String} full path to source map file | ||
* @private | ||
*/ | ||
function getSourceMapFromFile (file) { | ||
const fileBody = readFileSync(file).toString() | ||
const sourceMapLineRE = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/mg | ||
const results = fileBody.match(sourceMapLineRE) | ||
if (results !== null) { | ||
const sourceMap = results[results.length - 1].split('=')[1] | ||
if (isAbsolute(sourceMap)) { | ||
return sourceMap | ||
} else { | ||
const base = dirname(file) | ||
return join(base, sourceMap) | ||
} | ||
} | ||
} | ||
|
||
module.exports = getSourceMapFromFile |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,4 @@ | |
"bin", | ||
"LICENSE" | ||
] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function Unloaded(){ | ||
return 'Never loaded :(' | ||
} | ||
|
||
console.log("This file shouldn't have been evaluated") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export default function getString(i){ | ||
if (typeof i === 'number'){ | ||
if (isNaN(i)){ | ||
return 'NaN' | ||
} | ||
else if (i === 0){ | ||
return 'zero' | ||
} | ||
else if (i > 0){ | ||
return 'positive' | ||
} | ||
else { | ||
return 'negative' | ||
} | ||
} | ||
else { | ||
return 'wat?' | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import getString from "./loaded" | ||
console.log(getString(0)) | ||
console.log(getString(1)) | ||
console.log(getString(-1)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function Unloaded(){ | ||
return 'Never loaded :(' | ||
} | ||
|
||
console.log("This file shouldn't have been evaluated") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export default function getString(i){ | ||
if (typeof i === 'number'){ | ||
if (isNaN(i)){ | ||
return 'NaN' | ||
} | ||
else if (i === 0){ | ||
return 'zero' | ||
} | ||
else if (i > 0){ | ||
return 'positive' | ||
} | ||
else { | ||
return 'negative' | ||
} | ||
} | ||
else { | ||
return 'wat?' | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import getString from "./loaded" | ||
console.log(getString(0)) | ||
console.log(getString(1)) | ||
console.log(getString(-1)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = function Unloaded(){ | ||
return 'Never loaded :(' | ||
} | ||
|
||
console.log("This file shouldn't have been evaluated") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = function getString(i){ | ||
if (typeof i === 'number'){ | ||
if (isNaN(i)){ | ||
return 'NaN' | ||
} | ||
else if (i === 0){ | ||
return 'zero' | ||
} | ||
else if (i > 0){ | ||
return 'positive' | ||
} | ||
else { | ||
return 'negative' | ||
} | ||
} | ||
else { | ||
return 'wat?' | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const loaded = require('./loaded.js'); | ||
console.log(loaded(0)) | ||
console.log(loaded(1)) | ||
console.log(loaded(-1)) |