浏览代码

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 年前
committed by Guillaume Vincent
父节点
当前提交
fc7f09f56f
共有 1 个文件被更改,包括 3 次插入7 次删除
  1. +3
    -7
      cli.js

+ 3
- 7
cli.js 查看文件

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


正在加载...
取消
保存