Comparing version 5.2.3 to 5.3.0
@@ -59,3 +59,3 @@ "use strict"; | ||
// eslint-disable-next-line no-control-regex | ||
if (/[\u0001-\u0009\u000B-\u001A]/.test(cell)) { | ||
if (/[\u0001-\u0006\u0008-\u0009\u000B-\u001A]/.test(cell)) { | ||
throw new Error('Table data must not contain control characters.'); | ||
@@ -62,0 +62,0 @@ } |
@@ -82,3 +82,3 @@ { | ||
}, | ||
"version": "5.2.3" | ||
"version": "5.3.0" | ||
} |
285
README.md
@@ -12,2 +12,3 @@ <a name="table"></a> | ||
* [Features](#table-features) | ||
* [Install](#table-install) | ||
* [Usage](#table-usage) | ||
@@ -40,2 +41,13 @@ * [Cell Content Alignment](#table-usage-cell-content-alignment) | ||
<a name="table-install"></a> | ||
## Install | ||
```bash | ||
npm install table | ||
``` | ||
[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/gajus) | ||
[![Become a Patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/gajus) | ||
<a name="table-usage"></a> | ||
@@ -137,2 +149,3 @@ ## Usage | ||
╚════╧════╧════╝ | ||
``` | ||
@@ -150,26 +163,26 @@ | ||
let config, | ||
data, | ||
output; | ||
data, | ||
output; | ||
data = [ | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
]; | ||
config = { | ||
columns: { | ||
0: { | ||
alignment: 'left', | ||
minWidth: 10 | ||
}, | ||
1: { | ||
alignment: 'center', | ||
minWidth: 10 | ||
}, | ||
2: { | ||
alignment: 'right', | ||
minWidth: 10 | ||
} | ||
columns: { | ||
0: { | ||
alignment: 'left', | ||
minWidth: 10 | ||
}, | ||
1: { | ||
alignment: 'center', | ||
minWidth: 10 | ||
}, | ||
2: { | ||
alignment: 'right', | ||
minWidth: 10 | ||
} | ||
} | ||
}; | ||
@@ -199,17 +212,17 @@ | ||
let data, | ||
output, | ||
options; | ||
output, | ||
options; | ||
data = [ | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
]; | ||
options = { | ||
columns: { | ||
1: { | ||
width: 10 | ||
} | ||
columns: { | ||
1: { | ||
width: 10 | ||
} | ||
} | ||
}; | ||
@@ -239,32 +252,32 @@ | ||
let config, | ||
data, | ||
output; | ||
data, | ||
output; | ||
data = [ | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
]; | ||
config = { | ||
border: { | ||
topBody: `─`, | ||
topJoin: `┬`, | ||
topLeft: `┌`, | ||
topRight: `┐`, | ||
border: { | ||
topBody: `─`, | ||
topJoin: `┬`, | ||
topLeft: `┌`, | ||
topRight: `┐`, | ||
bottomBody: `─`, | ||
bottomJoin: `┴`, | ||
bottomLeft: `└`, | ||
bottomRight: `┘`, | ||
bottomBody: `─`, | ||
bottomJoin: `┴`, | ||
bottomLeft: `└`, | ||
bottomRight: `┘`, | ||
bodyLeft: `│`, | ||
bodyRight: `│`, | ||
bodyJoin: `│`, | ||
bodyLeft: `│`, | ||
bodyRight: `│`, | ||
bodyJoin: `│`, | ||
joinBody: `─`, | ||
joinLeft: `├`, | ||
joinRight: `┤`, | ||
joinJoin: `┼` | ||
} | ||
joinBody: `─`, | ||
joinLeft: `├`, | ||
joinRight: `┤`, | ||
joinJoin: `┼` | ||
} | ||
}; | ||
@@ -294,23 +307,23 @@ | ||
let data, | ||
output, | ||
options; | ||
output, | ||
options; | ||
data = [ | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'], | ||
['3A', '3B', '3C'], | ||
['4A', '4B', '4C'] | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'], | ||
['3A', '3B', '3C'], | ||
['4A', '4B', '4C'] | ||
]; | ||
options = { | ||
/** | ||
* @typedef {function} drawHorizontalLine | ||
* @param {number} index | ||
* @param {number} size | ||
* @return {boolean} | ||
*/ | ||
drawHorizontalLine: (index, size) => { | ||
return index === 0 || index === 1 || index === size - 1 || index === size; | ||
} | ||
/** | ||
* @typedef {function} drawHorizontalLine | ||
* @param {number} index | ||
* @param {number} size | ||
* @return {boolean} | ||
*/ | ||
drawHorizontalLine: (index, size) => { | ||
return index === 0 || index === 1 || index === size - 1 || index === size; | ||
} | ||
}; | ||
@@ -344,21 +357,21 @@ | ||
let config, | ||
data, | ||
output; | ||
data, | ||
output; | ||
data = [ | ||
['0A', 'AABBCC', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
['0A', 'AABBCC', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
]; | ||
config = { | ||
columns: { | ||
0: { | ||
paddingLeft: 3 | ||
}, | ||
1: { | ||
width: 2, | ||
paddingRight: 3 | ||
} | ||
columns: { | ||
0: { | ||
paddingLeft: 3 | ||
}, | ||
1: { | ||
width: 2, | ||
paddingRight: 3 | ||
} | ||
} | ||
}; | ||
@@ -390,17 +403,17 @@ | ||
import { | ||
table, | ||
getBorderCharacters | ||
table, | ||
getBorderCharacters | ||
} from 'table'; | ||
let config, | ||
data; | ||
data; | ||
data = [ | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
['0A', '0B', '0C'], | ||
['1A', '1B', '1C'], | ||
['2A', '2B', '2C'] | ||
]; | ||
config = { | ||
border: getBorderCharacters(`name of the template`) | ||
border: getBorderCharacters(`name of the template`) | ||
}; | ||
@@ -493,13 +506,13 @@ | ||
import { | ||
createStream | ||
createStream | ||
} from 'table'; | ||
let config, | ||
stream; | ||
stream; | ||
config = { | ||
columnDefault: { | ||
width: 50 | ||
}, | ||
columnCount: 1 | ||
columnDefault: { | ||
width: 50 | ||
}, | ||
columnCount: 1 | ||
}; | ||
@@ -510,3 +523,3 @@ | ||
setInterval(() => { | ||
stream.write([new Date()]); | ||
stream.write([new Date()]); | ||
}, 500); | ||
@@ -519,3 +532,3 @@ ``` | ||
The underlying implementation is explained in this [Stack Overflow answer](http://stackoverflow.com/a/32938658/368691). | ||
The underlying implementation is explained in this [Stack Overflow answer](http://stackoverflow.com/a/32938658/368691). | ||
@@ -526,3 +539,3 @@ Streaming supports all of the configuration properties and functionality of a static table (such as auto text wrapping, alignment and padding), e.g. | ||
import { | ||
createStream | ||
createStream | ||
} from 'table'; | ||
@@ -533,22 +546,22 @@ | ||
let config, | ||
stream, | ||
i; | ||
stream, | ||
i; | ||
config = { | ||
columnDefault: { | ||
width: 50 | ||
columnDefault: { | ||
width: 50 | ||
}, | ||
columnCount: 3, | ||
columns: { | ||
0: { | ||
width: 10, | ||
alignment: 'right' | ||
}, | ||
columnCount: 3, | ||
columns: { | ||
0: { | ||
width: 10, | ||
alignment: 'right' | ||
}, | ||
1: { | ||
alignment: 'center', | ||
}, | ||
2: { | ||
width: 10 | ||
} | ||
1: { | ||
alignment: 'center', | ||
}, | ||
2: { | ||
width: 10 | ||
} | ||
} | ||
}; | ||
@@ -561,7 +574,7 @@ | ||
setInterval(() => { | ||
let random; | ||
let random; | ||
random = _.sample('abcdefghijklmnopqrstuvwxyz', _.random(1, 30)).join(''); | ||
random = _.sample('abcdefghijklmnopqrstuvwxyz', _.random(1, 30)).join(''); | ||
stream.write([i++, new Date(), random]); | ||
stream.write([i++, new Date(), random]); | ||
}, 500); | ||
@@ -571,2 +584,3 @@ ``` | ||
![Streaming random data.](./.README/streaming-random.gif) | ||
<a name="table-usage-text-truncation"></a> | ||
@@ -581,16 +595,16 @@ ### Text Truncation | ||
let config, | ||
data, | ||
output; | ||
data, | ||
output; | ||
data = [ | ||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] | ||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] | ||
]; | ||
config = { | ||
columns: { | ||
0: { | ||
width: 20, | ||
truncate: 100 | ||
} | ||
columns: { | ||
0: { | ||
width: 20, | ||
truncate: 100 | ||
} | ||
} | ||
}; | ||
@@ -620,4 +634,4 @@ | ||
let config, | ||
data, | ||
output; | ||
data, | ||
output; | ||
@@ -629,7 +643,7 @@ data = [ | ||
config = { | ||
columns: { | ||
0: { | ||
width: 20 | ||
} | ||
columns: { | ||
0: { | ||
width: 20 | ||
} | ||
} | ||
}; | ||
@@ -659,16 +673,16 @@ | ||
let config, | ||
data, | ||
output; | ||
data, | ||
output; | ||
data = [ | ||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] | ||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.'] | ||
]; | ||
config = { | ||
columns: { | ||
0: { | ||
width: 20, | ||
wrapWord: true | ||
} | ||
columns: { | ||
0: { | ||
width: 20, | ||
wrapWord: true | ||
} | ||
} | ||
}; | ||
@@ -694,3 +708,4 @@ | ||
╚══════════════════════╝ | ||
``` | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
691
193369