Skip to content

Commit

Permalink
Vector: remove toJSON() from interface (grafana#19254)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantxu committed Sep 20, 2019
1 parent 19f3ec4 commit 6787e7b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/grafana-data/src/dataframe/FieldCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/grafana-data/src/dataframe/processDataFrame.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
});
});
2 changes: 1 addition & 1 deletion packages/grafana-data/src/dataframe/processDataFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
});

Expand Down
1 change: 1 addition & 0 deletions packages/grafana-data/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './displayValue';
export * from './graph';
export * from './ScopedVars';
export * from './transformations';
export * from './vector';
5 changes: 0 additions & 5 deletions packages/grafana-data/src/types/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ export interface Vector<T = any> {
* Get the resutls as an array.
*/
toArray(): T[];

/**
* Return the values as a simple array for json serialization
*/
toJSON(): any; // same results as toArray()
}

/**
Expand Down

0 comments on commit 6787e7b

Please sign in to comment.