From d6c1df0785bc5043fdb486caa67b4729e58ba270 Mon Sep 17 00:00:00 2001 From: Beau Sorensen Date: Thu, 5 Feb 2015 16:14:34 -0800 Subject: [PATCH] Fixing formatting, version bump 0.0.7 --- ascii-table.js | 45 ++++++++++++++++++++++----------------------- ascii-table.min.js | 2 +- bower.json | 2 +- package.json | 2 +- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/ascii-table.js b/ascii-table.js index bc518b0..0c35485 100644 --- a/ascii-table.js +++ b/ascii-table.js @@ -34,7 +34,7 @@ function AsciiTable(name, options) { * Current library version, should match `package.json` */ -AsciiTable.VERSION = '0.0.6' +AsciiTable.VERSION = '0.0.7' /*! * Alignment constants @@ -404,30 +404,29 @@ AsciiTable.prototype.addRowMatrix = function(rows) { return this } - /** - * Add rows from the given data array, processed by the callback function rowCallback. - * - * @param {Array} data - * @param (Function) rowCallback - * @param (Boolean) asMatrix - controls if the row created by rowCallback should be assigned as row matrix - * @api public - */ - - AsciiTable.prototype.addData = function(data, rowCallback, asMatrix) { - if(Object.prototype.toString.call( data ) !== '[object Array]') { - - return this; - } - for (var index = 0, limit = data.length; index < limit; index++) { - var row = rowCallback(data[index]); - if(asMatrix) { - this.addRowMatrix(row); - } else { - this.addRow(row); - } +/** + * Add rows from the given data array, processed by the callback function rowCallback. + * + * @param {Array} data + * @param (Function) rowCallback + * @param (Boolean) asMatrix - controls if the row created by rowCallback should be assigned as row matrix + * @api public + */ + +AsciiTable.prototype.addData = function(data, rowCallback, asMatrix) { + if (toString.call(data) !== '[object Array]') { + return this; + } + for (var index = 0, limit = data.length; index < limit; index++) { + var row = rowCallback(data[index]); + if(asMatrix) { + this.addRowMatrix(row); + } else { + this.addRow(row); } - return this } + return this +} /** * Reset the current row state diff --git a/ascii-table.min.js b/ascii-table.min.js index e9d4dbf..9b6e06a 100644 --- a/ascii-table.min.js +++ b/ascii-table.min.js @@ -1 +1 @@ -!function(){"use strict";function t(t,e){this.options=e||{},this.reset(t)}var e=Array.prototype.slice,i=Object.prototype.toString;t.VERSION="0.0.6",t.LEFT=0,t.CENTER=1,t.RIGHT=2,t.factory=function(e,i){return new t(e,i)},t.align=function(e,i,n,r){return e===t.LEFT?t.alignLeft(i,n,r):e===t.RIGHT?t.alignRight(i,n,r):e===t.CENTER?t.alignCenter(i,n,r):t.alignAuto(i,n,r)},t.alignLeft=function(t,e,i){if(!e||0>e)return"";"undefined"==typeof t&&(t=""),"undefined"==typeof i&&(i=" "),"string"!=typeof t&&(t=t.toString());var n=e+1-t.length;return 0>=n?t:t+Array(e+1-t.length).join(i)},t.alignCenter=function(e,i,n){if(!i||0>i)return"";"undefined"==typeof e&&(e=""),"undefined"==typeof n&&(n=" "),"string"!=typeof e&&(e=e.toString());var r=e.length,o=Math.floor(i/2-r/2),s=Math.abs(r%2-i%2),i=e.length;return t.alignRight("",o,n)+e+t.alignLeft("",o+s,n)},t.alignRight=function(t,e,i){if(!e||0>e)return"";"undefined"==typeof t&&(t=""),"undefined"==typeof i&&(i=" "),"string"!=typeof t&&(t=t.toString());var n=e+1-t.length;return 0>=n?t:Array(e+1-t.length).join(i)+t},t.alignAuto=function(e,n,r){"undefined"==typeof e&&(e="");var o=i.call(e);if(r||(r=" "),n=+n,"[object String]"!==o&&(e=e.toString()),e.length1||"[object Array]"!==i.call(t))&&(t=e.call(arguments)),this.__heading=t,this},t.prototype.getHeading=function(){return this.__heading.slice()},t.prototype.setHeadingAlign=function(t){return this.__headingAlign=t,this},t.prototype.addRow=function(t){return(arguments.length>1||"[object Array]"!==i.call(t))&&(t=e.call(arguments)),this.__maxCells=Math.max(this.__maxCells,t.length),this.__rows.push(t),this},t.prototype.getRows=function(){return this.__rows.slice().map(function(t){return t.slice()})},t.prototype.addRowMatrix=function(t){for(var e=0;eg;g++){var p=u[g];o[g]=Math.max(o[g],p?p.toString().length:0)}this.__colMaxes=o,e=this.__justify?Math.max.apply(null,o):0,o.forEach(function(t){s+=e?e:t+i.__spacing}),e&&(s+=o.length),s-=this.__spacing,a&&n.push(this._seperator(s-r+1,this.__top)),this.__name&&(n.push(this._renderTitle(s-r+1)),a&&n.push(this._seperator(s-r+1))),this.__heading&&(n.push(this._renderRow(this.__heading," ",this.__headingAlign)),n.push(this._rowSeperator(r,this.__fill)));for(var l=0;le)return"";t||(t=""),"undefined"==typeof i&&(i=" "),"string"!=typeof t&&(t=t.toString());var r=e+1-t.length;return 0>=r?t:t+Array(e+1-t.length).join(i)},t.alignCenter=function(e,i,r){if(!i||0>i)return"";e||(e=""),"undefined"==typeof r&&(r=" "),"string"!=typeof e&&(e=e.toString());var n=e.length,o=Math.floor(i/2-n/2),s=Math.abs(n%2-i%2),i=e.length;return t.alignRight("",o,r)+e+t.alignLeft("",o+s,r)},t.alignRight=function(t,e,i){if(!e||0>e)return"";t||(t=""),"undefined"==typeof i&&(i=" "),"string"!=typeof t&&(t=t.toString());var r=e+1-t.length;return 0>=r?t:Array(e+1-t.length).join(i)+t},t.alignAuto=function(e,r,n){e||(e="");var o=i.call(e);if(n||(n=" "),r=+r,"[object String]"!==o&&(e=e.toString()),e.length1||"[object Array]"!==i.call(t))&&(t=e.call(arguments)),this.__heading=t,this},t.prototype.getHeading=function(){return this.__heading.slice()},t.prototype.setHeadingAlign=function(t){return this.__headingAlign=t,this},t.prototype.addRow=function(t){return(arguments.length>1||"[object Array]"!==i.call(t))&&(t=e.call(arguments)),this.__maxCells=Math.max(this.__maxCells,t.length),this.__rows.push(t),this},t.prototype.getRows=function(){return this.__rows.slice().map(function(t){return t.slice()})},t.prototype.addRowMatrix=function(t){for(var e=0;en;n++){var s=e(t[n]);r?this.addRowMatrix(s):this.addRow(s)}return this},t.prototype.clearRows=function(){return this.__rows=[],this.__maxCells=0,this.__colMaxes=[],this},t.prototype.setJustify=function(t){return 0===arguments.length&&(t=!0),this.__justify=!!t,this},t.prototype.toJSON=function(){return{title:this.getTitle(),heading:this.getHeading(),rows:this.getRows()}},t.prototype.parse=t.prototype.fromJSON=function(t){return this.clear().setTitle(t.title).setHeading(t.heading).addRowMatrix(t.rows)},t.prototype.render=t.prototype.valueOf=t.prototype.toString=function(){for(var e,i=this,r=[],n=this.__maxCells,o=t.arrayFill(n,0),s=3*n,h=this.__rows,a=this.__border,_=this.__heading?[this.__heading].concat(h):h,l=0;l<_.length;l++)for(var u=_[l],g=0;n>g;g++){var p=u[g];o[g]=Math.max(o[g],p?p.toString().length:0)}this.__colMaxes=o,e=this.__justify?Math.max.apply(null,o):0,o.forEach(function(t){s+=e?e:t+i.__spacing}),e&&(s+=o.length),s-=this.__spacing,a&&r.push(this._seperator(s-n+1,this.__top)),this.__name&&(r.push(this._renderTitle(s-n+1)),a&&r.push(this._seperator(s-n+1))),this.__heading&&(r.push(this._renderRow(this.__heading," ",this.__headingAlign)),r.push(this._rowSeperator(n,this.__fill)));for(var l=0;l" diff --git a/package.json b/package.json index 3e0d218..6969cd1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ascii-table" -, "version": "0.0.6" +, "version": "0.0.7" , "license": "MIT" , "keywords": [ "table"