Skip to content

Commit

Permalink
use class syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Apr 1, 2020
1 parent cd1e20b commit 1efbfef
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ import { getFormatService } from '../../services';
// and thus all map to the same value.
// This little helper overwrites the toString method of an object and keeps it the
// same otherwise - allowing d3 to correctly work with the values.
const D3MappableObject = function(data) {
for (const key in data) {
if (data.hasOwnProperty(key)) {
this[key] = data[key];
class D3MappableObject {
constructor(data) {
for (const key in data) {
if (data.hasOwnProperty(key)) {
this[key] = data[key];
}
}
}
};
D3MappableObject.prototype.toString = function() {
return JSON.stringify(this);
};

toString() {
return JSON.stringify(this);
}
}

/**
* Provides an API for pulling values off the data
Expand Down

0 comments on commit 1efbfef

Please sign in to comment.