Skip to content

Commit 1d6f3ba

Browse files
Null and undefined cells support added (#3)
* initial release * test data fixes * null and undefined cell support added
1 parent cda55bf commit 1d6f3ba

8 files changed

Lines changed: 129 additions & 115 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 1.0.1
2+
3+
- Added `null` and `undefined` types for header, rows and footer cells.
4+
15
### 1.0.0
26

37
- Initial release

README.md

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ This gives you the following table on console:
8989

9090
### Table methods
9191

92+
###### Note
93+
94+
```ts
95+
type Cell = string | number | null | undefined;
96+
```
97+
9298
#### getHeader
9399

94100
Gets header of the table.
@@ -98,7 +104,7 @@ table.getHeader();
98104
```
99105

100106
```ts
101-
() => (string | number)[];
107+
() => Cell[];
102108
```
103109

104110
#### setHeader
@@ -110,12 +116,12 @@ table.setHeader(['Name', 'Age', 'City']);
110116
```
111117

112118
```ts
113-
(header: (string | number)[]) => void;
119+
(header: Cell[]) => void;
114120
```
115121

116-
| Argument | Required | Description |
117-
|----------|----------|-----------------------------------|
118-
| `header` | Yes | Header to be settled to the table |
122+
| Argument | Required | Description |
123+
|----------|----------|---------------------------------------|
124+
| `header` | Yes | The header to be settled to the table |
119125

120126
#### getFooter
121127

@@ -126,7 +132,7 @@ table.getFooter();
126132
```
127133

128134
```ts
129-
() => (string | number)[];
135+
() => Cell[];
130136
```
131137

132138
#### setFooter
@@ -138,12 +144,12 @@ table.setFooter(['Name', 'Age', 'City']);
138144
```
139145

140146
```ts
141-
(footer: (string | number)[]) => void;
147+
(footer: Cell[]) => void;
142148
```
143149

144-
| Argument | Required | Description |
145-
|----------|----------|-----------------------------------|
146-
| `footer` | Yes | Footer to be settled to the table |
150+
| Argument | Required | Description |
151+
|----------|----------|---------------------------------------|
152+
| `footer` | Yes | The footer to be settled to the table |
147153

148154

149155
#### getRows
@@ -155,7 +161,7 @@ table.getRows();
155161
```
156162

157163
```ts
158-
() => (string | number)[][];
164+
() => Cell[][];
159165
```
160166

161167
#### getRow
@@ -167,12 +173,12 @@ table.getRow(index);
167173
```
168174

169175
```ts
170-
(index: number) => (string | number)[];
176+
(index: number) => Cell[];
171177
```
172178

173-
| Argument | Required | Description |
174-
|----------|----------|------------------|
175-
| `index` | Yes | Index of the row |
179+
| Argument | Required | Description |
180+
|----------|----------|----------------------|
181+
| `index` | Yes | The index of the row |
176182

177183
#### addRows
178184

@@ -186,12 +192,12 @@ table.addRows([
186192
```
187193

188194
```ts
189-
(rows: (string | number)[][]) => void;
195+
(rows: Cell[][]) => void;
190196
```
191197

192-
| Argument | Required | Description |
193-
|----------|----------|--------------|
194-
| `rows` | Yes | List of rows |
198+
| Argument | Required | Description |
199+
|----------|----------|------------------|
200+
| `rows` | Yes | The list of rows |
195201

196202
#### addRow
197203

@@ -202,12 +208,12 @@ table.addRow(['first row', 'value']);
202208
```
203209

204210
```ts
205-
(row: (string | number)[]) => void;
211+
(row: Cell[]) => void;
206212
```
207213

208214
| Argument | Required | Description |
209215
|----------|----------|-------------|
210-
| `row` | Yes | Row |
216+
| `row` | Yes | The row |
211217

212218
#### deleteRow
213219

@@ -221,9 +227,9 @@ table.deleteRow(4);
221227
(index: number) => void;
222228
```
223229

224-
| Argument | Required | Description |
225-
|----------|----------|------------------------|
226-
| `index` | Yes | Row index for deletion |
230+
| Argument | Required | Description |
231+
|----------|----------|----------------------------|
232+
| `index` | Yes | The row index for deletion |
227233

228234
#### toString
229235

@@ -258,7 +264,7 @@ table.toJson();
258264
```
259265

260266
```ts
261-
() => Record<string | number, string | number>[];
267+
() => Record<string | number, Cell>[];
262268
```
263269

264270
#### clone
@@ -287,17 +293,17 @@ const table = PrettyTable.from(
287293

288294
```ts
289295
(
290-
header?: (string | number)[] | null,
291-
rows?: (string | number)[][] | null,
292-
footer?: (string | number)[] | null,
296+
header?: Cell[] | null,
297+
rows?: Cell[][] | null,
298+
footer?: Cell[] | null,
293299
) => PrettyTable;
294300
```
295301

296-
| Argument | Required | Default | Description |
297-
|----------|----------|---------|---------------------|
298-
| `header` | No | `null` | Header of the table |
299-
| `rows` | No | `null` | List of table rows |
300-
| `footer` | No | `null` | Footer of the table |
302+
| Argument | Required | Default | Description |
303+
|----------|----------|---------|-------------------------|
304+
| `header` | No | `null` | The header of the table |
305+
| `rows` | No | `null` | The list of table rows |
306+
| `footer` | No | `null` | The footer of the table |
301307

302308
#### static fromCsv
303309

@@ -311,10 +317,10 @@ const table = PrettyTable.fromCsv(csvFile, { header: true });
311317
(file: string | Buffer, options?: { header?: boolean; footer?: boolean; }) => PrettyTable;
312318
```
313319

314-
| Argument | Required | Default | Description |
315-
|-----------|----------|-----------------------------------|----------------------|
316-
| `file` | Yes | N\A | Content of CSV |
317-
| `options` | No | `{ header: true, footer: false }` | Options of CSV table |
320+
| Argument | Required | Default | Description |
321+
|-----------|----------|-----------------------------------|--------------------------|
322+
| `file` | Yes | N\A | The content of CSV |
323+
| `options` | No | `{ header: true, footer: false }` | The options of CSV table |
318324

319325
#### static fromJson
320326

@@ -346,12 +352,12 @@ const table = PrettyTable.fromJson([
346352
```
347353

348354
```ts
349-
(json: Record<string | number, string | number>[]) => PrettyTable;
355+
(json: Record<string | number, Cell>[]) => PrettyTable;
350356
```
351357

352-
| Argument | Required | Description |
353-
|----------|----------|-----------------|
354-
| `json` | Yes | Content of JSON |
358+
| Argument | Required | Description |
359+
|----------|----------|---------------------|
360+
| `json` | Yes | The content of JSON |
355361

356362
## License
357363

package-lock.json

Lines changed: 46 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)