Comparing version 1.0.49 to 1.0.50
{ | ||
"name": "as-table", | ||
"version": "1.0.49", | ||
"version": "1.0.50", | ||
"description": "A simple function that print objects / arrays as ASCII tables. Handles ANSI styling and weird 💩 Unicode emoji symbols – they won't break the layout.", | ||
@@ -5,0 +5,0 @@ "main": "build/as-table.js", |
@@ -68,3 +68,3 @@ # as-table | ||
```javascript | ||
asTable.configure ({ print: obj => (typeof obj === 'boolean') ? (obj ? 'yes' : 'no') : String (obj) }) (data) | ||
asTable.configure ({ print: x => (typeof x === 'boolean') ? (x ? 'yes' : 'no') : String (x) }) (data) | ||
``` | ||
@@ -79,2 +79,16 @@ ``` | ||
The callback also receives a field name (in case of objects) or a column index (in case of arrays): | ||
```javascript | ||
asTable = require ('as-table').configure ({ | ||
print (x, k) { | ||
if (k === 'timestamp') return new Date (obj).toGMTString() | ||
return String (k) | ||
} | ||
}) | ||
asTable ([ { name: 'A', timestamp: 1561202591572 }, | ||
{ name: 'B', timestamp: 1558524240034 } ]) | ||
``` | ||
## Obtaining a pre-configured function | ||
@@ -81,0 +95,0 @@ |
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
32045
114