bun-types-no-globals 1.3.7-canary.20260121T141246 → 1.3.7-canary.20260123T141002

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/lib/bun.d.ts +109 -3
  2. package/package.json +1 -1
package/lib/bun.d.ts CHANGED
@@ -743,6 +743,101 @@ declare module "bun" {
743
743
  export function parse(input: string): unknown;
744
744
  }
745
745
 
746
+ /**
747
+ * JSONL (JSON Lines) related APIs.
748
+ *
749
+ * Each line in the input is expected to be a valid JSON value separated by newlines.
750
+ */
751
+ namespace JSONL {
752
+ /**
753
+ * The result of `Bun.JSONL.parseChunk`.
754
+ */
755
+ interface ParseChunkResult {
756
+ /** The successfully parsed JSON values. */
757
+ values: unknown[];
758
+ /** How far into the input was consumed. When the input is a string, this is a character offset. When the input is a `TypedArray`, this is a byte offset. Use `input.slice(read)` or `input.subarray(read)` to get the unconsumed remainder. */
759
+ read: number;
760
+ /** `true` if all input was consumed successfully. `false` if the input ends with an incomplete value or a parse error occurred. */
761
+ done: boolean;
762
+ /** A `SyntaxError` if a parse error occurred, otherwise `null`. Values parsed before the error are still available in `values`. */
763
+ error: SyntaxError | null;
764
+ }
765
+
766
+ /**
767
+ * Parse a JSONL (JSON Lines) string into an array of JavaScript values.
768
+ *
769
+ * If a parse error occurs and no values were successfully parsed, throws
770
+ * a `SyntaxError`. If values were parsed before the error, returns the
771
+ * successfully parsed values without throwing.
772
+ *
773
+ * Incomplete trailing values (e.g. from a partial chunk) are silently
774
+ * ignored and not included in the result.
775
+ *
776
+ * When a `TypedArray` is passed, the bytes are parsed directly without
777
+ * copying if the content is ASCII.
778
+ *
779
+ * @param input The JSONL string or typed array to parse
780
+ * @returns An array of parsed values
781
+ * @throws {SyntaxError} If the input starts with invalid JSON and no values could be parsed
782
+ *
783
+ * @example
784
+ * ```js
785
+ * const items = Bun.JSONL.parse('{"a":1}\n{"b":2}\n');
786
+ * // [{ a: 1 }, { b: 2 }]
787
+ *
788
+ * // From a Uint8Array (zero-copy for ASCII):
789
+ * const buf = new TextEncoder().encode('{"a":1}\n{"b":2}\n');
790
+ * const items = Bun.JSONL.parse(buf);
791
+ * // [{ a: 1 }, { b: 2 }]
792
+ *
793
+ * // Partial results on error after valid values:
794
+ * const partial = Bun.JSONL.parse('{"a":1}\n{bad}\n');
795
+ * // [{ a: 1 }]
796
+ *
797
+ * // Throws when no valid values precede the error:
798
+ * Bun.JSONL.parse('{bad}\n'); // throws SyntaxError
799
+ * ```
800
+ */
801
+ export function parse(input: string | NodeJS.TypedArray | DataView<ArrayBuffer> | ArrayBufferLike): unknown[];
802
+
803
+ /**
804
+ * Parse a JSONL chunk, designed for streaming use.
805
+ *
806
+ * Never throws on parse errors. Instead, returns whatever values were
807
+ * successfully parsed along with an `error` property containing the
808
+ * `SyntaxError` (or `null` on success). Use `read` to determine how
809
+ * much input was consumed and `done` to check if all input was parsed.
810
+ *
811
+ * When a `TypedArray` is passed, the bytes are parsed directly without
812
+ * copying if the content is ASCII. Optional `start` and `end` parameters
813
+ * allow slicing without copying, and `read` will be a byte offset into
814
+ * the original typed array.
815
+ *
816
+ * @param input The JSONL string or typed array to parse
817
+ * @param start Byte offset to start parsing from (typed array only, default: 0)
818
+ * @param end Byte offset to stop parsing at (typed array only, default: input.byteLength)
819
+ * @returns An object with `values`, `read`, `done`, and `error` properties
820
+ *
821
+ * @example
822
+ * ```js
823
+ * let buffer = new Uint8Array(0);
824
+ * for await (const chunk of stream) {
825
+ * buffer = Buffer.concat([buffer, chunk]);
826
+ * const { values, read, error } = Bun.JSONL.parseChunk(buffer);
827
+ * if (error) throw error;
828
+ * for (const value of values) handle(value);
829
+ * buffer = buffer.subarray(read);
830
+ * }
831
+ * ```
832
+ */
833
+ export function parseChunk(input: string): ParseChunkResult;
834
+ export function parseChunk(
835
+ input: NodeJS.TypedArray | DataView<ArrayBuffer> | ArrayBufferLike,
836
+ start?: number,
837
+ end?: number,
838
+ ): ParseChunkResult;
839
+ }
840
+
746
841
  /**
747
842
  * YAML related APIs
748
843
  */
@@ -1745,6 +1840,17 @@ declare module "bun" {
1745
1840
  * @default "warn"
1746
1841
  */
1747
1842
  logLevel?: "verbose" | "debug" | "info" | "warn" | "error";
1843
+
1844
+ /**
1845
+ * Enable REPL mode transforms:
1846
+ * - Wraps top-level inputs that appear to be object literals (inputs starting with '{' without trailing ';') in parentheses
1847
+ * - Hoists all declarations as var for REPL persistence across vm.runInContext calls
1848
+ * - Wraps last expression in { __proto__: null, value: expr } for result capture
1849
+ * - Wraps code in sync/async IIFE to avoid parentheses around object literals
1850
+ *
1851
+ * @default false
1852
+ */
1853
+ replMode?: boolean;
1748
1854
  }
1749
1855
 
1750
1856
  /**
@@ -1851,7 +1957,7 @@ declare module "bun" {
1851
1957
  type Architecture = "x64" | "arm64";
1852
1958
  type Libc = "glibc" | "musl";
1853
1959
  type SIMD = "baseline" | "modern";
1854
- type Target =
1960
+ type CompileTarget =
1855
1961
  | `bun-darwin-${Architecture}`
1856
1962
  | `bun-darwin-x64-${SIMD}`
1857
1963
  | `bun-linux-${Architecture}`
@@ -2193,7 +2299,7 @@ declare module "bun" {
2193
2299
  }
2194
2300
 
2195
2301
  interface CompileBuildOptions {
2196
- target?: Bun.Build.Target;
2302
+ target?: Bun.Build.CompileTarget;
2197
2303
  execArgv?: string[];
2198
2304
  executablePath?: string;
2199
2305
  outfile?: string;
@@ -2275,7 +2381,7 @@ declare module "bun" {
2275
2381
  * });
2276
2382
  * ```
2277
2383
  */
2278
- compile: boolean | Bun.Build.Target | CompileBuildOptions;
2384
+ compile: boolean | Bun.Build.CompileTarget | CompileBuildOptions;
2279
2385
 
2280
2386
  /**
2281
2387
  * Splitting is not currently supported with `.compile`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-types-no-globals",
3
- "version": "1.3.7-canary.20260121T141246",
3
+ "version": "1.3.7-canary.20260123T141002",
4
4
  "main": "./generator/index.ts",
5
5
  "types": "./lib/index.d.ts",
6
6
  "description": "TypeScript type definitions for Bun without global types pollution",