Skip to content

Commit

Permalink
Upgrade lodash 4 vislib (#11)
Browse files Browse the repository at this point in the history
* replace lodash 3 with lodash 4 on vislib plugin

* Further changes

* further replacement of lodash3 to 4

* further work on upgrading to lodash 4

* final changes to update lodash
  • Loading branch information
stratoula authored Jul 1, 2020
1 parent f5ee602 commit ac50d48
Show file tree
Hide file tree
Showing 78 changed files with 97 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { cloneDeep, uniq, get } from 'lodash3';
import { cloneDeep, uniq, get } from 'lodash';
import { EuiSpacer } from '@elastic/eui';

import { IAggConfig } from 'src/plugins/data/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { capitalize } from 'lodash3';
import { upperFirst } from 'lodash';

import { BasicVislibParams, ValueAxis, SeriesParam } from '../../../types';
import { ChartModes, ChartTypes, InterpolationModes, Positions } from '../../../utils/collections';
Expand Down Expand Up @@ -67,7 +67,7 @@ const getUpdatedAxisName = (
axisPosition: ValueAxis['position'],
valueAxes: BasicVislibParams['valueAxes']
) => {
const axisName = capitalize(axisPosition) + AXIS_PREFIX;
const axisName = upperFirst(axisPosition) + AXIS_PREFIX;
const nextAxisNameNumber = valueAxes.reduce(countNextAxisNumber(axisName, 'name'), 1);

return `${axisName}${nextAxisNameNumber}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
rows: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
label: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
valueFormatter: _.identity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
rows: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
rows: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
label: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
label: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
label: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
rows: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
label: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
rows: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
label: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
columns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
rows: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
label: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

export default {
xAxisOrderedValues: ['_all'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';
import { flattenSeries } from './flatten_series';

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

/*
* Accepts a Kibana data object with a rows or columns key
Expand All @@ -30,5 +30,5 @@ export function flattenSeries(obj) {

obj = obj.rows ? obj.rows : obj.columns;

return _.chain(obj).pluck('series').flattenDeep().value();
return _.chain(obj).map('series').flattenDeep().value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';
import { dataArray as createArr } from './data_array';
import { uniqLabels as getArrOfUniqLabels } from './uniq_labels';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

import { labels } from './labels';
import { dataArray } from './data_array';
Expand Down Expand Up @@ -166,9 +166,9 @@ describe('Vislib Labels Module Test Suite', function () {
seriesArr = Array.isArray(seriesLabels);
rowsArr = Array.isArray(rowsLabels);
uniqSeriesLabels = _.chain(rowsData.rows)
.pluck('series')
.map('series')
.flattenDeep()
.pluck('label')
.map('label')
.uniq()
.value();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

/*
* Accepts an array of data objects and a formatter function.
Expand All @@ -28,5 +28,5 @@ export function uniqLabels(arr) {
throw new TypeError('UniqLabelUtil expects an array of objects');
}

return _(arr).pluck('label').unique().value();
return _(arr).map('label').uniq().value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import React, { BaseSyntheticEvent, KeyboardEvent, PureComponent } from 'react';
import classNames from 'classnames';
import { compact, uniq, map, every, isUndefined } from 'lodash3';
import { compact, uniqBy, map, every, isUndefined } from 'lodash';

import { i18n } from '@kbn/i18n';
import { EuiPopoverProps, EuiIcon, keyCodes, htmlIdGenerator } from '@elastic/eui';
Expand Down Expand Up @@ -119,7 +119,7 @@ export class VisLegend extends PureComponent<VisLegendProps, VisLegendState> {
getSeriesLabels = (data: any[]) => {
const values = data.map((chart) => chart.series).reduce((a, b) => a.concat(b), []);

return compact(uniq(values, 'label')).map((label: any) => ({
return compact(uniqBy(values, 'label')).map((label: any) => ({
...label,
values: [label.values[0].seriesRaw],
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';

/**
* Returns an array of names ordered by appearance in the nested array
Expand All @@ -39,7 +39,7 @@ export function getPieNames(data: any[]): string[] {
});
});

return _.uniq(names, 'label');
return _.uniqBy(names, 'label');
}

/**
Expand All @@ -61,7 +61,7 @@ function getNames(data: any, columns: any): string[] {
.sortBy(function (obj) {
return obj.index;
})
.unique(function (d) {
.uniqBy(function (d) {
return d.label;
})
.value();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React from 'react';
import _ from 'lodash3';
import _ from 'lodash';
import numeral from '@elastic/numeral';
import { renderToStaticMarkup } from 'react-dom/server';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';
import $ from 'jquery';

import { pointSeriesTooltipFormatter } from './_pointseries_tooltip_formatter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import _ from 'lodash3';
import _ from 'lodash';
import $ from 'jquery';

const OFFSET = 10;
Expand Down Expand Up @@ -110,7 +110,7 @@ function getOverflow(size, pos, containers) {
}

function mergeOverflows(dest, src) {
_.merge(dest, src, function (a, b) {
_.mergeWith(dest, src, function (a, b) {
if (a == null || b == null) return a || b;
if (a < 0 && b < 0) return Math.min(a, b);
return Math.max(a, b);
Expand All @@ -131,7 +131,7 @@ function pickPlacement(prop, pos, overflow, prev, pref, fallback, placement) {
const stash = '_' + prop;

// list of directions in order of preference
const dirs = _.unique([prev[stash], pref, fallback].filter(Boolean));
const dirs = _.uniq([prev[stash], pref, fallback].filter(Boolean));

let dir;
let value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import $ from 'jquery';
import _ from 'lodash3';
import _ from 'lodash';
import sinon from 'sinon';

import { positionTooltip } from './position_tooltip';
Expand Down
Loading

0 comments on commit ac50d48

Please sign in to comment.