From f0a17e935d7cafd8e73ab89da0e5268b428da65a Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias.bieniek@gmail.com>
Date: Wed, 3 Aug 2016 18:32:57 +0200
Subject: [PATCH 1/7] gulp: Remove unused lodash import

---
 gulpfile.js | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index 5349626..6e3e6a8 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -3,7 +3,6 @@ var gutil = require('gulp-util');
 var mocha = require('gulp-mocha');
 var istanbul = require('gulp-istanbul');
 var printExample = require('./lib/print-example');
-var _ = require('lodash');
 
 gulp.task('test',mochaTask);
 gulp.task('coverage',coverage());
@@ -70,4 +69,4 @@ function logMochaError(err){
   } else {
     gutil.log.apply(gutil,arguments);
   }
-}
\ No newline at end of file
+}

From 6cefb3d7f6a4f09f70d8d45460aad7f6ed1d60f5 Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias.bieniek@gmail.com>
Date: Wed, 3 Aug 2016 18:34:37 +0200
Subject: [PATCH 2/7] lib: Remove unused lodash import

---
 lib/print-example.js | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/print-example.js b/lib/print-example.js
index ae23609..29eb9b6 100644
--- a/lib/print-example.js
+++ b/lib/print-example.js
@@ -1,7 +1,6 @@
 var chai = require('chai');
 var expect = chai.expect;
 var colors = require('colors/safe');
-var _ = require('lodash');
 var fs = require('fs');
 var git = require('git-rev');
 
@@ -120,4 +119,4 @@ module.exports = {
   mdExample:mdExample,
   logExample:logExample,
   runTest:runTest
-};
\ No newline at end of file
+};

From f418e8f2ccac08f8d435c429f2d47045c187e041 Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias.bieniek@gmail.com>
Date: Wed, 3 Aug 2016 18:35:10 +0200
Subject: [PATCH 3/7] Replace _.forEach() calls with native Array.forEach()

---
 src/cell.js               |  6 +++---
 src/layout-manager.js     | 24 ++++++++++++------------
 src/table.js              | 14 ++++++--------
 test/table-layout-test.js |  6 +++---
 4 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/cell.js b/src/cell.js
