Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add character length dictionary for string length computation in console #431

Merged
merged 3 commits into from
Aug 24, 2022

Conversation

mkah91
Copy link
Contributor

@mkah91 mkah91 commented Aug 23, 2022

👀What is this pr about?

The PR introduces an optional charLength dictionary in the findWidthInConsole method that is used to compute the length of a string in console. With that dictionary you can assign a certain length to a character or a string.

🚀 Changes

Fixed

#389
#430

🖼 Screenshots

const bundle = new Table({
  title: 'Bundle (BUNDLENAME)',
  columns: [
    { name: 'Weapon' },
    { name: 'Chroma' },
    { name: 'Quality' },
    { name: 'Price' },
  ],
+ charLength: { '👍': 2, '✅': 2 },
})

bundle.addRows([
  {
    Weapon: '👍',
    Chroma: '✅',
    Quality: 'Deluxe',
    Price: '1 775 VP',
  },
])

bundle.printTable()
Before After
image image

@ayonious ayonious merged commit 89f6db2 into ayonious:master Aug 24, 2022
@ayonious
Copy link
Owner

LGTM

@ayonious
Copy link
Owner

Thanks a lot @mkah91

ayonious pushed a commit that referenced this pull request Aug 24, 2022
## [2.11.1](v2.11.0...v2.11.1) (2022-08-24)

### Bug Fixes

* add character length dictionary for string length computation in console  ([#431](#431)) ([89f6db2](89f6db2))
* dont allow negative numbers in string.repeat ([#422](#422)) ([c9e8994](c9e8994))
* Fix color resetting for borders ([#428](#428)) ([bcb6e8c](bcb6e8c))
@ayonious
Copy link
Owner

🎉 This PR is included in version 2.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markg85
Copy link

markg85 commented Aug 24, 2022

This is such a cool fix! Really makes tables smile back, hehehe

@mkah91 mkah91 deleted the add-character-length-substitution branch August 29, 2022 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants