Socket
Socket
Sign inDemoInstall

source-mapper

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

source-mapper - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

.travis.yml

7

CHANGES.md
# Changes
## 1.0.0
- Use Browserify 5.9 for testing
- Map `<anonymous>` lines
- Use through2
- Use convert-source-map ^0.4
## 0.3.0

@@ -4,0 +11,0 @@

35

lib/source-mapper.js

@@ -10,3 +10,3 @@ /*

var through = require('through');
var through = require('through2');
var convert = require('convert-source-map');

@@ -16,4 +16,4 @@ var sourceMap = require('source-map');

var stackRE = new RegExp('^(\\s*(?:at (?:.+ \\()?)?)'
+ '(\\[stdin\\]|about:blank|(?:http|file)\\:\\/\\/.+|Unknown script code)'
+ '\\:([0-9]+)(\\:[0-9]+\\)?$|\\)?$)', 'gm');
+ '(\\[stdin\\]|about:blank|(?:http|file)\\:\\/\\/.+|Unknown script code|'
+ '<anonymous>)\\:([0-9]+)(\\:[0-9]+\\)?$|\\)?$)', 'gm');

@@ -60,16 +60,21 @@

var buf = '';
return through(function (data) {
if (data) {
buf += data.toString();
var p = buf.lastIndexOf('\n');
if (p !== -1) {
this.queue(exports.line(consumer, buf.substring(0, p + 1), offset));
buf = buf.substring(p + 1);
}
if (buf.length > 3 && !/^\s+at /.test(buf)) {
this.queue(buf);
buf = '';
}
return through(function (chunk, enc, next) {
/*jslint unparam: true*/
buf += chunk.toString();
var p = buf.lastIndexOf('\n');
if (p !== -1) {
this.push(exports.line(consumer, buf.substring(0, p + 1), offset));
buf = buf.substring(p + 1);
}
if (buf.length > 3 && !/^\s+at /.test(buf)) {
this.push(buf);
buf = '';
}
next();
}, function (next) {
if (buf) {
this.push(buf);
}
next();
});
};
{
"name": "source-mapper",
"version": "0.3.0",
"version": "1.0.0",
"description": "Replace URLs in track traces with original sources",

@@ -17,4 +17,4 @@ "author": "Maximilian Antoni <mail@maxantoni.de> (http://maxantoni.de)",

"dependencies": {
"through": "^2.3.4",
"convert-source-map": "~0.3.5",
"through2": "^0.6",
"convert-source-map": "^0.4",
"source-map": "~0.1.37"

@@ -24,4 +24,4 @@ },

"mocha": "^1.20",
"jslint": "^0.5",
"browserify": "^4.2"
"jslint": "^0.6",
"browserify": "^5.9"
},

@@ -31,3 +31,4 @@ "repository": {

"url": "https://github.com/mantoni/source-mapper.js.git"
}
},
"license": "MIT"
}
# Source Mapper
[![Build Status]](https://travis-ci.org/mantoni/source-mapper.js)
[![SemVer]](http://semver.org)
[![License]](https://github.com/mantoni/source-mapper.js/blob/master/LICENSE)
Replace URLs in stack traces with original sources based on [source-map][]. For

@@ -46,2 +50,7 @@ node and the browser.

## Compatibility
- Node 0.10 or later
- Browserify 5.9 or later
## License

@@ -51,3 +60,6 @@

[Build Status]: http://img.shields.io/travis/mantoni/source-mapper.js.svg
[SemVer]: http://img.shields.io/:semver-%E2%9C%93-brightgreen.svg
[License]: http://img.shields.io/npm/l/source-mapper.svg
[source-map]: https://github.com/mozilla/source-map
[through]: https://github.com/dominictarr/through

@@ -35,6 +35,6 @@ /*global describe, it, before, beforeEach*/

before(function (done) {
var b = browserify();
var b = browserify({ debug : true });
b.add('./test/fixture/thrower.js');
b.bundle({ debug : true }, function (err, script) {
js = script;
b.bundle(function (err, script) {
js = script.toString();
done(err);

@@ -67,3 +67,3 @@ });

s.on('end', function () {
var base = path.resolve('test', 'fixture', 'thrower.js');
var base = 'test/fixture/thrower.js';
var arr = d.split('\n');

@@ -84,28 +84,33 @@

it('maps about:blank line', function () {
var base = path.resolve('test', 'fixture', 'thrower.js');
var mapped = mapper.line(c, 'about:blank:5');
assert.equal(mapper.line(c, 'about:blank:5'), base + ':4');
assert.equal(mapped, 'test/fixture/thrower.js:4');
});
it('maps http:// line', function () {
var base = path.resolve('test', 'fixture', 'thrower.js');
var mapped = mapper.line(c, 'http://localhost/test:5');
assert.equal(mapper.line(c, 'http://localhost/test:5'), base + ':4');
assert.equal(mapped, 'test/fixture/thrower.js:4');
});
it('maps file:// line', function () {
var base = path.resolve('test', 'fixture', 'thrower.js');
var mapped = mapper.line(c, 'file://that/file/test:5');
assert.equal(mapper.line(c, 'file://that/file/test:5'), base + ':4');
assert.equal(mapped, 'test/fixture/thrower.js:4');
});
it('maps IE 10 stack line', function () {
var base = path.resolve('test', 'fixture', 'thrower.js');
var mapped = mapper.line(c,
'at Anonymous function (Unknown script code:5:1)');
assert.equal(
mapper.line(c, 'at Anonymous function (Unknown script code:5:1)'),
'at Anonymous function (' + base + ':4:1)'
);
assert.equal(mapped,
'at Anonymous function (test/fixture/thrower.js:4:1)');
});
it('maps anonymous line', function () {
var mapped = mapper.line(c, 'at Object.fail (<anonymous>:5:1)');
assert.equal(mapped, 'at Object.fail (test/fixture/thrower.js:4:1)');
});
it('does not map "abc http://"', function () {

@@ -112,0 +117,0 @@ var line = 'abc http://localhost:5';

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc