Skip to content

Commit

Permalink
fix node 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mekhonoshin (invntrm) committed Apr 9, 2017
1 parent 6022d2b commit 2f35bb6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ var lib = module.exports = {
getTotals: function (headers, rows, totalsFnCollection) {
return headers.map(function (header) {
var columnName = header[0];
var columnCells = rows.map(row => row.reduce((res, cell) => cell[0] === columnName ? cell[1].raw : res));
var columnCells = rows.map(function(row) {
return row.reduce(function (res, cell) { return cell[0] === columnName ? cell[1].raw : res; });
});
var calcTotal = function () { return ''; }

// same totals for all headers
Expand Down Expand Up @@ -146,6 +148,6 @@ var lib = module.exports = {
},

deletedByKey: function (pairs, key) {
return pairs.filter(tuple => tuple[0] !== key)
return pairs.filter(function(tuple) { return tuple[0] !== key; })
}
};
17 changes: 17 additions & 0 deletions node.0.10.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var Table = require('.');
var simple = {
data: [
{ "name": "Larry Wall", "age":57, "link": "<a href='http://www.wall.org/~larry/'>www.wall.org/~larry/</a>" },
{ "name": "Bill Gates", "age":56, "link": "<a href='http://www.microsoft.com'>www.microsoft.com</a>" },
{ "name": "Daffy Duck", "age":75, "link": "" }
],
headersObj: { "name" : "User name", "age": "User age", "link": "Homepage" },
headersPairs: [['name', 'User name'], ['age', 'User age'], ['link', 'Homepage']],
};

var html = (new Table({'class': 'some-table'}))
.setHeaders(simple.headersObj)
.setData(simple.data)
.render();

console.log(html);

0 comments on commit 2f35bb6

Please sign in to comment.