Applyy extract method to check input options
This commit is contained in:
parent
419b29e609
commit
d4bb4edd1d
@ -53,6 +53,16 @@ module.exports = class Formula extends BaseDataview {
|
|||||||
constructor (query, options = {}, queries = {}) {
|
constructor (query, options = {}, queries = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this._checkOptions(options);
|
||||||
|
|
||||||
|
this.query = query;
|
||||||
|
this.queries = queries;
|
||||||
|
this.column = options.column || '1';
|
||||||
|
this.operation = options.operation;
|
||||||
|
this._isFloatColumn = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_checkOptions (options) {
|
||||||
if (typeof options.operation !== 'string') {
|
if (typeof options.operation !== 'string') {
|
||||||
throw new Error(`Formula expects 'operation' in dataview options`);
|
throw new Error(`Formula expects 'operation' in dataview options`);
|
||||||
}
|
}
|
||||||
@ -64,12 +74,6 @@ module.exports = class Formula extends BaseDataview {
|
|||||||
if (options.operation !== 'count' && typeof options.column !== 'string') {
|
if (options.operation !== 'count' && typeof options.column !== 'string') {
|
||||||
throw new Error(`Formula expects 'column' in dataview options`);
|
throw new Error(`Formula expects 'column' in dataview options`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.query = query;
|
|
||||||
this.queries = queries;
|
|
||||||
this.column = options.column || '1';
|
|
||||||
this.operation = options.operation;
|
|
||||||
this._isFloatColumn = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user