Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Sep 26, 2023
1 parent 6cd0a87 commit f50b60f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ function filterJumps(list, name, nVersions, context) {
return list.slice(jump - 1 - nVersions)
}

function isSupported(flags, includePartialSupport) {
function isSupported(flags, withPartial) {
return (
typeof flags === 'string' &&
(flags.indexOf('y') >= 0 || (includePartialSupport && flags.indexOf('a') >= 0))
(flags.indexOf('y') >= 0 || (withPartial && flags.indexOf('a') >= 0))
)
}

Expand Down Expand Up @@ -887,7 +887,7 @@ var QUERIES = {
regexp: /^(?:(fully|partially) )?supports\s+([\w-]+)$/,
select: function (context, node) {
env.loadFeature(browserslist.cache, node.feature)
var includePartialSupport = (node.supportType || 'partially') === 'partially';
var withPartial = node.supportType !== 'fully'
var features = browserslist.cache[node.feature]
var result = []
for (var name in features) {
Expand All @@ -896,13 +896,13 @@ var QUERIES = {
var checkDesktop =
context.mobileToDesktop &&
name in browserslist.desktopNames &&
isSupported(features[name][data.released.slice(-1)[0]], includePartialSupport)
isSupported(features[name][data.released.slice(-1)[0]], withPartial)
data.versions.forEach(function (version) {
var flags = features[name][version]
if (flags === undefined && checkDesktop) {
flags = features[browserslist.desktopNames[name]][version]
}
if (isSupported(flags, includePartialSupport)) {
if (isSupported(flags, withPartial)) {
result.push(name + ' ' + version)
}
})
Expand Down
9 changes: 4 additions & 5 deletions test/feature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test('throw an error on wrong feature name from Can I Use', () => {
)
})

test('selects browsers by feature, including partial support by default', () => {
test('selects browsers by feature', () => {
browserslist.cache.rtcpeerconnection = {
and_chr: { 81: 'y' },
chrome: { 80: 'n', 81: 'a', 82: 'y' },
Expand All @@ -60,7 +60,7 @@ test('selects browsers by feature, including partial support by default', () =>
])
})

test('selects browsers by feature, including partial support in partial mode', () => {
test('selects browsers by feature, including partial support', () => {
browserslist.cache.rtcpeerconnection = {
and_chr: { 81: 'y' },
chrome: { 80: 'n', 81: 'a', 82: 'y' },
Expand All @@ -74,7 +74,7 @@ test('selects browsers by feature, including partial support in partial mode', (
])
})

test('selects browsers by feature, omiting partial support in full mode', () => {
test('selects browsers by feature, omiting partial support', () => {
browserslist.cache.rtcpeerconnection = {
and_chr: { 81: 'y' },
chrome: { 80: 'n', 81: 'a', 82: 'y' },
Expand All @@ -83,11 +83,10 @@ test('selects browsers by feature, omiting partial support in full mode', () =>

equal(browserslist('fully supports rtcpeerconnection'), [
'and_chr 81',
'chrome 82',
'chrome 82'
])
})


test('selects browsers by feature with dashes in its name', () => {
browserslist.cache['arrow-functions'] = {
and_chr: { 81: 'n' },
Expand Down

0 comments on commit f50b60f

Please sign in to comment.