index 1281b97..6b645b6 100644
--- a/src/cell.js
+++ b/src/cell.js
@@ -36,7 +36,7 @@ Cell.prototype.mergeTableOptions = function(tableOptions,cells){
   var optionsChars = this.options.chars || {};
   var tableChars = tableOptions.chars;
   var chars = this.chars = {};
-  _.forEach(CHAR_NAMES,function(name){
+  CHAR_NAMES.forEach(function(name){
      setOption(optionsChars,tableChars,name,chars);
   });
 
@@ -132,7 +132,7 @@ Cell.prototype.draw = function(lineNum,spanningCell){
 Cell.prototype.drawTop = function(drawRight){
   var content = [];
   if(this.cells){  //TODO: cells should always exist - some tests don't fill it in though
-    _.forEach(this.widths,function(width,index){
+    this.widths.forEach(function(width,index){
       content.push(this._topLeftChar(index));
       content.push(
         utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'],width)
@@ -361,4 +361,4 @@ var CHAR_NAMES = [  'top'
 ];
 module.exports = Cell;
 module.exports.ColSpanCell = ColSpanCell;
-module.exports.RowSpanCell = RowSpanCell;
\ No newline at end of file
+module.exports.RowSpanCell = RowSpanCell;
diff --git a/src/layout-manager.js b/src/layout-manager.js
index c17ce34..bb53571 100644
--- a/src/layout-manager.js
+++ b/src/layout-manager.js
@@ -5,8 +5,8 @@ var ColSpanCell = Cell.ColSpanCell;
 
 (function(){
   function layoutTable(table){
-    _.forEach(table,function(row,rowIndex){
-      _.forEach(row,function(cell,columnIndex){
+    table.forEach(function(row,rowIndex){
+      row.forEach(function(cell,columnIndex){
         cell.y = rowIndex;
         cell.x = columnIndex;
         for(var y = rowIndex; y >= 0; y--){
@@ -25,8 +25,8 @@ var ColSpanCell = Cell.ColSpanCell;
 
   function maxWidth(table) {
     var mw = 0;
-    _.forEach(table, function (row) {
-      _.forEach(row, function (cell) {
+    table.forEach(function (row) {
+      row.forEach(function (cell) {
         mw = Math.max(mw,cell.x + (cell.colSpan || 1));
       });
     });
@@ -77,8 +77,8 @@ var ColSpanCell = Cell.ColSpanCell;
   }
 
   function addRowSpanCells(table){
-    _.forEach(table,function(row,rowIndex){
-      _.forEach(row,function(cell){
+    table.forEach(function(row,rowIndex){
+      row.forEach(function(cell){
         for(var i = 1; i < cell.rowSpan; i++){
           var rowSpanCell = new RowSpanCell(cell);
           rowSpanCell.x = cell.x;
@@ -141,7 +141,7 @@ var ColSpanCell = Cell.ColSpanCell;
   }
 
   function generateCells(rows){
-    return _.map(rows,function(row){
+    return rows.map(function(row){
       if(!_.isArray(row)){
         var key = Object.keys(row)[0];
         row = row[key];
@@ -153,7 +153,7 @@ var ColSpanCell = Cell.ColSpanCell;
           row = [key,row];
         }
       }
-      return _.map(row,function(cell){
+      return row.map(function(cell){
         return new Cell(cell);
       });
     });
@@ -183,8 +183,8 @@ function makeComputeWidths(colSpan,desiredWidth,x,forcedMin){
   return function(vals,table){
     var result = [];
     var spanners = [];
-    _.forEach(table,function(row){
-      _.forEach(row,function(cell){
+    table.forEach(function(row){
+      row.forEach(function(cell){
         if((cell[colSpan] || 1) > 1){
           spanners.push(cell);
         }
@@ -194,13 +194,13 @@ function makeComputeWidths(colSpan,desiredWidth,x,forcedMin){
       });
     });
 
-    _.forEach(vals,function(val,index){
+    vals.forEach(function(val,index){
       if(_.isNumber(val)){
         result[index] = val;
       }
     });
 
-    //_.forEach(spanners,function(cell){
+    //spanners.forEach(function(cell){
     for(var k = spanners.length - 1; k >=0; k--){
       var cell = spanners[k];
       var span = cell[colSpan];
diff --git a/src/table.js b/src/table.js
index 09af0d7..1df19ae 100644
--- a/src/table.js
+++ b/src/table.js
@@ -1,7 +1,5 @@
-
 var utils = require('./utils');
 var tableLayout = require('./layout-manager');
-var _ = require('lodash');
 
 function Table(options){
   this.options = utils.mergeOptions(options);
@@ -24,8 +22,8 @@ Table.prototype.toString = function(){
 
   var cells = tableLayout.makeTableLayout(array);
 
-  _.forEach(cells,function(row){
-    _.forEach(row,function(cell){
+  cells.forEach(function(row){
+    row.forEach(function(cell){
       cell.mergeTableOptions(this.options,cells);
     },this);
   },this);
@@ -33,8 +31,8 @@ Table.prototype.toString = function(){
   tableLayout.computeWidths(this.options.colWidths,cells);
   tableLayout.computeHeights(this.options.rowHeights,cells);
 
-  _.forEach(cells,function(row,rowIndex){
-    _.forEach(row,function(cell,cellIndex){
+  cells.forEach(function(row,rowIndex){
+    row.forEach(function(cell,cellIndex){
       cell.init(this.options);
     },this);
   },this);
@@ -63,7 +61,7 @@ Table.prototype.toString = function(){
 
 function doDraw(row,lineNum,result){
   var line = [];
-  _.forEach(row,function(cell){
+  row.forEach(function(cell){
     line.push(cell.draw(lineNum));
   });
   var str = line.join('');
@@ -75,4 +73,4 @@ Table.prototype.__defineGetter__('width', function (){
   return str[0].length;
 });
 
-module.exports = Table;
\ No newline at end of file
+module.exports = Table;
diff --git a/test/table-layout-test.js b/test/table-layout-test.js
index cebe167..80014e1 100644
--- a/test/table-layout-test.js
+++ b/test/table-layout-test.js
@@ -414,8 +414,8 @@ describe('tableLayout', function () {
    */
 
   function checkLayout(actualTable,expectedTable){
-    _.forEach(expectedTable,function(expectedRow,y){
-      _.forEach(expectedRow,function(expectedCell,x){
+    expectedTable.forEach(function(expectedRow,y){
+      expectedRow.forEach(function(expectedCell,x){
         if(expectedCell !== null){
           var actualCell = findCell(actualTable,x,y);
           checkExpectation(actualCell,expectedCell,x,y,actualTable);
@@ -463,4 +463,4 @@ describe('tableLayout', function () {
       //TODO: retest here x,y coords
     }
   }
-});
\ No newline at end of file
+});

From 34c8d379342cd9368575dde1113b5988c9cc40a2 Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias.bieniek@gmail.com>
Date: Wed, 3 Aug 2016 18:35:25 +0200
Subject: [PATCH 4/7] utils: Replace _.forEach() calls with
 Object.keys().forEach()

---
 src/utils.js | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/utils.js b/src/utils.js
index 9dae6e5..f31933f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -104,8 +104,8 @@ function unwindState(state,ret){
   delete state.lastBackgroundAdded;
   delete state.lastForegroundAdded;
 
-  _.forEach(state,function(value,key){
-    if(value){
+  Object.keys(state).forEach(function(key){
+    if(state[key]){
       ret += codeCache[key].off;
     }
   });
@@ -127,8 +127,8 @@ function rewindState(state,ret){
   delete state.lastBackgroundAdded;
   delete state.lastForegroundAdded;
 
-  _.forEach(state,function(value,key){
-    if(value){
+  Object.keys(state).forEach(function(key){
+    if(state[key]){
       ret = codeCache[key].on + ret;
     }
   });

From 5a4f8926980a35ad035fef9ae540370f724d1ffd Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias.bieniek@gmail.com>
Date: Wed, 3 Aug 2016 19:04:14 +0200
Subject: [PATCH 5/7] cell: Replace _.reduce() calls with native Array.reduce()

---
 src/cell.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cell.js b/src/cell.js
index 6b645b6..7ffde37 100644
--- a/src/cell.js
+++ b/src/cell.js
@@ -85,8 +85,8 @@ Cell.prototype.init = function(tableOptions){
   var y = this.y;
   this.widths = tableOptions.colWidths.slice(x, x + this.colSpan);
   this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan);
-  this.width = _.reduce(this.widths,sumPlusOne);
-  this.height = _.reduce(this.heights,sumPlusOne);
+  this.width = this.widths.reduce(sumPlusOne, -1);
+  this.height = this.heights.reduce(sumPlusOne, -1);
 
   this.hAlign = this.options.hAlign || tableOptions.colAligns[x];
   this.vAlign = this.options.vAlign || tableOptions.rowAligns[y];

From cb5fb2a2722f701642e1b89cd0b56826ac4a11b8 Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias.bieniek@gmail.com>
Date: Wed, 3 Aug 2016 19:13:48 +0200
Subject: [PATCH 6/7] Replace _.extend() with Object.assign() polyfill

---
 package.json          |  1 +
 src/layout-manager.js |  3 ++-
 src/utils.js          | 10 +++++-----
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/package.json b/package.json
index c02b369..7e1c10b 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,7 @@
   },
   "dependencies": {
     "lodash": "^3.10.1",
+    "object-assign": "^4.1.0",
     "string-width": "^1.0.1"
   },
   "devDependencies": {
diff --git a/src/layout-manager.js b/src/layout-manager.js
index bb53571..f110de3 100644
--- a/src/layout-manager.js
+++ b/src/layout-manager.js
@@ -1,4 +1,5 @@
 var _ = require('lodash');
+var objectAssign = require('object-assign');
 var Cell = require('./cell');
 var RowSpanCell = Cell.RowSpanCell;
 var ColSpanCell = Cell.ColSpanCell;
@@ -227,7 +228,7 @@ function makeComputeWidths(colSpan,desiredWidth,x,forcedMin){
       }
     }
 
-    _.extend(vals,result);
+    objectAssign(vals,result);
     for(var j = 0; j < vals.length; j++){
       vals[j] = Math.max(forcedMin, vals[j] || 0);
     }
diff --git a/src/utils.js b/src/utils.js
index f31933f..f6c0ae2 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,4 +1,4 @@
-var _ = require('lodash');
+var objectAssign = require('object-assign');
 var stringWidth = require('string-width');
 
 function codeRegex(capture){
@@ -236,9 +236,9 @@ function defaultOptions(){
 function mergeOptions(options,defaults){
   options = options || {};
   defaults = defaults || defaultOptions();
-  var ret = _.extend({}, defaults, options);
-  ret.chars = _.extend({}, defaults.chars, options.chars);
-  ret.style = _.extend({}, defaults.style, options.style);
+  var ret = objectAssign({}, defaults, options);
+  ret.chars = objectAssign({}, defaults.chars, options.chars);
+  ret.style = objectAssign({}, defaults.style, options.style);
   return ret;
 }
 
@@ -287,7 +287,7 @@ function colorizeLines(input){
   for(var i = 0; i < input.length; i++){
     var line = rewindState(state,input[i]) ;
     state = readState(line);
-    var temp = _.extend({},state);
+    var temp = objectAssign({},state);
     output.push(unwindState(temp,line));
   }
   return output;

From 3a37e3188e26f61de5958e207e7f5fe7865a6f18 Mon Sep 17 00:00:00 2001
From: Tobias Bieniek <tobias.bieniek@gmail.com>
Date: Wed, 3 Aug 2016 20:14:35 +0200
Subject: [PATCH 7/7] Replace _.isNumber/String/...() with "kind-of" library

---
 package.json              |  2 +-
 src/cell.js               |  6 +++---
 src/layout-manager.js     | 14 +++++++-------
 test/table-layout-test.js |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/package.json b/package.json
index 7e1c10b..0851865 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
     "test": "test"
   },
   "dependencies": {
-    "lodash": "^3.10.1",
+    "kind-of": "^3.0.4",
     "object-assign": "^4.1.0",
     "string-width": "^1.0.1"
   },
diff --git a/src/cell.js b/src/cell.js
index 7ffde37..c65fd7c 100644
--- a/src/cell.js
+++ b/src/cell.js
@@ -1,4 +1,4 @@
-var _ = require('lodash');
+var kindOf = require('kind-of');
 var utils = require('./utils');
 
 /**
@@ -13,13 +13,13 @@ function Cell(options){
 }
 
 Cell.prototype.setOptions = function(options){
-  if(_.isString(options) || _.isNumber(options) || _.isBoolean(options)){
+  if(['boolean', 'number', 'string'].indexOf(kindOf(options)) !== -1){
     options = {content:''+options};
   }
   options = options || {};
   this.options = options;
   var content = options.content;
-  if (_.isString(content) || _.isNumber(content) || _.isBoolean(content)) {
+  if (['boolean', 'number', 'string'].indexOf(kindOf(content)) !== -1) {
     this.content = String(content);
   } else if (!content) {
     this.content = '';
diff --git a/src/layout-manager.js b/src/layout-manager.js
index f110de3..098df3a 100644
--- a/src/layout-manager.js
+++ b/src/layout-manager.js
@@ -1,4 +1,4 @@
-var _ = require('lodash');
+var kindOf = require('kind-of');
 var objectAssign = require('object-assign');
 var Cell = require('./cell');
 var RowSpanCell = Cell.RowSpanCell;
@@ -143,10 +143,10 @@ var ColSpanCell = Cell.ColSpanCell;
 
   function generateCells(rows){
     return rows.map(function(row){
-      if(!_.isArray(row)){
+      if(kindOf(row) !== 'array'){
         var key = Object.keys(row)[0];
         row = row[key];
-        if(_.isArray(row)){
+        if(kindOf(row) === 'array'){
           row = row.slice();
           row.unshift(key);
         }
@@ -196,7 +196,7 @@ function makeComputeWidths(colSpan,desiredWidth,x,forcedMin){
     });
 
     vals.forEach(function(val,index){
-      if(_.isNumber(val)){
+      if(kindOf(val) === 'number'){
         result[index] = val;
       }
     });
@@ -207,17 +207,17 @@ function makeComputeWidths(colSpan,desiredWidth,x,forcedMin){
       var span = cell[colSpan];
       var col = cell[x];
       var existingWidth = result[col];
-      var editableCols = _.isNumber(vals[col]) ? 0 : 1;
+      var editableCols = kindOf(vals[col]) === 'number' ? 0 : 1;
       for(var i = 1; i < span; i ++){
         existingWidth += 1 + result[col + i];
-        if(!_.isNumber(vals[col + i])){
+        if(kindOf(vals[col + i]) !== 'number'){
           editableCols++;
         }
       }
       if(cell[desiredWidth] > existingWidth){
         i = 0;
         while(editableCols > 0 && cell[desiredWidth] > existingWidth){
-          if(!_.isNumber(vals[col+i])){
+          if(kindOf(vals[col+i]) !== 'number'){
             var dif = Math.round( (cell[desiredWidth] - existingWidth) / editableCols );
             existingWidth += dif;
             result[col + i] += dif;
diff --git a/test/table-layout-test.js b/test/table-layout-test.js
index 80014e1..e4b5c59 100644
--- a/test/table-layout-test.js
+++ b/test/table-layout-test.js
@@ -10,7 +10,7 @@ describe('tableLayout', function () {
   var computeHeights = layoutManager.computeHeights;
   var chai = require('chai');
   var expect = chai.expect;
-  var _ = require('lodash');
+  var kindOf = require('kind-of');
 
   it('simple 2x2 layout',function(){
     var actual = makeTableLayout([
@@ -437,7 +437,7 @@ describe('tableLayout', function () {
   }
 
   function checkExpectation(actualCell,expectedCell,x,y,actualTable){
-    if(_.isString(expectedCell)){
+    if(kindOf(expectedCell) === 'string'){
       expectedCell = {content:expectedCell};
     }
     var address = '(' + y + ',' + x + ')';
