Giter Site home page Giter Site logo

ascii-table3's People

Contributors

allmightysauron avatar osztenkurden avatar visoredkon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ascii-table3's Issues

Feat: Support for grouping cells

The library at the current time severely lacks customization. A feature I really need right now is grouping of cells. I need a table that looks something like this (hand-made as an example):

+---------------------------------------+
|                 Build                 |
+---------------------------------------+
|        x64        |        x86        |
+-------+-----------+-------+-----------+
| Name  | Time (ms) | Name  | Time (ms) |
+-------+-----------+-------+-----------+
| Total |         3 | Total |         4 |
| Deps  |         8 | Deps  |         5 |
+-------+-----------+-------+-----------+

I understand it isn't a small change to make but I would love it if you would at least consider the idea.

Thanks!

Compatibility with Bun

I try to use ascii-table3 using Bun but I got this error

ENOTDIR: Not a directory
   path: "/home/joproject0911/Code/typescript/local/unnamed-bot/node_modules/ascii-table3/src/ascii-table3.js/../ascii-table3.styles.json"
 syscall: "open"
   errno: -20

      at new AsciiTable3 (/home/joproject0911/Code/typescript/local/unnamed-bot/node_modules/ascii-table3/src/ascii-table3.js:42:33)
      at /home/joproject0911/Code/typescript/local/unnamed-bot/src/services/event.ts:15:24
      at _initialize (/home/joproject0911/Code/typescript/local/unnamed-bot/src/services/event.ts:12:24)
      at /home/joproject0911/Code/typescript/local/unnamed-bot/src/struct/client.ts:37:12
      at registerListeners (/home/joproject0911/Code/typescript/local/unnamed-bot/src/struct/client.ts:35:52)
      at /home/joproject0911/Code/typescript/local/unnamed-bot/src/struct/client.ts:31:18
      at /home/joproject0911/Code/typescript/local/unnamed-bot/src/struct/client.ts:30:37
      at processTicksAndRejections (:1:2602)

Emjoji count as 2

I use it to display scoreboard with my discord bot :
image

using this config :

 const table: AsciiTable3 = new AsciiTable3()
                .setHeading('#', 'User', 'Kiwi')
                .setAlign(1, AlignmentEnum.CENTER)
                .setAlign(2, AlignmentEnum.CENTER)
                .setAlign(3, AlignmentEnum.RIGHT)
                .addRowMatrix(results);
            table.setStyle('compact');

As you can see, the 3 first ligne isn't aligned with other ...

Emoji is count as 2, but it take 1 place when it render, so the algorithm add 1 extra space .

Bug: adding colors to cells breaks cell width sync between header & body

I wanted to have colored text in cells using chalk, which adds this type of unicode chars: \x1B[32m<text>\x1B[39m. The coloring works alright, but it breaks the column width sync between headers & body:
Sample output when all the words in the first column are colored green with chalk.green('text'):

+----------------------+--------+---------+
|       Package        | Compat | Version |
+----------------------+--------+---------+
| coveralls  | >=6    | 3.1.1   |
| mocha      | N/A    | N/A     |
| nyc        | >=8.9  | 15.1.0  |
| release-it | >=10   | 14.11.8 |
+----------------------+--------+---------+

Can't resolve 'fs in node_modules...'

Have a nice day!
I have a problem with using ascii-table3 with React. After adding the code example from basic usage and trying to npm run start my project i get warning in console: 'Module not found: Error: Can't resolve 'fs' in 'C:\Users******\WebstormProjects\untitled2\node_modules\ascii-table3\src'
ERROR in ./node_modules/ascii-table3/src/ascii-table3.js 27:11-24'.

And I did not find any decisions how to solve it. Earlier in issues you wrote that this problem was solved

Running on browser?

Hey, is there any way to run this library in the browser? Apparently it requires the fs module (not available in the browser).

Off-center column hurts my OCD :/

I just noticed during testing that the middle column is slightly off center, despite having .setAlignCenter(true)

I'll attach the code and an image for reference :)

Any advice would be great!

const { updatePosition } = require("../../prisma/levelling/functions");
var { AsciiTable3 } = require("ascii-table3");

module.exports = {
  data: {
    name: "leaderboard",
    description: "View the XP leaderboard",
    type: 1,
  },
  async execute(interaction) {
    const leaderboardData = await updatePosition();

    if (leaderboardData) {
      // Create an ASCII table with compact style
      const table = new AsciiTable3("XP Leaderboard");
      table
        .setHeading("#", "XP", "User")
        .setAlignCenter(true)
        .setStyle("unicode-round");
      //  .setStyle("unicode-mix");
      // .setStyle("unicode-single")

      leaderboardData.forEach((entry, index) => {
        table.addRow(index + 1, entry.xp, entry.user.username);
      });

      // Send the table as a message in Discord
      await interaction.reply(`\`\`\`${table.toString()}\`\`\``);
    } else if (leaderboardData.length === 0) {
      await interaction.reply({
        content: "The leaderboard is empty...",
        ephemeral: true,
      });
    } else {
      await interaction.reply({
        content: "An error occurred while updating the leaderboard.",
        ephemeral: true,
      });
    }
  },
};

Typescript doesn't recognize type file

Hello,

as #7 already started to say, this module is unusable with typescript. You need to define the class again in a d.ts file and link them correctly. This is the minimum that ts recognizes that there is an import:

package.json:

+  "types": "ascii-table3.d.ts",

ascii-table.d.ts:

declare module "ascii-table3" {
  export class AsciiTable3 {
    // list functions signatures here
  }

  // extra exports here
}

Another idea instead of manually writing the types could be the use of https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html , but this would require some changes on your import algorithm, as then it would generate a circular reference, as it doesn't know the d.ts file.

Critical dependency: the request of a dependency is an expression

hello,

trying to compile my small application using npx webpack for local use and run into this error:

WARNING in ./node_modules/ascii-table3/src/ascii-table3.js 42:49-81
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/ascii-table3/index.js 1:0-46

when I go ahead and try running my application, it gives me this error before crashing:

Error: Cannot find module '../ascii-table3.styles.json'

thanks

Ignore chars for width computation

Is it possible to exclude certain characters from the width computation? This is usefull if the table cells includes markdown syntax e.g. ** that doesn't need to be included in the maxwidth of a column.

OS License

Any chance you would consider licensing this under Apache 2 or MIT OS licenses?
We are using ascii-table in a console utility. Upon review by a client's legal department, they are asking us to remove it. I'd rather not..

Thanks for writing this library,
Kurt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.