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

browserslist

Package Overview
Dependencies
Maintainers
1
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserslist - npm Package Compare versions

Comparing version 4.24.3 to 4.24.4

27

index.js

@@ -9,3 +9,3 @@ var jsReleases = require('node-releases/data/processed/envs.json')

var env = require('./node')
var parse = require('./parse') // Will load browser.js in webpack
var parseWithoutCache = require('./parse') // Will load browser.js in webpack

@@ -323,3 +323,3 @@ var YEAR = 365.259641 * 24 * 60 * 60 * 1000

function resolve(queries, context) {
return parse(QUERIES, queries).reduce(function (result, node, index) {
return parseQueries(queries).reduce(function (result, node, index) {
if (node.not && index === 0) {

@@ -400,2 +400,3 @@ throw new BrowserslistError(

var cache = {}
var parseCache = {}

@@ -407,2 +408,5 @@ function browserslist(queries, opts) {

var needsPath = parseQueries(queries).some(function (node) {
return QUERIES[node.type].needsPath
})
var context = {

@@ -412,5 +416,8 @@ ignoreUnknownVersions: opts.ignoreUnknownVersions,

mobileToDesktop: opts.mobileToDesktop,
path: opts.path,
env: opts.env
}
// Removing to avoid using context.path without marking query as needsPath
if (needsPath) {
context.path = opts.path
}

@@ -449,2 +456,12 @@ env.oldDataWarning(browserslist.data)

function parseQueries(queries) {
var cacheKey = JSON.stringify(queries)
if (cacheKey in parseCache) return parseCache[cacheKey]
var result = parseWithoutCache(QUERIES, queries)
if (!env.env.BROWSERSLIST_DISABLE_CACHE) {
parseCache[cacheKey] = result
}
return result
}
browserslist.parse = function (queries, opts) {

@@ -454,3 +471,3 @@ opts = prepareOpts(opts)

checkQueries(queries)
return parse(QUERIES, queries)
return parseQueries(queries)
}

@@ -1143,2 +1160,3 @@

regexp: /^browserslist config$/i,
needsPath: true,
select: function (context) {

@@ -1151,2 +1169,3 @@ return browserslist(undefined, context)

regexp: /^extends (.+)$/i,
needsPath: true,
select: function (context, node) {

@@ -1153,0 +1172,0 @@ return resolve(env.loadQueries(context, node.config), context)

129

node.js

@@ -16,4 +16,6 @@ var feature = require('caniuse-lite/dist/unpacker/feature').default

var dataTimeChecked = false
var filenessCache = {}
var configCache = {}
var statCache = {}
var configPathCache = {}
var parseConfigCache = {}
function checkExtend(name) {

@@ -39,21 +41,39 @@ var use = ' Use `dangerousExtend` option to disable.'

function isFile(file) {
if (file in filenessCache) {
return filenessCache[file]
}
var result = fs.existsSync(file) && fs.statSync(file).isFile()
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
filenessCache[file] = result
}
return result
return fs.existsSync(file) && fs.statSync(file).isFile()
}
function isDirectory(dir) {
return fs.existsSync(dir) && fs.statSync(dir).isDirectory()
}
function eachParent(file, callback) {
var dir = isFile(file) ? path.dirname(file) : file
var loc = path.resolve(dir)
function eachParent(file, callback, cache) {
var loc = path.resolve(file)
var pathsForCacheResult = []
var result
do {
if (!pathInRoot(loc)) break
var result = callback(loc)
if (typeof result !== 'undefined') return result
if (!pathInRoot(loc)) {
break
}
if (cache && (loc in cache)) {
result = cache[loc]
break
}
pathsForCacheResult.push(loc)
if (!isDirectory(loc)) {
continue
}
var locResult = callback(loc)
if (typeof locResult !== 'undefined') {
result = locResult
break
}
} while (loc !== (loc = path.dirname(loc)))
return undefined
if (cache && !process.env.BROWSERSLIST_DISABLE_CACHE) {
pathsForCacheResult.forEach(function (cachePath) {
cache[cachePath] = result
})
}
return result
}

@@ -108,14 +128,17 @@

function parsePackage(file) {
var config = JSON.parse(
fs
.readFileSync(file)
.toString()
.replace(/^\uFEFF/m, '')
)
if (config.browserlist && !config.browserslist) {
throw new BrowserslistError(
'`browserlist` key instead of `browserslist` in ' + file
)
var text = fs
.readFileSync(file)
.toString()
.replace(/^\uFEFF/m, '')
var list
if (text.indexOf('"browserslist"') >= 0) {
list = JSON.parse(text).browserslist
} else if (text.indexOf('"browserlist"') >= 0) {
var config = JSON.parse(text)
if (config.browserlist && !config.browserslist) {
throw new BrowserslistError(
'`browserlist` key instead of `browserslist` in ' + file
)
}
}
var list = config.browserslist
if (Array.isArray(list) || typeof list === 'string') {

@@ -132,7 +155,13 @@ list = { defaults: list }

function parsePackageOrReadConfig(file) {
if (path.basename(file) === 'package.json') {
return parsePackage(file)
} else {
return module.exports.readConfig(file)
if (file in parseConfigCache) {
return parseConfigCache[file]
}
var isPackage = path.basename(file) === 'package.json'
var result = isPackage ? parsePackage(file) : module.exports.readConfig(file)
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
parseConfigCache[file] = result
}
return result
}

@@ -244,3 +273,3 @@

return isFile(file) ? file : undefined
})
}, statCache)
}

@@ -348,2 +377,3 @@ if (typeof stats === 'string') {

}
return module.exports.parseConfig(fs.readFileSync(file))

@@ -353,3 +383,3 @@ },

findConfigFile: function findConfigFile(from) {
var resolved = eachParent(from, function (dir) {
return eachParent(from, function (dir) {
var config = path.join(dir, 'browserslist')

@@ -390,31 +420,9 @@ var pkg = path.join(dir, 'package.json')

}
})
return resolved
}, configPathCache)
},
findConfig: function findConfig(from) {
from = path.resolve(from)
var fromDir = isFile(from) ? path.dirname(from) : from
if (fromDir in configCache) {
return configCache[fromDir]
}
var resolved
var configFile = this.findConfigFile(from)
if (configFile) {
resolved = parsePackageOrReadConfig(configFile)
}
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
var configDir = configFile && path.dirname(configFile)
eachParent(from, function (dir) {
configCache[dir] = resolved
if (dir === configDir) {
return null
}
})
}
return resolved
return configFile ? parsePackageOrReadConfig(configFile) : undefined
},

@@ -424,4 +432,5 @@

dataTimeChecked = false
filenessCache = {}
configCache = {}
statCache = {}
configPathCache = {}
parseConfigCache = {}

@@ -428,0 +437,0 @@ this.cache = {}

{
"name": "browserslist",
"version": "4.24.3",
"version": "4.24.4",
"description": "Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",

@@ -5,0 +5,0 @@ "keywords": [

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