From 6787e7b5ab984338071f64f59fc72aaaa2dad055 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Fri, 20 Sep 2019 08:22:33 -0700 Subject: [PATCH] Vector: remove toJSON() from interface (#19254) --- packages/grafana-data/src/dataframe/FieldCache.test.ts | 2 +- .../grafana-data/src/dataframe/processDataFrame.test.ts | 8 ++++---- packages/grafana-data/src/dataframe/processDataFrame.ts | 2 +- packages/grafana-data/src/types/index.ts | 1 + packages/grafana-data/src/types/vector.ts | 5 ----- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/grafana-data/src/dataframe/FieldCache.test.ts b/packages/grafana-data/src/dataframe/FieldCache.test.ts index d38946bd712..2f005157b8e 100644 --- a/packages/grafana-data/src/dataframe/FieldCache.test.ts +++ b/packages/grafana-data/src/dataframe/FieldCache.test.ts @@ -82,7 +82,7 @@ describe('FieldCache', () => { it('should get the first field with a duplicate name', () => { const field = ext.getFieldByName('value'); expect(field!.name).toEqual('value'); - expect(field!.values.toJSON()).toEqual([1, 2, 3]); + expect(field!.values.toArray()).toEqual([1, 2, 3]); }); it('should return index of the field', () => { diff --git a/packages/grafana-data/src/dataframe/processDataFrame.test.ts b/packages/grafana-data/src/dataframe/processDataFrame.test.ts index adf10690ec5..70fae9a879b 100644 --- a/packages/grafana-data/src/dataframe/processDataFrame.test.ts +++ b/packages/grafana-data/src/dataframe/processDataFrame.test.ts @@ -189,14 +189,14 @@ describe('sorted DataFrame', () => { it('Should sort numbers', () => { const sorted = sortDataFrame(frame, 0, true); expect(sorted.length).toEqual(3); - expect(sorted.fields[0].values.toJSON()).toEqual([3, 2, 1]); - expect(sorted.fields[1].values.toJSON()).toEqual(['c', 'b', 'a']); + expect(sorted.fields[0].values.toArray()).toEqual([3, 2, 1]); + expect(sorted.fields[1].values.toArray()).toEqual(['c', 'b', 'a']); }); it('Should sort strings', () => { const sorted = sortDataFrame(frame, 1, true); expect(sorted.length).toEqual(3); - expect(sorted.fields[0].values.toJSON()).toEqual([3, 2, 1]); - expect(sorted.fields[1].values.toJSON()).toEqual(['c', 'b', 'a']); + expect(sorted.fields[0].values.toArray()).toEqual([3, 2, 1]); + expect(sorted.fields[1].values.toArray()).toEqual(['c', 'b', 'a']); }); }); diff --git a/packages/grafana-data/src/dataframe/processDataFrame.ts b/packages/grafana-data/src/dataframe/processDataFrame.ts index 6221bb4e658..abb8a67aae2 100644 --- a/packages/grafana-data/src/dataframe/processDataFrame.ts +++ b/packages/grafana-data/src/dataframe/processDataFrame.ts @@ -401,7 +401,7 @@ export function toDataFrameDTO(data: DataFrame): DataFrameDTO { name: f.name, type: f.type, config: f.config, - values: f.values.toJSON(), + values: f.values.toArray(), }; }); diff --git a/packages/grafana-data/src/types/index.ts b/packages/grafana-data/src/types/index.ts index fd8d362074a..24ffa20123d 100644 --- a/packages/grafana-data/src/types/index.ts +++ b/packages/grafana-data/src/types/index.ts @@ -12,3 +12,4 @@ export * from './displayValue'; export * from './graph'; export * from './ScopedVars'; export * from './transformations'; +export * from './vector'; diff --git a/packages/grafana-data/src/types/vector.ts b/packages/grafana-data/src/types/vector.ts index 7e667d725a9..d4e231b51d0 100644 --- a/packages/grafana-data/src/types/vector.ts +++ b/packages/grafana-data/src/types/vector.ts @@ -10,11 +10,6 @@ export interface Vector { * Get the resutls as an array. */ toArray(): T[]; - - /** - * Return the values as a simple array for json serialization - */ - toJSON(): any; // same results as toArray() } /**