Explorar el Código

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 hace 7 años
committed by Guillaume Vincent
padre
commit
fc7f09f56f
Se han modificado 1 ficheros con 3 adiciones y 7 borrados
  1. +3
    -7
      cli.js

+ 3
- 7
cli.js Ver fichero

@@ -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) {


Cargando…
Cancelar
Guardar