javy

0.1.2 • Public • Published

Javy Lib

This library provides abstractions and convenience methods over Javy's built-in functions.

In javy/fs:

readFileSync(fd)

Returns a Uint8Array representation (a byte array) of the contents of a file descriptor.

writeFileSync(fd, buffer)

Writes the contents of a Uint8Array to a file descriptor.

STDIO

Has Stdin, Stdout, and Stderr properties which correspond to the integer file descriptors for standard input, standard output, and standard error for use with readFileSync and writeFileSync.

Usage example

import { readFileSync, writeFileSync, STDIO } from `javy/fs`

const textEncoder = new TextEncoder();

const inputBuffer = readFileSync(STDIO.Stdin);
const inputText = new TextDecoder().decode(inputBuffer);

const stdoutContent = `${inputText} -- out`;
const stderrContent = `${inputText} -- err`;

writeFileSync(STDIO.Stdout, textEncoder.encode(stdoutContent));
writeFileSync(STDIO.Stderr, textEncoder.encode(stderrContent));

Tests

To run the tests, run npm test. It requires you to have a release build of javy and have wasmtime installed.

Publishing

Run npm run build before running npm publish.

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i javy

    Weekly Downloads

    6,578

    Version

    0.1.2

    License

    Apache-2.0

    Unpacked Size

    13.4 kB

    Total Files

    18

    Last publish

    Collaborators

    • saulecabrera
    • surma
    • jeffcharles-shopify