Use ES6 class syntax

This commit is contained in:
Daniel García Aubert 2017-09-15 14:04:09 +02:00
parent 6b2e2b2241
commit 5d632d936e

View File

@ -1,12 +1,14 @@
var dataviews = require('./');
var DataviewFactory = {
dataviews: Object.keys(dataviews).reduce(function(allDataviews, dataviewClassName) {
allDataviews[dataviewClassName.toLowerCase()] = dataviews[dataviewClassName];
return allDataviews;
}, {}),
module.exports = class DataviewFactory {
static get dataviews() {
return Object.keys(dataviews).reduce((allDataviews, dataviewClassName) => {
allDataviews[dataviewClassName.toLowerCase()] = dataviews[dataviewClassName];
return allDataviews;
}, {});
}
getDataview: function(query, dataviewDefinition) {
static getDataview (query, dataviewDefinition) {
var type = dataviewDefinition.type;
if (!this.dataviews[type]) {
throw new Error('Invalid dataview type: "' + type + '"');
@ -14,5 +16,3 @@ var DataviewFactory = {
return new this.dataviews[type](query, dataviewDefinition.options, dataviewDefinition.sql);
}
};
module.exports = DataviewFactory;