refactor: use Set instead of Array when appropriate (#39324)
This commit is contained in:
parent
c5e50e4882
commit
fe93f69e5a
3 changed files with 7 additions and 7 deletions
|
@ -146,14 +146,14 @@ require('@electron/internal/browser/api/web-frame-main');
|
||||||
// Set main startup script of the app.
|
// Set main startup script of the app.
|
||||||
const mainStartupScript = packageJson.main || 'index.js';
|
const mainStartupScript = packageJson.main || 'index.js';
|
||||||
|
|
||||||
const KNOWN_XDG_DESKTOP_VALUES = ['Pantheon', 'Unity:Unity7', 'pop:GNOME'];
|
const KNOWN_XDG_DESKTOP_VALUES = new Set(['Pantheon', 'Unity:Unity7', 'pop:GNOME']);
|
||||||
|
|
||||||
function currentPlatformSupportsAppIndicator () {
|
function currentPlatformSupportsAppIndicator () {
|
||||||
if (process.platform !== 'linux') return false;
|
if (process.platform !== 'linux') return false;
|
||||||
const currentDesktop = process.env.XDG_CURRENT_DESKTOP;
|
const currentDesktop = process.env.XDG_CURRENT_DESKTOP;
|
||||||
|
|
||||||
if (!currentDesktop) return false;
|
if (!currentDesktop) return false;
|
||||||
if (KNOWN_XDG_DESKTOP_VALUES.includes(currentDesktop)) return true;
|
if (KNOWN_XDG_DESKTOP_VALUES.has(currentDesktop)) return true;
|
||||||
// ubuntu based or derived session (default ubuntu one, communitheme…) supports
|
// ubuntu based or derived session (default ubuntu one, communitheme…) supports
|
||||||
// indicator too.
|
// indicator too.
|
||||||
if (/ubuntu/ig.test(currentDesktop)) return true;
|
if (/ubuntu/ig.test(currentDesktop)) return true;
|
||||||
|
|
|
@ -26,7 +26,7 @@ const keysOfTypeNumberCompileTimeCheck: { [K in IntegerBrowserWindowOptionKeys]
|
||||||
};
|
};
|
||||||
// Note `top` / `left` are special cases from the browser which we later convert
|
// Note `top` / `left` are special cases from the browser which we later convert
|
||||||
// to y / x.
|
// to y / x.
|
||||||
const keysOfTypeNumber = ['top', 'left', ...Object.keys(keysOfTypeNumberCompileTimeCheck)];
|
const keysOfTypeNumber = new Set(['top', 'left', ...Object.keys(keysOfTypeNumberCompileTimeCheck)]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note that we only allow "0" and "1" boolean conversion when the type is known
|
* Note that we only allow "0" and "1" boolean conversion when the type is known
|
||||||
|
@ -37,7 +37,7 @@ const keysOfTypeNumber = ['top', 'left', ...Object.keys(keysOfTypeNumberCompileT
|
||||||
*/
|
*/
|
||||||
type CoercedValue = string | number | boolean;
|
type CoercedValue = string | number | boolean;
|
||||||
function coerce (key: string, value: string): CoercedValue {
|
function coerce (key: string, value: string): CoercedValue {
|
||||||
if (keysOfTypeNumber.includes(key)) {
|
if (keysOfTypeNumber.has(key)) {
|
||||||
return parseInt(value, 10);
|
return parseInt(value, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,12 +108,12 @@ async function main () {
|
||||||
|
|
||||||
const onlyTests = args.only && args.only.split(',');
|
const onlyTests = args.only && args.only.split(',');
|
||||||
|
|
||||||
const DISABLED_TESTS = [
|
const DISABLED_TESTS = new Set([
|
||||||
'nannew-test.js',
|
'nannew-test.js',
|
||||||
'buffer-test.js'
|
'buffer-test.js'
|
||||||
];
|
]);
|
||||||
const testsToRun = fs.readdirSync(path.resolve(NAN_DIR, 'test', 'js'))
|
const testsToRun = fs.readdirSync(path.resolve(NAN_DIR, 'test', 'js'))
|
||||||
.filter(test => !DISABLED_TESTS.includes(test))
|
.filter(test => !DISABLED_TESTS.has(test))
|
||||||
.filter(test => {
|
.filter(test => {
|
||||||
return !onlyTests || onlyTests.includes(test) || onlyTests.includes(test.replace('.js', '')) || onlyTests.includes(test.replace('-test.js', ''));
|
return !onlyTests || onlyTests.includes(test) || onlyTests.includes(test.replace('.js', '')) || onlyTests.includes(test.replace('-test.js', ''));
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue