New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

get-source

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-source - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

test_files/original.babeled.with.inline.sourcemap.js

21

get-source.js

@@ -10,2 +10,3 @@ "use strict";

memoize = require ('lodash.memoize'),
dataURIToBuffer = require ('data-uri-to-buffer'),
lastOf = x => x[x.length - 1]

@@ -58,2 +59,5 @@

else if (path.startsWith ('data:')) {
this.text = dataURIToBuffer (path).toString () }
else {

@@ -85,11 +89,17 @@ try {

try {
if (this.sourceMap_ === undefined) {
let url = this.text.match (/\u0023 sourceMappingURL=(.+\.map)/) // escape #, otherwise it will match this exact line.. %)
if (url = (url && url[1])) {
const [,url] = this.text.match (/\# sourceMappingURL=(.+)\n?/) || [undefined, undefined]
if (url) {
const sourceMap = new SourceMap (this.path, url)
if (sourceMap.parsed) {
this.sourceMap_ = sourceMap
}
}
else {
} else {
this.sourceMap_ = null

@@ -101,4 +111,5 @@ }

catch (e) {
this.sourceMap_ = null
this.sourceMapError = e
this.sourceMap_ = null }
}

@@ -105,0 +116,0 @@ return this.sourceMap_

{
"name": "get-source",
"version": "1.0.10",
"version": "1.0.11",
"description": "Platform-agnostic source code inspection, with sourcemaps support",

@@ -40,2 +40,3 @@ "main": "get-source",

"dependencies": {
"data-uri-to-buffer": "^1.0.0",
"lodash.memoize": "^4.1.2",

@@ -42,0 +43,0 @@ "source-map": "^0.5.6"

@@ -12,3 +12,3 @@ # get-source

- [x] Allows to read source code files in Node and browsers
- [x] Full sourcemap support (path resolving, external/embedded linking and long chains)
- [x] Full sourcemap support (path resolving, external/embedded/inline linking, and long chains)
- [x] **Synchronous** API — which is good when you implement a debugging tool (e.g. [logging](https://github.com/xpl/ololog))

@@ -15,0 +15,0 @@ - [x] Built-in cache

@@ -42,2 +42,9 @@ "use strict";

})
it ('works with data URIs', () => {
path.relativeToFile ('/foo/bar.js', 'data:application/json;charset=utf-8;base64,eyJ2ZXJza==')
.should.equal ( 'data:application/json;charset=utf-8;base64,eyJ2ZXJza==')
})
})

@@ -122,3 +129,15 @@

it ('reads sources (sourcemapped, with inline base64 sourcemaps)', () => {
const babeled = getSource ('./test_files/original.babeled.with.inline.sourcemap.js')
babeled.sourceMap.should.not.equal (undefined)
const resolved = babeled.resolve ({ line: 6, column: 1 })
resolved.line.should.equal (4)
resolved.column.should.equal (1)
resolved.sourceLine.should.equal ('\treturn \'hello world\' }')
})
it ('supports even CHAINED sourcemaps!', () => {

@@ -125,0 +144,0 @@

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