IO

An Agnostic Implementation for IO Operations

Specifications

Runtime

  • Bun
  • Deno
  • Node

Methods

textOf

  • If the file is not found or fails, it returns null.
import { wrap } from "vixeny";

wrap()()
  .customPetition({
    path: "/getPackage",
    f: async ({ io }) => {
      const file = await io.textOf("./package.json");

      return new Response(file, {
        status: file ? 200 : 404,
      });
    },
  });

writeText

  • Returns a boolean after the operation is completed.
  • It cannot throw an error.
import { wrap } from "vixeny";

wrap()()
  .customPetition({
    path: "/write",
    f: async ({ io }) => {
      // Returns boolean
      const wasWritten = await io.writeText("./file")("hello world!");

      return new Response(null, {
        status: wasWritten ? 200 : 400,
      });
    },
  });

List

Crypto

If crypto with at least a globalKey is present.