Huge News!Announcing our $40M Series B led by Abstract Ventures.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.16 to 1.0.17

15

get-source.js

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

path = require ('./impl/path'),
memoize = require ('lodash.memoize'),
dataURIToBuffer = require ('data-uri-to-buffer'),

@@ -16,2 +15,13 @@ lastOf = x => x[x.length - 1]

const memoize = f => {
const m = (x = '') => (x in m.cache) ? m.cache[x] : (m.cache[x] = f(x))
m.forgetEverything = () => { m.cache = Object.create (null) }
m.cache = Object.create (null)
return m
}
/* ------------------------------------------------------------------------ */
const newSourceFileMemoized = memoize (file => new SourceFile (file))

@@ -21,2 +31,5 @@

getSource.resetCache = () => newSourceFileMemoized.forgetEverything ()
getSource.getCache = () => newSourceFileMemoized.cache
/* ------------------------------------------------------------------------ */

@@ -23,0 +36,0 @@

3

package.json
{
"name": "get-source",
"version": "1.0.16",
"version": "1.0.17",
"description": "Platform-agnostic source code inspection, with sourcemaps support",

@@ -36,5 +36,4 @@ "main": "get-source",

"data-uri-to-buffer": "^1.0.0",
"lodash.memoize": "^4.1.2",
"source-map": "^0.5.6"
}
}

@@ -58,3 +58,4 @@ "use strict";

const getSource = require ('./get-source'),
fs = require ('fs')
fs = require ('fs'),
path = require ('path')

@@ -71,3 +72,3 @@ it ('caches read files', () => {

original.path.should.equal ('/Users/mac/get-source/test_files/original.js') // resolves input paths
original.path.should.equal (path.resolve ('./test_files/original.js')) // resolves input paths
original.text.should.equal (fs.readFileSync ('./test_files/original.js', { encoding: 'utf-8' }))

@@ -93,3 +94,3 @@ original.lines.should.deep.equal ([

uglified.path.should.equal ('/Users/mac/get-source/test_files/original.uglified.js')
uglified.path.should.equal (path.resolve ('./test_files/original.uglified.js'))
uglified.lines.should.deep.equal ([

@@ -116,3 +117,3 @@ 'function hello(){return"hello world"}',

uglified.path.should.equal ('/Users/mac/get-source/test_files/original.uglified.with.sources.js')
uglified.path.should.equal (path.resolve ('./test_files/original.uglified.with.sources.js'))
uglified.lines.should.deep.equal ([

@@ -130,3 +131,3 @@ 'function hello(){return"hello world"}',

resolved.column.should.equal (1)
resolved.sourceFile.path.should.equal ('/Users/mac/get-source/test_files/## embedded ##') // I've changed the filename manually, by editing .map file
resolved.sourceFile.path.should.equal (path.resolve ('./test_files') + '/## embedded ##') // I've changed the filename manually, by editing .map file
resolved.sourceLine.should.equal ('\treturn \'hello world\' }')

@@ -155,3 +156,3 @@ })

beautified.path.should.equal ('/Users/mac/get-source/test_files/original.uglified.beautified.js')
beautified.path.should.equal (path.resolve ('./test_files/original.uglified.beautified.js'))
beautified.text.should.equal (fs.readFileSync ('./test_files/original.uglified.beautified.js', { encoding: 'utf-8' }))

@@ -165,3 +166,3 @@

resolved.column.should.equal (1)
resolved.sourceFile.path.should.equal ('/Users/mac/get-source/test_files/original.js')
resolved.sourceFile.path.should.equal (path.resolve ('./test_files/original.js'))
resolved.sourceLine.should.equal ('\treturn \'hello world\' }')

@@ -187,2 +188,24 @@ })

})
it ('caching works', () => {
const files =
[ './test.js',
'./package.json',
'./test_files/original.js',
'./test_files/original.uglified.js',
'./test_files/original.uglified.js.map',
'./test_files/original.uglified.with.sources.js',
'./test_files/original.uglified.with.sources.js.map',
'./test_files/original.babeled.with.inline.sourcemap.js',
'./test_files/original.uglified.beautified.js',
'./test_files/original.uglified.beautified.js.map',
'./abyrvalg' ]
Object.keys (getSource.getCache ()).should.deep.equal (files.map (x => path.resolve (x)))
getSource.resetCache ()
Object.keys (getSource.getCache ()).length.should.equal (0)
})
})

@@ -189,0 +212,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