bun-types 1.3.7-canary.20260115T140932 → 1.3.7-canary.20260117T140656

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bun.d.ts +91 -0
  2. package/package.json +1 -1
package/bun.d.ts CHANGED
@@ -610,6 +610,97 @@ declare module "bun" {
610
610
  */
611
611
  function stripANSI(input: string): string;
612
612
 
613
+ interface WrapAnsiOptions {
614
+ /**
615
+ * If `true`, break words in the middle if they don't fit on a line.
616
+ * If `false`, only break at word boundaries.
617
+ *
618
+ * @default false
619
+ */
620
+ hard?: boolean;
621
+
622
+ /**
623
+ * If `true`, wrap at word boundaries when possible.
624
+ * If `false`, don't perform word wrapping (only wrap at explicit newlines).
625
+ *
626
+ * @default true
627
+ */
628
+ wordWrap?: boolean;
629
+
630
+ /**
631
+ * If `true`, trim leading and trailing whitespace from each line.
632
+ * If `false`, preserve whitespace.
633
+ *
634
+ * @default true
635
+ */
636
+ trim?: boolean;
637
+
638
+ /**
639
+ * When it's ambiguous and `true`, count ambiguous width characters as 1 character wide.
640
+ * If `false`, count them as 2 characters wide.
641
+ *
642
+ * @default true
643
+ */
644
+ ambiguousIsNarrow?: boolean;
645
+ }
646
+
647
+ /**
648
+ * Wrap a string to fit within the specified column width, preserving ANSI escape codes.
649
+ *
650
+ * This function is designed to be compatible with the popular "wrap-ansi" NPM package.
651
+ *
652
+ * Features:
653
+ * - Preserves ANSI escape codes (colors, styles) across line breaks
654
+ * - Supports SGR codes (colors, bold, italic, etc.) and OSC 8 hyperlinks
655
+ * - Respects Unicode display widths (full-width characters, emoji)
656
+ * - Word wrapping at word boundaries (configurable)
657
+ *
658
+ * @category Utilities
659
+ *
660
+ * @param input The string to wrap
661
+ * @param columns The maximum column width
662
+ * @param options Wrapping options
663
+ * @returns The wrapped string
664
+ *
665
+ * @example
666
+ * ```ts
667
+ * import { wrapAnsi } from "bun";
668
+ *
669
+ * console.log(wrapAnsi("hello world", 5));
670
+ * // Output:
671
+ * // hello
672
+ * // world
673
+ *
674
+ * // Preserves ANSI colors across line breaks
675
+ * console.log(wrapAnsi("\u001b[31mhello world\u001b[0m", 5));
676
+ * // Output:
677
+ * // \u001b[31mhello\u001b[0m
678
+ * // \u001b[31mworld\u001b[0m
679
+ *
680
+ * // Hard wrap long words
681
+ * console.log(wrapAnsi("abcdefghij", 3, { hard: true }));
682
+ * // Output:
683
+ * // abc
684
+ * // def
685
+ * // ghi
686
+ * // j
687
+ * ```
688
+ */
689
+ function wrapAnsi(
690
+ /**
691
+ * The string to wrap
692
+ */
693
+ input: string,
694
+ /**
695
+ * The maximum column width
696
+ */
697
+ columns: number,
698
+ /**
699
+ * Wrapping options
700
+ */
701
+ options?: WrapAnsiOptions,
702
+ ): string;
703
+
613
704
  /**
614
705
  * TOML related APIs
615
706
  */
package/package.json CHANGED
@@ -33,5 +33,5 @@
33
33
  "bun.js",
34
34
  "types"
35
35
  ],
36
- "version": "1.3.7-canary.20260115T140932"
36
+ "version": "1.3.7-canary.20260117T140656"
37
37
  }