UNPKG

bs-platform

Version:

bucklescript compiler, ocaml standard libary by bucklescript and its required runtime support

84 lines (68 loc) 2.32 kB
import * as Caml_gc from "./caml_gc.js"; import * as Caml_io from "./caml_io.js"; import * as Pervasives from "./pervasives.js"; import * as Caml_external_polyfill from "./caml_external_polyfill.js"; import * as Caml_builtin_exceptions from "./caml_builtin_exceptions.js"; function if_spacetime_enabled(f) { } function create(path) { return { channel: Pervasives.stdout, closed: true }; } function save_event(time, t, event_name) { return if_spacetime_enabled((function (param) { return Caml_external_polyfill.resolve("caml_spacetime_only_works_for_native_code")(time, t.channel, event_name); })); } function save_and_close(time, t) { return if_spacetime_enabled((function (param) { if (t.closed) { throw [ Caml_builtin_exceptions.failure, "Series is closed" ]; } Caml_external_polyfill.resolve("caml_spacetime_only_works_for_native_code")(time, t.channel); var oc = t.channel; Caml_io.caml_ml_flush(oc); Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); t.closed = true; })); } var Series = { create: create, save_event: save_event, save_and_close: save_and_close }; function take(time, param) { var channel = param.channel; var closed = param.closed; return if_spacetime_enabled((function (param) { if (closed) { throw [ Caml_builtin_exceptions.failure, "Series is closed" ]; } Caml_gc.caml_gc_minor(undefined); return Caml_external_polyfill.resolve("caml_spacetime_only_works_for_native_code")(time, channel); })); } var Snapshot = { take: take }; function save_event_for_automatic_snapshots(event_name) { return if_spacetime_enabled((function (param) { return Caml_external_polyfill.resolve("caml_spacetime_only_works_for_native_code")(event_name); })); } var enabled = false; export { enabled , Series , Snapshot , save_event_for_automatic_snapshots , } /* No side effect */