hyper-analytics
Advanced tools
Comparing version 0.11.17 to 0.11.18
182
js/Base.js
'use strict'; | ||
function Base() {} | ||
Base.extend = require('extend-me'); | ||
var Base = require('fin-hypergrid-data-source-base'); | ||
Base.prototype = { | ||
constructor: Base.prototype.constructor, | ||
// Following are for legacy methods | ||
replaceIndent: '_', | ||
Base.prototype.getFields = function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getFields(); | ||
} | ||
}; | ||
getProperty: function getProperty(propName) { | ||
if (propName in this) { | ||
return this[propName]; | ||
} | ||
Base.prototype.getHeaders = function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getHeaders(); | ||
} | ||
}; | ||
if (this.dataSource) { | ||
return getProperty.call(this.dataSource, propName); | ||
} | ||
}, | ||
getDataIndex: function(y) { | ||
if (this.dataSource) { | ||
return this.dataSource.getDataIndex.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getRow: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getRow.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
findRow: function(columnName, value) { | ||
if (this.dataSource) { | ||
return this.dataSource.findRow.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
revealRow: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.revealRow.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getValue: function(x, y){ | ||
if (this.dataSource) { | ||
return this.dataSource.getValue.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
setValue: function(x, y, value){ | ||
if (this.dataSource) { | ||
return this.dataSource.setValue.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getRowCount: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getRowCount.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getColumnCount: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getColumnCount.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getFields: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getFields.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getHeaders: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.getHeaders.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getCalculators: function(){ | ||
if (this.dataSource) { | ||
return this.dataSource.revealRow.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getDefaultHeaders: function(){ | ||
if (this.dataSource) { | ||
return this.dataSource.getDefaultHeaders.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
setFields: function(arr) { | ||
if (this.dataSource) { | ||
return this.dataSource.setFields.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
setHeaders: function(arr) { | ||
if (this.dataSource) { | ||
return this.dataSource.setHeaders.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
getGrandTotals: function(row){ | ||
if (this.dataSource) { | ||
return this.dataSource.getGrandTotals.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
setData: function(arr) { | ||
if (this.dataSource) { | ||
return this.dataSource.setData.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
click: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.click.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
isDrillDown: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.isDrillDown.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
apply: function() {}, | ||
viewMakesSense: function() { | ||
if (this.dataSource) { | ||
return this.dataSource.viewMakesSense.apply(this.dataSource, arguments); | ||
} | ||
}, | ||
Base.prototype.getCalculators = function() { | ||
if (this.dataSource) { | ||
return this.dataSource.revealRow(); | ||
} | ||
}; | ||
/** | ||
* Get new object with name and index given the name or the index. | ||
* @param {string|number} [column] - Column name or index. | ||
* @param {string} [defaultName] - Name to use when column is omitted or undefined. May be omitted when column is definitely defined. | ||
* @returns {{name: string, index: number}} | ||
*/ | ||
getColumnInfo: function(column, defaultName) { | ||
var name, index; | ||
if (column === undefined) { | ||
column = defaultName; | ||
} | ||
if (typeof column === 'number') { | ||
name = this.getFields()[index = column]; | ||
} else { | ||
index = this.getFields().indexOf(name = column); | ||
} | ||
if (name && index >= 0) { | ||
return { | ||
name: name, | ||
index: index | ||
}; | ||
} | ||
}, | ||
Base.prototype.setFields = function(arr) { | ||
if (this.dataSource) { | ||
return this.dataSource.setFields.call(this.dataSource, arr); | ||
} | ||
}; | ||
fixIndentForTableDisplay: function(string) { | ||
var count = string.search(/\S/); | ||
var end = string.substring(count); | ||
var result = Array(count + 1).join(this.replaceIndent) + end; | ||
return result; | ||
}, | ||
dump: function(max) { | ||
max = Math.min(this.getRowCount(), max || Math.max(100, this.getRowCount())); | ||
var data = []; | ||
var fields = this.getHeaders(); | ||
var cCount = this.getColumnCount(); | ||
var viewMakesSense = this.viewMakesSense; | ||
for (var r = 0; r < max; r++) { | ||
var row = {}; | ||
for (var c = 0; c < cCount; c++) { | ||
var val = this.getValue(c, r); | ||
if (c === 0 && viewMakesSense) { | ||
val = this.fixIndentForTableDisplay(val); | ||
} | ||
row[fields[c]] = val; | ||
} | ||
data[r] = row; | ||
} | ||
console.table(data); | ||
Base.prototype.setHeaders = function(arr) { | ||
if (this.dataSource) { | ||
return this.dataSource.setHeaders.call(this.dataSource, arr); | ||
} | ||
@@ -167,0 +35,0 @@ }; |
{ | ||
"name": "hyper-analytics", | ||
"version": "0.11.17", | ||
"version": "0.11.18", | ||
"description": "Data transformations on arrays of congruent JavaScript objects.", | ||
@@ -15,6 +15,3 @@ "repository": { | ||
"devDependencies": { | ||
"browser-sync": "^2.10.1", | ||
"gulp": "^3.9.0", | ||
"gulp-beautify": "^2.0.0", | ||
"gulp-browserify": "^0.5.1", | ||
"gulp-eslint": "^1.1.1", | ||
@@ -24,6 +21,2 @@ "gulp-exclude-gitignore": "^1.0.0", | ||
"gulp-mocha": "^2.2.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-replace": "^0.5.4", | ||
"gulp-sourcemaps": "^1.5.2", | ||
"gulp-uglify": "^1.5.1", | ||
"gulp-util": "^3.0.6", | ||
@@ -39,4 +32,5 @@ "jsdoc": "^3.3.2", | ||
"dependencies": { | ||
"extend-me": "^2.2.4" | ||
"extend-me": "^2.3.0", | ||
"fin-hypergrid-data-source-base": "0.4.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13
88212
2
2714
+ Addedfin-hypergrid-data-source-base@0.4.0(transitive)
Updatedextend-me@^2.3.0