Skip to content

Commit

Permalink
remove support for node < v8
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Jun 26, 2019
1 parent 32d6a3e commit c6d34bb
Show file tree
Hide file tree
Showing 14 changed files with 1,591 additions and 197 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -3,5 +3,3 @@ node_js:
- 12
- 10
- 8
- 6
- 4
6 changes: 1 addition & 5 deletions index.js
@@ -1,4 +1,3 @@
'use strict'
const os = require('os')

/**
Expand All @@ -22,7 +21,6 @@ const os = require('os')
* layout
*/
class Table {

/**
* @param {object[]} - input data
* @param [options] {object} - optional settings
Expand Down Expand Up @@ -177,12 +175,10 @@ function getLongestArray (arrays) {

function padCell (cellValue, padding, width) {
const ansi = require('./lib/ansi')
const padEnd = require('lodash.padend')
var ansiLength = cellValue.length - ansi.remove(cellValue).length
cellValue = cellValue || ''
return (padding.left || '') +
padEnd(cellValue, width - padding.length() + ansiLength) +
(padding.right || '')
cellValue.padEnd(width - padding.length() + ansiLength) + (padding.right || '')
}

/**
Expand Down
2 changes: 0 additions & 2 deletions lib/ansi.js
@@ -1,5 +1,3 @@
'use strict'

const ansiEscapeSequence = /\u001b.*?m/g

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/cell.js
@@ -1,4 +1,3 @@
'use strict'
const t = require('typical')

const _value = new WeakMap()
Expand All @@ -16,7 +15,7 @@ class Cell {

get value () {
let cellValue = _value.get(this)
if (t.isFunction(cellValue)) cellValue = cellValue.call(_column.get(this))
if (typeof cellValue === 'function') cellValue = cellValue.call(_column.get(this))
if (cellValue === undefined) {
cellValue = ''
} else {
Expand Down
1 change: 0 additions & 1 deletion lib/column.js
@@ -1,4 +1,3 @@
'use strict'
const t = require('typical')
const Padding = require('./padding')

Expand Down
1 change: 0 additions & 1 deletion lib/columns.js
@@ -1,4 +1,3 @@
'use strict'
const t = require('typical')
const arrayify = require('array-back')
const Column = require('./column')
Expand Down
2 changes: 0 additions & 2 deletions lib/padding.js
@@ -1,5 +1,3 @@
'use strict'

class Padding {
constructor (padding) {
this.left = padding.left
Expand Down
3 changes: 1 addition & 2 deletions lib/rows.js
@@ -1,4 +1,3 @@
'use strict'
const arrayify = require('array-back')
const Cell = require('./cell')
const t = require('typical')
Expand Down Expand Up @@ -29,7 +28,7 @@ class Rows {
const emptyColumns = distinctColumnNames.filter(columnName => {
const hasValue = data.some(row => {
const value = row[columnName]
return (t.isDefined(value) && !t.isString(value)) || (t.isString(value) && /\S+/.test(value))
return (t.isDefined(value) && typeof value !== 'string') || (typeof value === 'string' && /\S+/.test(value))
})
return !hasValue
})
Expand Down

0 comments on commit c6d34bb

Please sign in to comment.