Skip to content

Commit d62b369

Browse files
committed
New method logBottom
1 parent c79616f commit d62b369

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/class/SimpleTable.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5700,4 +5700,27 @@ export default class SimpleTable extends Simple {
57005700
console.log(`\nTable ${this.name}: ${formatNumber(nbRows)} rows.`);
57015701
return await this;
57025702
}
5703+
5704+
/**
5705+
* Logs the bottom n rows. Note that the order is inverted. The last rows are logged first.
5706+
*
5707+
* @example
5708+
* Basic usage
5709+
* ```ts
5710+
* await table.logBottom(10)
5711+
* ```
5712+
*
5713+
* @param count - The number of rows to log.
5714+
*/
5715+
async logBottom(
5716+
count: number,
5717+
) {
5718+
console.log(`\nTable ${this.name} (${count} bottom rows):`);
5719+
const data = await this.getBottom(count);
5720+
logData(
5721+
null,
5722+
data,
5723+
this.nbCharactersToLog,
5724+
);
5725+
}
57035726
}

test/unit/methods/logBottom.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { assertEquals } from "jsr:@std/assert";
2+
import SimpleDB from "../../../src/class/SimpleDB.ts";
3+
4+
Deno.test("should log the last rows", async () => {
5+
const sdb = new SimpleDB();
6+
const table = sdb.newTable();
7+
await table.loadData("test/data/files/employees.csv");
8+
await table.logBottom(5);
9+
10+
// How to test?
11+
assertEquals(true, true);
12+
await sdb.done();
13+
});

0 commit comments

Comments
 (0)