terminal-table
Advanced tools
Comparing version 0.0.11 to 0.0.12
38
index.js
@@ -203,6 +203,23 @@ var eaw = require("eastasianwidth"); | ||
Table.prototype.getRange = function(row, column, attr){ | ||
for(var i = this.attrMap.length, m;i--;){ | ||
for(var i = this.attrMap.length, m, s;i--;){ | ||
m = this.attrMap[i]; | ||
var r = ((m.row[0] || 0) <= row && row < (m.row[1] || Infinity)) ? 1 : 0; | ||
var c = ((m.column[0] || 0) <= column && column < (m.column[1] || Infinity)) ? 1 : 0; | ||
var startRow = m.row[0] < 0 ? this.table.length + m.row[0] : m.row[0]; | ||
var endRow = m.row[1] < 0 ? this.table.length + m.row[1] : m.row[1]; | ||
if(startRow > endRow){ | ||
s = startRow; | ||
startRow = endRow; | ||
endRow = s; | ||
} | ||
var startCol = m.column[0] < 0 ? this.horlen() + m.column[0] : m.column[0]; | ||
var endCol = m.column[1] < 0 ? this.horlen() + m.column[1] : m.column[1]; | ||
if(startCol > endCol){ | ||
s = startCol; | ||
startCol = endCol; | ||
endRow = s; | ||
} | ||
var r = ((startRow || 0) <= row && row < (endRow || Infinity)) ? 1 : 0; | ||
var c = ((startCol || 0) <= column && column < (endCol || Infinity)) ? 1 : 0; | ||
if((r & c) && m.attr[attr]){ | ||
@@ -218,6 +235,3 @@ return m.attr[attr]; | ||
var val = null; | ||
if(!this.table[row] || !this.table[row][column]){ | ||
return null; | ||
} | ||
if(val = this.table[row][column][attr] || null){ | ||
if(this.table[row] && this.table[row][column] && (val = this.table[row][column][attr] || null)){ | ||
return val; | ||
@@ -342,2 +356,12 @@ } | ||
Table.prototype.__defineGetter__("cols", function(){ | ||
return this.horlen(); | ||
}); | ||
Table.prototype.__defineGetter__("rows", function(){ | ||
return this.table.length; | ||
}); | ||
module.exports = Table; |
{ | ||
"name": "terminal-table", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "View a table in the terminal.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
53709
17
507