Przeglądaj źródła

Array.prototype.some instead of mutable var in forEach (#6)

This is the correct higher-order function for this task that doesn't make mutable state and also `some` will short-circuit once a true is found unlike the `forEach`.
pull/342/head
toastal 7 lat temu
committed by Guillaume Vincent
rodzic
commit
fc7f09f56f
1 zmienionych plików z 3 dodań i 7 usunięć
  1. +3
    -7
      cli.js

+ 3
- 7
cli.js Wyświetl plik

@@ -69,13 +69,9 @@ function calcPassword(site, login, masterPassword, passwordProfile) {


function hasNoShortOption(options) {
let hasShortOption = false;
['l', 'u', 'd', 's'].forEach(function(shortOption) {
if (typeof options[shortOption] !== 'undefined' && options[shortOption]) {
hasShortOption = true;
}
});
return !hasShortOption;
return !(['l', 'u', 'd', 's'].some(function(shortOption) {
return typeof options[shortOption] !== 'undefined' && options[shortOption];
}));
}

function getOptionBoolean(options, optionString) {


Ładowanie…
Anuluj
Zapisz