mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
Lodash upgrade (#2885)
* upgraded lodash, changed method names * native implementations as requested
This commit is contained in:
parent
04a60cfcbb
commit
d103a22fa0
14
.eslintrc.js
14
.eslintrc.js
@ -8,9 +8,11 @@ module.exports = {
|
|||||||
"globals": {
|
"globals": {
|
||||||
"_": "readonly"
|
"_": "readonly"
|
||||||
},
|
},
|
||||||
|
"plugins": ["lodash"],
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:vue/recommended"
|
"plugin:vue/recommended",
|
||||||
|
"plugin:lodash/recommended"
|
||||||
],
|
],
|
||||||
"parser": "vue-eslint-parser",
|
"parser": "vue-eslint-parser",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
@ -22,6 +24,16 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"lodash/prefer-lodash-method": "off",
|
||||||
|
"lodash/prefer-lodash-typecheck": "off",
|
||||||
|
"lodash/prefer-constant": "off",
|
||||||
|
"lodash/prefer-noop": "off",
|
||||||
|
"lodash/prefer-matches": "off",
|
||||||
|
"lodash/prefer-includes": "off",
|
||||||
|
"lodash/prefer-startswith": "off",
|
||||||
|
"lodash/prefer-get": "off",
|
||||||
|
"lodash/prefer-is-nil": "off",
|
||||||
|
"lodash/import-scope": "off",
|
||||||
"no-bitwise": "error",
|
"no-bitwise": "error",
|
||||||
"curly": "error",
|
"curly": "error",
|
||||||
"eqeqeq": "error",
|
"eqeqeq": "error",
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
"d3-time": "1.0.x",
|
"d3-time": "1.0.x",
|
||||||
"d3-time-format": "2.1.x",
|
"d3-time-format": "2.1.x",
|
||||||
"eslint": "5.2.0",
|
"eslint": "5.2.0",
|
||||||
|
"eslint-plugin-lodash": "^6.0.0",
|
||||||
"eslint-plugin-vue": "^6.0.0",
|
"eslint-plugin-vue": "^6.0.0",
|
||||||
"eventemitter3": "^1.2.0",
|
"eventemitter3": "^1.2.0",
|
||||||
"exports-loader": "^0.7.0",
|
"exports-loader": "^0.7.0",
|
||||||
@ -47,7 +48,7 @@
|
|||||||
"karma-sourcemap-loader": "^0.3.7",
|
"karma-sourcemap-loader": "^0.3.7",
|
||||||
"karma-webpack": "^3.0.0",
|
"karma-webpack": "^3.0.0",
|
||||||
"location-bar": "^3.0.1",
|
"location-bar": "^3.0.1",
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^4.17.12",
|
||||||
"markdown-toc": "^0.11.7",
|
"markdown-toc": "^0.11.7",
|
||||||
"marked": "^0.3.5",
|
"marked": "^0.3.5",
|
||||||
"mini-css-extract-plugin": "^0.4.1",
|
"mini-css-extract-plugin": "^0.4.1",
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
'../../../src/api/objects/object-utils',
|
'../../../src/api/objects/object-utils'
|
||||||
'lodash'
|
|
||||||
],
|
],
|
||||||
function (
|
function (
|
||||||
objectUtils,
|
objectUtils,
|
||||||
@ -235,7 +234,8 @@ define(
|
|||||||
var defaultRange = metadata.valuesForHints(['range'])[0];
|
var defaultRange = metadata.valuesForHints(['range'])[0];
|
||||||
defaultRange = defaultRange ? defaultRange.key : undefined;
|
defaultRange = defaultRange ? defaultRange.key : undefined;
|
||||||
|
|
||||||
var sourceMap = _.indexBy(metadata.values(), 'key');
|
const keyBy = (array, k) => (array || []).reduce((r, x) => ({ ...r, [k ? x[k] : x]: x }), {});
|
||||||
|
var sourceMap = keyBy(metadata.values(), 'key');
|
||||||
|
|
||||||
var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject) ===
|
var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject) ===
|
||||||
telemetryAPI.legacyProvider;
|
telemetryAPI.legacyProvider;
|
||||||
@ -300,7 +300,8 @@ define(
|
|||||||
var defaultRange = metadata.valuesForHints(['range'])[0];
|
var defaultRange = metadata.valuesForHints(['range'])[0];
|
||||||
defaultRange = defaultRange ? defaultRange.key : undefined;
|
defaultRange = defaultRange ? defaultRange.key : undefined;
|
||||||
|
|
||||||
var sourceMap = _.indexBy(metadata.values(), 'key');
|
const keyBy = (array, k) => (array || []).reduce((r, x) => ({ ...r, [k ? x[k] : x]: x }), {});
|
||||||
|
var sourceMap = keyBy(metadata.values(), 'key');
|
||||||
|
|
||||||
var isLegacyProvider = telemetryAPI.findSubscriptionProvider(domainObject) ===
|
var isLegacyProvider = telemetryAPI.findSubscriptionProvider(domainObject) ===
|
||||||
telemetryAPI.legacyProvider;
|
telemetryAPI.legacyProvider;
|
||||||
|
@ -196,8 +196,8 @@ define([
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
DefaultCompositionProvider.prototype.includes = function (parent, childId) {
|
DefaultCompositionProvider.prototype.includes = function (parent, childId) {
|
||||||
return parent.composition.findIndex(composee =>
|
return parent.composition.some(composee =>
|
||||||
this.publicAPI.objects.areIdsEqual(composee, childId)) !== -1;
|
this.publicAPI.objects.areIdsEqual(composee, childId));
|
||||||
};
|
};
|
||||||
|
|
||||||
DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) {
|
DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) {
|
||||||
|
@ -85,9 +85,9 @@ define([
|
|||||||
value: +e.value
|
value: +e.value
|
||||||
};
|
};
|
||||||
}), 'e.value');
|
}), 'e.value');
|
||||||
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
|
valueMetadata.values = Object.entries(valueMetadata.enumerations).reduce((a, [key, {value}]) => {a [key] = value; return a}, []);
|
||||||
valueMetadata.max = _.max(valueMetadata.values);
|
valueMetadata.max = Math.max(...valueMetadata.values);
|
||||||
valueMetadata.min = _.min(valueMetadata.values);
|
valueMetadata.min = Math.min(...valueMetadata.values);
|
||||||
}
|
}
|
||||||
|
|
||||||
valueMetadatas.push(valueMetadata);
|
valueMetadatas.push(valueMetadata);
|
||||||
|
@ -370,7 +370,7 @@ define([
|
|||||||
TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) {
|
TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) {
|
||||||
var options = metadatas.map(function (metadata) {
|
var options = metadatas.map(function (metadata) {
|
||||||
var values = metadata.valuesForHints(hints);
|
var values = metadata.valuesForHints(hints);
|
||||||
return _.indexBy(values, 'key');
|
return _.keyBy(values, 'key');
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
var results = {};
|
var results = {};
|
||||||
Object.keys(a).forEach(function (key) {
|
Object.keys(a).forEach(function (key) {
|
||||||
@ -383,7 +383,7 @@ define([
|
|||||||
var sortKeys = hints.map(function (h) {
|
var sortKeys = hints.map(function (h) {
|
||||||
return 'hints.' + h;
|
return 'hints.' + h;
|
||||||
});
|
});
|
||||||
return _.sortByAll(options, sortKeys);
|
return _.sortBy(options, sortKeys);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,13 +57,13 @@ define([
|
|||||||
|
|
||||||
if (valueMetadata.format === 'enum') {
|
if (valueMetadata.format === 'enum') {
|
||||||
if (!valueMetadata.values) {
|
if (!valueMetadata.values) {
|
||||||
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
|
valueMetadata.values = Object.entries(valueMetadata.enumerations).reduce((a, [key, {value}]) => {a [key] = value; return a}, []);
|
||||||
}
|
}
|
||||||
if (!valueMetadata.hasOwnProperty('max')) {
|
if (!valueMetadata.hasOwnProperty('max')) {
|
||||||
valueMetadata.max = _.max(valueMetadata.values) + 1;
|
valueMetadata.max = Math.max(...valueMetadata.values) + 1;
|
||||||
}
|
}
|
||||||
if (!valueMetadata.hasOwnProperty('min')) {
|
if (!valueMetadata.hasOwnProperty('min')) {
|
||||||
valueMetadata.min = _.min(valueMetadata.values) - 1;
|
valueMetadata.min = Math.min(...valueMetadata.values) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ define([
|
|||||||
return metadata.hints[hint];
|
return metadata.hints[hint];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return _.sortByAll(matchingMetadata, ...iteratees);
|
return _.sortBy(matchingMetadata, ...iteratees);
|
||||||
};
|
};
|
||||||
|
|
||||||
TelemetryMetadataManager.prototype.getFilterableValues = function () {
|
TelemetryMetadataManager.prototype.getFilterableValues = function () {
|
||||||
|
@ -220,7 +220,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = _.sortedIndex(this.imageHistory, datum, this.timeFormat.format.bind(this.timeFormat));
|
const index = _.sortedIndexBy(this.imageHistory, datum, this.timeFormat.format.bind(this.timeFormat));
|
||||||
this.imageHistory.splice(index, 0, datum);
|
this.imageHistory.splice(index, 0, datum);
|
||||||
},
|
},
|
||||||
updateValues(datum) {
|
updateValues(datum) {
|
||||||
|
@ -152,7 +152,7 @@ function (
|
|||||||
MCTChartController.prototype.destroy = function () {
|
MCTChartController.prototype.destroy = function () {
|
||||||
this.isDestroyed = true;
|
this.isDestroyed = true;
|
||||||
this.stopListening();
|
this.stopListening();
|
||||||
_.invoke(this.lines, 'destroy');
|
this.lines.map(line => line.destroy());
|
||||||
DrawLoader.releaseDrawAPI(this.drawAPI);
|
DrawLoader.releaseDrawAPI(this.drawAPI);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ define([
|
|||||||
if (childObj) {
|
if (childObj) {
|
||||||
var index = telemetryObjects.indexOf(childObj);
|
var index = telemetryObjects.indexOf(childObj);
|
||||||
telemetryObjects.splice(index, 1);
|
telemetryObjects.splice(index, 1);
|
||||||
$scope.$broadcast('plot:tickWidth', _.max(tickWidthMap));
|
$scope.$broadcast('plot:tickWidth', Math.max(...Object.values(tickWidthMap)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +131,7 @@ define([
|
|||||||
}
|
}
|
||||||
tickWidthMap[plotId] = Math.max(width, tickWidthMap[plotId]);
|
tickWidthMap[plotId] = Math.max(width, tickWidthMap[plotId]);
|
||||||
var newTickWidth = _.max(tickWidthMap);
|
var newTickWidth = _.max(tickWidthMap);
|
||||||
|
|
||||||
if (newTickWidth !== tickWidth || width !== tickWidth) {
|
if (newTickWidth !== tickWidth || width !== tickWidth) {
|
||||||
tickWidth = newTickWidth;
|
tickWidth = newTickWidth;
|
||||||
$scope.$broadcast('plot:tickWidth', tickWidth);
|
$scope.$broadcast('plot:tickWidth', tickWidth);
|
||||||
|
@ -154,7 +154,7 @@ define([
|
|||||||
return _(this.baseState)
|
return _(this.baseState)
|
||||||
.values()
|
.values()
|
||||||
.map(_.clone)
|
.map(_.clone)
|
||||||
.indexBy('id')
|
.keyBy('id')
|
||||||
.value();
|
.value();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
@ -100,7 +100,7 @@ define([
|
|||||||
|
|
||||||
hasColumnWithKey(columnKey) {
|
hasColumnWithKey(columnKey) {
|
||||||
return _.flatten(Object.values(this.columns))
|
return _.flatten(Object.values(this.columns))
|
||||||
.findIndex(column => column.getKey() === columnKey) !== -1;
|
.some(column => column.getKey() === columnKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
getColumns() {
|
getColumns() {
|
||||||
|
@ -93,7 +93,7 @@ define(
|
|||||||
// same time stamp
|
// same time stamp
|
||||||
let potentialDupes = this.rows.slice(startIx, endIx + 1);
|
let potentialDupes = this.rows.slice(startIx, endIx + 1);
|
||||||
// Search potential dupes for exact dupe
|
// Search potential dupes for exact dupe
|
||||||
isDuplicate = _.findIndex(potentialDupes, _.isEqual.bind(undefined, row)) > -1;
|
isDuplicate = potentialDupes.some(_.isEqual.bind(undefined, row));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDuplicate) {
|
if (!isDuplicate) {
|
||||||
@ -201,7 +201,7 @@ define(
|
|||||||
sortBy(sortOptions) {
|
sortBy(sortOptions) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
this.sortOptions = sortOptions;
|
this.sortOptions = sortOptions;
|
||||||
this.rows = _.sortByOrder(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction);
|
this.rows = _.orderBy(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction);
|
||||||
this.emit('sort');
|
this.emit('sort');
|
||||||
}
|
}
|
||||||
// Return duplicate to avoid direct modification of underlying object
|
// Return duplicate to avoid direct modification of underlying object
|
||||||
|
Loading…
Reference in New Issue
Block a user