less underscore

This commit is contained in:
antelle 2019-09-17 23:44:17 +02:00
parent 89ccb99395
commit 08d7261488
21 changed files with 142 additions and 188 deletions

View File

@ -468,12 +468,12 @@ AutoTypeRunner.prototype.emitNext = function(err) {
this.emitterState.stack.push({
ops: this.emitterState.ops,
opIx: this.emitterState.opIx + 1,
mod: _.clone(this.emitterState.mod)
mod: { ...this.emitterState.mod }
});
Object.assign(this.emitterState, {
ops: op.value,
opIx: 0,
mod: _.clone(this.emitterState.activeMod)
mod: { ...this.emitterState.activeMod }
});
this.emitNext();
return;

View File

@ -3,7 +3,7 @@ import { AppSettingsModel } from 'models/app-settings-model';
const ExportApi = {
settings: {
get(key) {
return key ? AppSettingsModel[key] : Object.assign({}, AppSettingsModel);
return key ? AppSettingsModel[key] : { ...AppSettingsModel };
},
set(key, value) {
AppSettingsModel[key] = value;

View File

@ -76,7 +76,7 @@ const GeneratorPresets = {
const setting = AppSettingsModel.generatorPresets;
if (setting) {
if (setting.user) {
presets = presets.concat(setting.user.map(_.clone));
presets = presets.concat(setting.user.map(item => ({ ...item })));
}
let hasDefault = false;
presets.forEach(preset => {

View File

@ -267,10 +267,11 @@ const Launcher = {
return;
}
const encryptConfig = Object.assign({}, this.config, {
const encryptConfig = {
...this.config,
username: fileId,
password: password.getText()
});
};
FingerprintAuth.encrypt(encryptConfig, result => {
callback(result.token);
@ -283,10 +284,7 @@ const Launcher = {
return callback();
}
const decryptConfig = Object.assign({}, this.config, {
username: fileId,
token
});
const decryptConfig = { ...this.config, username: fileId, token };
FingerprintAuth.decrypt(decryptConfig, result => {
callback(result.password);

View File

@ -81,7 +81,7 @@ const SettingsManager = {
}
}
if (!this.neutralLocale) {
this.neutralLocale = _.clone(Locale);
this.neutralLocale = { ...Locale };
}
Object.assign(Locale, this.neutralLocale, localeValues);
this.activeLocale = loc;

View File

@ -66,54 +66,42 @@ const Alerts = {
},
info(config) {
this.alert(
Object.assign(
{
header: '',
body: '',
icon: 'info',
buttons: [this.buttons.ok],
esc: '',
click: '',
enter: ''
},
config
)
);
this.alert({
header: '',
body: '',
icon: 'info',
buttons: [this.buttons.ok],
esc: '',
click: '',
enter: '',
...config
});
},
error(config) {
this.alert(
Object.assign(
{
header: '',
body: '',
icon: 'exclamation-circle',
buttons: [this.buttons.ok],
esc: '',
click: '',
enter: ''
},
config
)
);
this.alert({
header: '',
body: '',
icon: 'exclamation-circle',
buttons: [this.buttons.ok],
esc: '',
click: '',
enter: '',
...config
});
},
yesno(config) {
this.alert(
Object.assign(
{
header: '',
body: '',
icon: 'question',
buttons: [this.buttons.yes, this.buttons.no],
esc: '',
click: '',
enter: 'yes'
},
config
)
);
this.alert({
header: '',
body: '',
icon: 'question',
buttons: [this.buttons.yes, this.buttons.no],
esc: '',
click: '',
enter: 'yes',
...config
});
}
};

View File

@ -322,7 +322,7 @@ class AppModel {
}
prepareFilter(filter) {
filter = _.clone(filter);
filter = { ...filter };
filter.textLower = filter.text ? filter.text.toLowerCase() : '';
filter.tagLower = filter.tag ? filter.tag.toLowerCase() : '';
return filter;
@ -448,7 +448,7 @@ class AppModel {
(err, file) => {
if (!err && file) {
logger.info('Sync just opened modified file');
_.defer(() => this.syncFile(file));
setTimeout(() => this.syncFile(file), 0);
}
callback(err);
},
@ -492,7 +492,7 @@ class AppModel {
(err, file) => {
if (!err && file) {
logger.info('Sync just opened file');
_.defer(() => this.syncFile(file));
setTimeout(() => this.syncFile(file), 0);
callback(err);
} else {
logger.info(
@ -781,9 +781,9 @@ class AppModel {
if (storage && Storage[storage].getPathForName && (!path || storage !== file.storage)) {
path = Storage[storage].getPathForName(file.name);
}
const optionsForLogging = _.clone(options);
const optionsForLogging = { ...options };
if (optionsForLogging && optionsForLogging.opts && optionsForLogging.opts.password) {
optionsForLogging.opts = _.clone(optionsForLogging.opts);
optionsForLogging.opts = { ...optionsForLogging.opts };
optionsForLogging.opts.password = '***';
}
logger.info('Sync started', storage, path, optionsForLogging);

View File

@ -2,7 +2,7 @@ import { Model } from 'framework/model';
class FileInfoModel extends Model {
constructor(data) {
data = Object.assign({}, data);
data = { ...data };
for (const [key, val] of Object.entries(data)) {
if (/Date$/.test(key)) {
data[key] = val ? new Date(val) : null;

View File

@ -12,15 +12,11 @@ const logger = new Logger('file');
class FileModel extends Model {
constructor(data) {
super(
Object.assign(
{
entryMap: {},
groupMap: {}
},
data
)
);
super({
entryMap: {},
groupMap: {},
...data
});
}
open(password, fileData, keyFileData, callback) {
@ -137,14 +133,14 @@ class FileModel extends Model {
}
setOpenFile(props) {
Object.assign(props, {
this.set({
...props,
active: true,
oldKeyFileName: this.keyFileName,
oldPasswordLength: props.passwordLength,
passwordChanged: false,
keyFileChanged: false
});
this.set(props);
this.oldPasswordHash = this.db.credentials.passwordHash;
this.oldKeyFileHash = this.db.credentials.keyFileHash;
this.oldKeyChangeDate = this.db.meta.keyChanged;

View File

@ -20,12 +20,12 @@ class UpdateModel extends Model {
}
save() {
const attr = _.clone(this);
Object.keys(attr).forEach(key => {
const attr = { ...this };
for (const key of Object.keys(attr)) {
if (key.lastIndexOf('update', 0) === 0) {
delete attr[key];
}
});
}
SettingsStore.save('update-info', attr);
}
}

View File

@ -587,7 +587,7 @@ const Plugin = Backbone.Model.extend(
const settingsPrefix = this.getSettingPrefix();
if (settings instanceof Array) {
return settings.map(setting => {
setting = _.clone(setting);
setting = { ...setting };
const value = AppSettingsModel[settingsPrefix + setting.name];
if (value !== undefined) {
setting.value = value;

View File

@ -99,13 +99,11 @@ const StorageWebDav = StorageBase.extend({
};
const that = this;
this._request(
_.defaults(
{
op: 'Save:stat',
method: 'HEAD'
},
saveOpts
),
{
op: 'Save:stat',
method: 'HEAD',
...saveOpts
},
(err, xhr, stat) => {
let useTmpPath = this.appSettings.webdavSaveMethod !== 'put';
if (err) {
@ -121,40 +119,32 @@ const StorageWebDav = StorageBase.extend({
}
if (useTmpPath) {
that._request(
_.defaults(
{
op: 'Save:put',
method: 'PUT',
path: tmpPath,
data,
nostat: true
},
saveOpts
),
{
op: 'Save:put',
method: 'PUT',
path: tmpPath,
data,
nostat: true,
...saveOpts
},
err => {
if (err) {
return cb(err);
}
that._request(
_.defaults(
{
op: 'Save:stat',
method: 'HEAD'
},
saveOpts
),
{
op: 'Save:stat',
method: 'HEAD',
...saveOpts
},
(err, xhr, stat) => {
if (err) {
that._request(
_.defaults(
{
op: 'Save:delete',
method: 'DELETE',
path: tmpPath
},
saveOpts
)
);
that._request({
op: 'Save:delete',
method: 'DELETE',
path: tmpPath,
...saveOpts
});
return cb(err, xhr, stat);
}
if (stat.rev !== rev) {
@ -165,16 +155,12 @@ const StorageWebDav = StorageBase.extend({
stat.rev,
rev
);
that._request(
_.defaults(
{
op: 'Save:delete',
method: 'DELETE',
path: tmpPath
},
saveOpts
)
);
that._request({
op: 'Save:delete',
method: 'DELETE',
path: tmpPath,
...saveOpts
});
return cb({ revConflict: true }, xhr, stat);
}
let movePath = path;
@ -189,31 +175,27 @@ const StorageWebDav = StorageBase.extend({
}
}
that._request(
_.defaults(
{
op: 'Save:move',
method: 'MOVE',
path: tmpPath,
nostat: true,
headers: {
Destination: encodeURI(movePath),
'Overwrite': 'T'
}
{
op: 'Save:move',
method: 'MOVE',
path: tmpPath,
nostat: true,
headers: {
Destination: encodeURI(movePath),
'Overwrite': 'T'
},
saveOpts
),
...saveOpts
},
err => {
if (err) {
return cb(err);
}
that._request(
_.defaults(
{
op: 'Save:stat',
method: 'HEAD'
},
saveOpts
),
{
op: 'Save:stat',
method: 'HEAD',
...saveOpts
},
(err, xhr, stat) => {
cb(err, xhr, stat);
}
@ -226,27 +208,23 @@ const StorageWebDav = StorageBase.extend({
);
} else {
that._request(
_.defaults(
{
op: 'Save:put',
method: 'PUT',
data,
nostat: true
},
saveOpts
),
{
op: 'Save:put',
method: 'PUT',
data,
nostat: true,
...saveOpts
},
err => {
if (err) {
return cb(err);
}
that._request(
_.defaults(
{
op: 'Save:stat',
method: 'HEAD'
},
saveOpts
),
{
op: 'Save:stat',
method: 'HEAD',
...saveOpts
},
(err, xhr, stat) => {
cb(err, xhr, stat);
}

View File

@ -127,7 +127,7 @@ class DetailsView extends View {
super.render();
return;
}
const model = Object.assign({ deleted: this.appModel.filter.trash }, this.model);
const model = { deleted: this.appModel.filter.trash, ...this.model };
this.template = template;
super.render(model);
this.setSelectedColor(this.model.color);
@ -450,7 +450,7 @@ class DetailsView extends View {
default:
if (e.item.lastIndexOf('add:', 0) === 0) {
const fieldName = e.item.substr(4);
const fieldView = _.find(this.fieldViews, f => f.model.name === fieldName);
const fieldView = this.fieldViews.find(f => f.model.name === fieldName);
fieldView.show();
fieldView.edit();
}

View File

@ -6,12 +6,10 @@ import { FieldView } from 'views/fields/field-view';
import { FieldViewText } from 'views/fields/field-view-text';
class FieldViewCustom extends FieldViewText {
events = Object.assign(
{
'mousedown .details__field-label': 'fieldLabelMousedown'
},
FieldViewText.prototype.events
);
events = {
'mousedown .details__field-label': 'fieldLabelMousedown',
...FieldViewText.prototype.events
};
startEdit() {
super.startEdit();
@ -36,7 +34,7 @@ class FieldViewCustom extends FieldViewText {
endEdit(newVal, extra) {
this.$el.removeClass('details__field--can-edit-title');
extra = Object.assign({}, extra);
extra = { ...extra };
if (this.model.titleChanged || this.model.newField) {
extra.newField = this.model.title;
}

View File

@ -34,7 +34,7 @@ class FieldViewDate extends FieldViewText {
}
});
this.picker.adjustPosition = this.adjustPickerPosition.bind(this);
_.defer(this.picker.show.bind(this.picker));
setTimeout(() => this.picker.show(), 0);
}
adjustPickerPosition(...args) {

View File

@ -17,7 +17,7 @@ class FieldViewTags extends FieldViewText {
return _.unique(
val
.split(/\s*[;,:]\s*/)
.filter(_.identity)
.filter(tag => tag)
.map(tag => {
return allTags[tag.toLowerCase()] || tag;
})

View File

@ -61,7 +61,7 @@ class GeneratorView extends View {
super(model);
this.createPresets();
const preset = this.preset;
this.gen = _.clone(_.find(this.presets, pr => pr.name === preset));
this.gen = { ...this.presets.find(pr => pr.name === preset) };
this.hide = AppSettingsModel.generatorHidePassword;
$('body').one('click', this.remove.bind(this));
this.listenTo(Events, 'lock-workspace', this.remove.bind(this));
@ -189,8 +189,8 @@ class GeneratorView extends View {
return;
}
this.preset = name;
const preset = _.find(this.presets, t => t.name === name);
this.gen = _.clone(preset);
const preset = this.presets.find(t => t.name === name);
this.gen = { ...preset };
this.render();
}

View File

@ -115,7 +115,7 @@ class ListSearchView extends View {
title: true
};
if (this.model.advancedSearch) {
this.advancedSearch = Object.assign({}, this.model.advancedSearch);
this.advancedSearch = { ...this.model.advancedSearch };
}
this.setLocale();
this.onKey(Keys.DOM_VK_F, this.findKeyPress, KeyHandler.SHORTCUT_ACTION);

View File

@ -303,7 +303,7 @@ class ListView extends View {
}
optionsDropdownSelect(e) {
const col = _.find(this.tableColumns, c => c.val === e.item);
const col = this.tableColumns.find(c => c.val === e.item);
col.enabled = !col.enabled;
e.el.find('i:first').toggleClass('fa-check-square-o fa-square-o');
this.render();

View File

@ -801,15 +801,13 @@ class OpenView extends View {
if (this.views.openConfig) {
this.views.openConfig.remove();
}
const config = Object.assign(
{
id: storage.name,
name: Locale[storage.name] || storage.name,
icon: storage.icon,
buttons: true
},
storage.getOpenConfig()
);
const config = {
id: storage.name,
name: Locale[storage.name] || storage.name,
icon: storage.icon,
buttons: true,
...storage.getOpenConfig()
};
this.views.openConfig = new OpenConfigView(config, {
parent: '.open__config-wrap'
});

View File

@ -125,7 +125,7 @@ class SettingsFileView extends View {
kdfParametersToUi(kdfParameters) {
return kdfParameters
? Object.assign({}, kdfParameters, { memory: Math.round(kdfParameters.memory / 1024) })
? { ...kdfParameters, memory: Math.round(kdfParameters.memory / 1024) }
: null;
}
@ -282,15 +282,13 @@ class SettingsFileView extends View {
} else {
if (!storage.list) {
if (storage.getOpenConfig) {
const config = Object.assign(
{
id: storage.name,
name: Locale[storage.name] || storage.name,
icon: storage.icon,
buttons: false
},
storage.getOpenConfig()
);
const config = {
id: storage.name,
name: Locale[storage.name] || storage.name,
icon: storage.icon,
buttons: false,
...storage.getOpenConfig()
};
const openConfigView = new OpenConfigView(config);
Alerts.alert({
header: '',