Skip to content

Commit a130400

Browse files
committed
feat!: rename property/option and support separate header alignment
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 7e1b3a0 commit a130400

File tree

16 files changed

+561
-155
lines changed

16 files changed

+561
-155
lines changed

lib/node_modules/@stdlib/plot/table/unicode/README.md

Lines changed: 93 additions & 44 deletions
Large diffs are not rendered by default.

lib/node_modules/@stdlib/plot/table/unicode/benchmark/benchmark.js

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ bench( pkg+'::instantiation,data,options', function benchmark( b ) {
132132
'cornerBottomRight': '*',
133133
'corners': [ '*', '*', '*', '*' ],
134134
'format': '%d',
135+
'headerAlign': 'center',
135136
'headers': [ 'col1', 'col2', 'col3' ],
136137
'headerSeparator': '-=',
137138
'horizontalSeparatorMode': 'repeat',
@@ -146,7 +147,7 @@ bench( pkg+'::instantiation,data,options', function benchmark( b ) {
146147
'marginBottom': 4,
147148
'marginLeft': 2,
148149
'margins': [ 4, 2, 4, 2 ],
149-
'maxCellWidth': 10,
150+
'maxColumnWidth': 10,
150151
'maxWidth': 60,
151152
'paddingLeft': 2,
152153
'paddingRight': [ 2, 3, 4 ],
@@ -702,6 +703,60 @@ bench( pkg+'::set,get:format:value=array', function benchmark( b ) {
702703
b.end();
703704
});
704705

706+
bench( pkg+'::set,get:headerAlign:value=string', function benchmark( b ) {
707+
var values;
708+
var v;
709+
var i;
710+
711+
values = [
712+
'left',
713+
'center',
714+
'right'
715+
];
716+
v = new UnicodeTable();
717+
718+
b.tic();
719+
for ( i = 0; i < b.iterations; i++ ) {
720+
v.headerAlign = values[ i % values.length ];
721+
if ( !isString( v.headerAlign ) ) {
722+
b.fail( 'should return a string' );
723+
}
724+
}
725+
b.toc();
726+
if ( !isString( v.headerAlign ) ) {
727+
b.fail( 'should return a string' );
728+
}
729+
b.pass( 'benchmark finished' );
730+
b.end();
731+
});
732+
733+
bench( pkg+'::set,get:headerAlign:value=array', function benchmark( b ) {
734+
var values;
735+
var v;
736+
var i;
737+
738+
values = [
739+
[ 'left', 'right' ],
740+
[ 'center', 'right' ],
741+
[ 'left', 'center' ]
742+
];
743+
v = new UnicodeTable();
744+
745+
b.tic();
746+
for ( i = 0; i < b.iterations; i++ ) {
747+
v.headerAlign = values[ i % values.length ];
748+
if ( !isArray( v.headerAlign ) ) {
749+
b.fail( 'should return an array' );
750+
}
751+
}
752+
b.toc();
753+
if ( !isArray( v.headerAlign ) ) {
754+
b.fail( 'should return an array' );
755+
}
756+
b.pass( 'benchmark finished' );
757+
b.end();
758+
});
759+
705760
bench( pkg+'::set,get:headers', function benchmark( b ) {
706761
var values;
707762
var v;
@@ -1073,7 +1128,7 @@ bench( pkg+'::set,get:margins', function benchmark( b ) {
10731128
b.end();
10741129
});
10751130

1076-
bench( pkg+'::set,get:maxCellWidth:value=number', function benchmark( b ) {
1131+
bench( pkg+'::set,get:maxColumnWidth:value=number', function benchmark( b ) {
10771132
var values;
10781133
var v;
10791134
var i;
@@ -1088,20 +1143,20 @@ bench( pkg+'::set,get:maxCellWidth:value=number', function benchmark( b ) {
10881143

10891144
b.tic();
10901145
for ( i = 0; i < b.iterations; i++ ) {
1091-
v.maxCellWidth = values[ i % values.length ];
1092-
if ( !isNumber( v.maxCellWidth ) ) {
1146+
v.maxColumnWidth = values[ i % values.length ];
1147+
if ( !isNumber( v.maxColumnWidth ) ) {
10931148
b.fail( 'should return a number' );
10941149
}
10951150
}
10961151
b.toc();
1097-
if ( !isNumber( v.maxCellWidth ) ) {
1152+
if ( !isNumber( v.maxColumnWidth ) ) {
10981153
b.fail( 'should return a number' );
10991154
}
11001155
b.pass( 'benchmark finished' );
11011156
b.end();
11021157
});
11031158

1104-
bench( pkg+'::set,get:maxCellWidth:value=array', function benchmark( b ) {
1159+
bench( pkg+'::set,get:maxColumnWidth:value=array', function benchmark( b ) {
11051160
var values;
11061161
var v;
11071162
var i;
@@ -1116,13 +1171,13 @@ bench( pkg+'::set,get:maxCellWidth:value=array', function benchmark( b ) {
11161171

11171172
b.tic();
11181173
for ( i = 0; i < b.iterations; i++ ) {
1119-
v.maxCellWidth = values[ i % values.length ];
1120-
if ( !isArray( v.maxCellWidth ) ) {
1174+
v.maxColumnWidth = values[ i % values.length ];
1175+
if ( !isArray( v.maxColumnWidth ) ) {
11211176
b.fail( 'should return an array' );
11221177
}
11231178
}
11241179
b.toc();
1125-
if ( !isArray( v.maxCellWidth ) ) {
1180+
if ( !isArray( v.maxColumnWidth ) ) {
11261181
b.fail( 'should return an array' );
11271182
}
11281183
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/plot/table/unicode/docs/repl.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171
options.format: Array<string>|string (optional)
7272
Cell format string(s). Default: '%s'.
7373

74+
options.headerAlign: Array<string>|string|null (optional)
75+
Header cell alignment(s). Must be one of the following:
76+
77+
- left: left-aligned.
78+
- center: center-aligned.
79+
- right: right-aligned.
80+
81+
Default: 'right'.
82+
7483
options.headers: Array<string> (optional)
7584
Table headers.
7685

@@ -126,8 +135,8 @@
126135
Table margins in the order [top, right, bottom, left]. Default:
127136
[ 0, 0, 0, 0 ].
128137

129-
options.maxCellWidth: Array<integer>|integer|null (optional)
130-
Maximum cell width(s) in units of grapheme clusters (i.e., visual
138+
options.maxColumnWidth: Array<integer>|integer|null (optional)
139+
Maximum column width(s) in units of grapheme clusters (i.e., visual
131140
characters). Default: +infinity.
132141

133142
options.maxWidth: integer|null (optional)
@@ -210,6 +219,9 @@
210219
table.get( i, j )
211220
Retrieves the data for a specified table cell.
212221

222+
table.headerAlign
223+
Header cell alignment(s).
224+
213225
table.headers
214226
Table headers.
215227

@@ -258,8 +270,8 @@
258270
table.margins
259271
Table margins in the order [top, right, bottom, left].
260272

261-
table.maxCellWidth
262-
Maximum cell width.
273+
table.maxColumnWidth
274+
Maximum column width.
263275

264276
table.maxWidth
265277
Maximum table width.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var UnicodeTable = require( './../lib' );
22+
23+
// Define a data set containing emoji:
24+
var data = [
25+
[
26+
'\u001b[31mbeep\u001b[0m', // red
27+
'\u001b[1mboop\u001b[0m', // bold
28+
'\u001b[44mfoo\u001b[0m', // blue_bg
29+
'\u001b[4m\u001b[47mbar\u001b[0m\u001b[0m' // underline, white_bg
30+
]
31+
];
32+
33+
// Define column headers:
34+
var headers = [ 'A', 'B', 'C', 'D' ];
35+
36+
// Create a table:
37+
var table = new UnicodeTable( data, {
38+
'headers': headers,
39+
'rowSeparator': '-',
40+
'columnSeparator': '|',
41+
'marginLeft': 5,
42+
'marginRight': 5,
43+
'align': 'right'
44+
});
45+
46+
// Render the table:
47+
var str = table.render();
48+
console.log( str );
49+
// => '...'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var UnicodeTable = require( './../lib' );
22+
23+
// Define a data set containing emoji:
24+
var data = [
25+
[ '😀', '🙌🏼', '👩🏾‍🚀', '👑', '🐇' ],
26+
[ '🙏🏻', '👉', '👏', '🤙', '☝🏿' ]
27+
];
28+
29+
// Define column headers:
30+
var headers = [ '1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣' ];
31+
32+
// Create a table:
33+
var table = new UnicodeTable( data, {
34+
'headers': headers,
35+
'rowSeparator': '-',
36+
'columnSeparator': '|',
37+
'cellWidth': 10,
38+
'marginLeft': 5,
39+
'marginRight': 5,
40+
'align': 'right'
41+
});
42+
43+
// Render the table:
44+
var str = table.render();
45+
console.log( str );
46+
// => '...'

lib/node_modules/@stdlib/plot/table/unicode/examples/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ var table = new UnicodeTable( data, {
3939
'marginLeft': 5,
4040
'marginRight': 5,
4141
'align': 'right',
42+
'headerAlign': [
43+
'left',
44+
'center',
45+
'right',
46+
'center',
47+
'left'
48+
],
4249
'format': '%0.5f'
4350
});
4451

lib/node_modules/@stdlib/plot/table/unicode/lib/defaults.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ function defaults() {
109109
// Cell format string:
110110
out.format = [ '%s' ];
111111

112+
// Header alignment:
113+
out.headerAlign = null;
114+
112115
// Column headers:
113116
out.headers = null;
114117

@@ -159,8 +162,8 @@ function defaults() {
159162
// Table margins:
160163
out.margins = [ 0, 0, 0, 0 ];
161164

162-
// Maximum cell width:
163-
out.maxCellWidth = [ FLOAT64_MAX ];
165+
// Maximum column width:
166+
out.maxColumnWidth = [ FLOAT64_MAX ];
164167

165168
// Maximum table width:
166169
out.maxWidth = FLOAT64_MAX;

0 commit comments

Comments
 (0)