/ src / bindings / Deno.res
Deno.res
 1  // SPDX-License-Identifier: AGPL-3.0-or-later
 2  // SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell
 3  // Deno FFI bindings for deno-bunbridge
 4  
 5  type arrayBuffer
 6  
 7  @val external denoVersion: string = "Deno.version.deno"
 8  
 9  module File = {
10    @val external readTextFile: string => promise<string> = "Deno.readTextFile"
11    @val external readFile: string => promise<Js.TypedArray2.Uint8Array.t> = "Deno.readFile"
12    @val external writeTextFile: (string, string) => promise<unit> = "Deno.writeTextFile"
13    @val external writeFile: (string, Js.TypedArray2.Uint8Array.t) => promise<unit> = "Deno.writeFile"
14  }
15  
16  module Stat = {
17    type t = {
18      size: int,
19      isFile: bool,
20      isDirectory: bool,
21    }
22  
23    @val external stat: string => promise<t> = "Deno.stat"
24  }
25  
26  module Command = {
27    type options = {
28      args?: array<string>,
29      cwd?: string,
30      env?: Dict.t<string>,
31      stdin?: string,
32      stdout?: string,
33      stderr?: string,
34    }
35  
36    type output = {
37      code: int,
38      stdout: Js.TypedArray2.Uint8Array.t,
39      stderr: Js.TypedArray2.Uint8Array.t,
40    }
41  
42    @new external make: (string, options) => 'command = "Deno.Command"
43    @send external outputSync: 'command => output = "outputSync"
44    @send external spawn: 'command => 'process = "spawn"
45  }
46  
47  module Serve = {
48    type options = {
49      port?: int,
50      hostname?: string,
51    }
52  
53    type server = {shutdown: unit => unit}
54  
55    @val external serve: (options, Request.t => promise<Response.t>) => server = "Deno.serve"
56  }