Migrate typescript#19
Open
utix wants to merge 4 commits into
Open
Conversation
- Replace CoffeeScript source with TypeScript (src/babar.ts, buckets.ts, draw.ts, types.ts, validate.ts) - Replace `colors` with `chalk` (no String.prototype mutation) - Add input validation with clear error messages (empty array, non-finite values, bad options) - Fix crash bugs: diffX=0, diff=0, numBkts=1 division by zero - Upgrade partial bar rendering from 2 levels (▄) to 8 levels (▁▂▃▄▅▆▇█) - Restore horizontal grid lines (_) above bars, matching original behavior - Add 48 unit and integration tests with Vitest - Add advanced.js example covering 13 corner cases - Bump version to 0.3.0 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…is, and horizontal bars - aggregation option: avg (default), sum, min, max, last, count - yScale option: linear (default) or log for exponential data - refY option: draws a ╌ threshold line at a given Y value (| in ascii mode) - Categorical X axis: accept [string, number][] points with named buckets - direction option: horizontal renders bars left-to-right with 8-level ▏▎▍▌▋▊▉█ chars - Horizontal mode supports refY as a vertical reference column - Categorical + horizontal combined: leaderboard-style charts - All features combinable (e.g. categorical + log + horizontal + refY) - 28 new tests covering all features and error cases - features.js example demonstrating all 8 feature combinations Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
maxLabelW was computed only from minX, so single-digit x values (0, 2) produced narrower labels than double-digit ones (10, 12), shifting bar start positions. Now measured across all generated x labels. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Add src/ansi.ts: 15-line ANSI colorize/bold replacing chalk entirely - Switch build from tsc (JS emit) to esbuild --bundle --minify for lib/babar.js - tsc now only emits .d.ts declarations (emitDeclarationOnly: true) - Remove chalk from dependencies (bundled → zero runtime deps) - Bundle size: 31KB → 9.3KB (same as original CoffeeScript output) - lib/ output: single babar.js + .d.ts files only (no .js.map, no sub-modules) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewrite in TypeScript + new charting features
Summary
Complete rewrite of the library from CoffeeScript to TypeScript, with new rendering capabilities, input validation, a test suite, and a significantly smaller bundle.
What changed
Core rewrite
Rendering improvements
New options
avgsumminmaxlastcountlinearlognumberverticalhorizontal[string, number][]Quality
Breaking changes
None — same function signature babar(points, options?), same option names, same return type.
Closes #8
Closes #12
Closes #13