New Features
Bun.cron — OS-Level Cron Jobs
Bun now includes a built-in Bun.cron API for registering OS-level scheduled jobs that work cross-platform:
- Register jobs using standard cron syntax that integrates with native schedulers (crontab on Linux, launchd on macOS, Task Scheduler on Windows)
- Parse cron expressions with
Bun.cron.parse()to determine next execution times, supporting standard 5-field format, named days/months (MON–SUN,JAN–DEC), and nicknames like@yearlyand@hourly - Remove jobs with
Bun.cron.remove()using job titles - Jobs trigger a
scheduled()export following the Cloudflare Workers Cron Triggers API
Re-registering with the same title overwrites the existing job in place, and platform-specific logging is available through standard system tools.
Bun.sliceAnsi — Terminal-Aware String Slicing
A new built-in that eliminates the need for the slice-ansi and cli-truncate npm packages. Bun.sliceAnsi provides:
- ANSI-aware slicing that preserves SGR color codes and OSC 8 hyperlinks while slicing by terminal column width
- Grapheme cluster support for correct handling of emoji, combining marks, and flag sequences
- Truncation with ellipsis that emits the truncation marker inside active styles for visual consistency but outside hyperlinks to prevent broken links
- Negative index support for slicing from the end of strings
Performance uses a three-tier strategy: SIMD fast path for ASCII, single-pass streaming for non-negative indices, and two-pass computation for negative indices.
Enhanced Markdown List Rendering
The Bun.markdown.render() API now passes richer metadata to list callbacks:
listItemcallbacks receiveindex,depth,ordered, andstartproperties, enabling custom nested numbering schemes (e.g.,1.,a.,i.) without post-processinglistcallbacks now include thedepthproperty
Breaking change: The listItem callback now always receives a meta object; previously it was only passed for task list items. Use conditional checks on start and checked (which are undefined when not applicable) to handle different list types.
Improvements
--path-ignore-patterns for test discovery — Exclude files and directories from bun test using glob patterns, either via the new command-line flag or test.pathIgnorePatterns in bunfig.toml. Matched directories are pruned during scanning for efficiency.
UDP socket fixes on macOS — Fixed three bugs in dgram UDP socket creation that caused silent failures on macOS, including proper reusePort support.