mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 07:38:15 +00:00
Lodash upgrade and cleanup (#2990)
* Upgrades lodash * Replaces some usage of lodash with native functions. * Adds linting to catch cases where native functions could be used instead of lodash functions * Renamed testTools to testUtils Co-authored-by: Joshi <simplyrender@gmail.com> Co-authored-by: David Tsay <david.e.tsay@nasa.gov> Co-authored-by: David Tsay <3614296+davetsay@users.noreply.github.com> Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
@ -152,7 +152,7 @@ function (
|
||||
MCTChartController.prototype.destroy = function () {
|
||||
this.isDestroyed = true;
|
||||
this.stopListening();
|
||||
_.invoke(this.lines, 'destroy');
|
||||
this.lines.forEach(line => line.destroy());
|
||||
DrawLoader.releaseDrawAPI(this.drawAPI);
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ define([
|
||||
this.initialize(options);
|
||||
}
|
||||
|
||||
_.extend(Collection.prototype, EventEmitter.prototype);
|
||||
Object.assign(Collection.prototype, EventEmitter.prototype);
|
||||
eventHelpers.extend(Collection.prototype);
|
||||
|
||||
Collection.extend = extend;
|
||||
@ -105,12 +105,7 @@ define([
|
||||
};
|
||||
|
||||
Collection.prototype.indexOf = function (model) {
|
||||
return _.findIndex(
|
||||
this.models,
|
||||
function (m) {
|
||||
return m === model;
|
||||
}
|
||||
);
|
||||
return this.models.findIndex(m => m === model);
|
||||
};
|
||||
|
||||
Collection.prototype.remove = function (model) {
|
||||
|
@ -49,7 +49,7 @@ define([
|
||||
this.initialize(options);
|
||||
}
|
||||
|
||||
_.extend(Model.prototype, EventEmitter.prototype);
|
||||
Object.assign(Model.prototype, EventEmitter.prototype);
|
||||
eventHelpers.extend(Model.prototype);
|
||||
|
||||
Model.extend = extend;
|
||||
|
@ -146,7 +146,7 @@ define([
|
||||
strategy = 'minmax';
|
||||
}
|
||||
|
||||
options = _.extend({}, { size: 1000, strategy, filters: this.filters }, options || {});
|
||||
options = Object.assign({}, { size: 1000, strategy, filters: this.filters }, options || {});
|
||||
|
||||
if (!this.unsubscribe) {
|
||||
this.unsubscribe = this.openmct
|
||||
@ -160,6 +160,7 @@ define([
|
||||
);
|
||||
}
|
||||
|
||||
/* eslint-disable you-dont-need-lodash-underscore/concat */
|
||||
return this.openmct
|
||||
.telemetry
|
||||
.request(this.domainObject, options)
|
||||
@ -171,6 +172,7 @@ define([
|
||||
.value();
|
||||
this.reset(newPoints);
|
||||
}.bind(this));
|
||||
/* eslint-enable you-dont-need-lodash-underscore/concat */
|
||||
},
|
||||
/**
|
||||
* Update x formatter on x change.
|
||||
@ -270,7 +272,7 @@ define([
|
||||
* @private
|
||||
*/
|
||||
sortedIndex: function (point) {
|
||||
return _.sortedIndex(this.data, point, this.getXVal);
|
||||
return _.sortedIndexBy(this.data, point, this.getXVal);
|
||||
},
|
||||
/**
|
||||
* Update min/max stats for the series.
|
||||
|
@ -101,11 +101,11 @@ define([
|
||||
var plotObject = this.plot.get('domainObject');
|
||||
if (plotObject.type === 'telemetry.plot.overlay') {
|
||||
|
||||
var persistedIndex = _.findIndex(plotObject.configuration.series, function (s) {
|
||||
var persistedIndex = plotObject.configuration.series.findIndex(s => {
|
||||
return _.isEqual(identifier, s.identifier);
|
||||
});
|
||||
|
||||
var configIndex = _.findIndex(this.models, function (m) {
|
||||
var configIndex = this.models.findIndex(m => {
|
||||
return _.isEqual(m.domainObject.identifier, identifier);
|
||||
});
|
||||
|
||||
|
@ -51,7 +51,7 @@ define([
|
||||
}
|
||||
}
|
||||
|
||||
_.extend(Draw2D.prototype, EventEmitter.prototype);
|
||||
Object.assign(Draw2D.prototype, EventEmitter.prototype);
|
||||
eventHelpers.extend(Draw2D.prototype);
|
||||
|
||||
// Convert from logical to physical x coordinates
|
||||
|
@ -78,7 +78,7 @@ define([
|
||||
this.listenTo(this.canvas, "webglcontextlost", this.onContextLost, this);
|
||||
}
|
||||
|
||||
_.extend(DrawWebGL.prototype, EventEmitter.prototype);
|
||||
Object.assign(DrawWebGL.prototype, EventEmitter.prototype);
|
||||
eventHelpers.extend(DrawWebGL.prototype);
|
||||
|
||||
DrawWebGL.prototype.onContextLost = function (event) {
|
||||
|
@ -23,7 +23,7 @@
|
||||
define([
|
||||
'../configuration/configStore',
|
||||
'../lib/eventHelpers',
|
||||
'../../../../api/objects/object-utils',
|
||||
'objectUtils',
|
||||
'lodash'
|
||||
], function (
|
||||
configStore,
|
||||
|
@ -31,7 +31,7 @@ define([
|
||||
function dynamicPathForKey(key) {
|
||||
return function (object, model) {
|
||||
var modelIdentifier = model.get('identifier');
|
||||
var index = _.findIndex(object.configuration.series, function (s) {
|
||||
var index = object.configuration.series.findIndex(s => {
|
||||
return _.isEqual(s.identifier, modelIdentifier);
|
||||
});
|
||||
return 'configuration.series[' + index + '].' + key;
|
||||
|
@ -73,10 +73,10 @@ define([
|
||||
if (range.max === '' || range.max === null || typeof range.max === 'undefined') {
|
||||
return 'Must specify Maximum';
|
||||
}
|
||||
if (_.isNaN(Number(range.min))) {
|
||||
if (Number.isNaN(Number(range.min))) {
|
||||
return 'Minimum must be a number.';
|
||||
}
|
||||
if (_.isNaN(Number(range.max))) {
|
||||
if (Number.isNaN(Number(range.max))) {
|
||||
return 'Maximum must be a number.';
|
||||
}
|
||||
if (Number(range.min) > Number(range.max)) {
|
||||
|
@ -76,7 +76,7 @@ define([
|
||||
if (childObj) {
|
||||
var index = telemetryObjects.indexOf(childObj);
|
||||
telemetryObjects.splice(index, 1);
|
||||
$scope.$broadcast('plot:tickWidth', _.max(tickWidthMap));
|
||||
$scope.$broadcast('plot:tickWidth', Math.max(...Object.values(tickWidthMap)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user