stdlib-js / stdlib-js/stdlib

[RFC]: add support for pretty printing tabular data in the REPL

Đang mở
#2,067 10 bình luận 0 reaction 1 người được giao Được @Snehil-Shah nhận Xem trên GitHub
difficulty: 4 Enhancement JavaScript Needs Discussion priority: Normal REPL RFC
Ngôn ngữ chính
JavaScript
Star
6k
Fork
1.3k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
611

Mô tả

### Description

This RFC proposes adding support for displaying tabular data in the REPL. Possible signature:

```
table( data[, n] )
```

It could work in a manner similar to `head`/`tail`, where, if `n > 0`, show the first `n` rows, and, if `n < 0`, show the last `n` rows.

The function could also support options, such as maximum cell width (e.g., to enforce showing abbreviated cell contents (such as truncating long strings)).

If `data` is an array of objects, could use keys as headers. Otherwise, if array of arrays, could support providing a list of headers.

### Related Issues

No.

### Questions

- Generating ASCII tables is likely to be applicable beyond just the REPL. So one question is whether the implementation for ASCII tables should live outside the REPL (e.g., in `@stdlib/plot/ascii/table` or similar) and then the REPL would just use that package for displaying tabular data? This probably makes sense, and we'd just need to define the API surface of the ASCII table package.
- We should also support `ndarray` data.

### Other

ASCII tables are fairly common, so prior art should be relatively easy to find. For example,

- https://github.com/tecfu/tty-table
- https://github.com/sorensen/ascii-table

### Checklist

- [X] I have read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with `RFC:`.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.