IF Commons GitHub

logical/handles

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-anyfs-posix-logical FR-006

The handles of the view: what an open object holds, and the table that gives each a number. An object is written through a buffer that holds the whole of it (a store puts whole objects), so a handle has the bytes it read at open, the revision they were at (or that there was none), where the next read or write is and whether anything was written. The table is a value a program passes to the view; there is no table in the process.

import { newHandleTable, writeAt } from "./handles.ts";
writeAt(new Uint8Array([1, 2]), 4, new Uint8Array([9])).length; // 5: the gap is zeros

Source: commons/anyfs-posix/src/logical/handles.ts

4 of 14 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

logical.Basetypeno test imports it
type Base = { readonly kind: "absent" } | { readonly kind: "rev"; readonly rev: Revision };

What an open object was when it was read: no object, or the object at a revision.

logical.OpenFiletypeno test imports it
type OpenFile = {
  readonly fd: Fd;
  readonly path: PosixPath;
  readonly storePath: Path;
  readonly flags: OpenFlags;
  base: Base;
  bytes: Uint8Array;
  position: number;
  dirty: boolean;
};

An open object. Its fields change as it is read and written, and only the view changes them.

logical.HandleTabletypeno test imports it
type HandleTable = {
  /** Opens an object and gives its number. */
  open(file: Omit<OpenFile, "fd">): Fd;
  get(fd: Fd): OpenFile | undefined;
  /** Lets a number go. */
  release(fd: Fd): void;
  /** How many are open. */
  readonly size: number;
};

The open objects, by number.

logical.newHandleTablefunctionno test imports it
function newHandleTable(): HandleTable

A table with nothing open. Numbers start at 3, as a process's do after its three standard streams.

logical.writeAtfunctionno test imports it
function writeAt(bytes: Uint8Array<ArrayBufferLike>, offset: number, data: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>

The bytes with some written at an offset: past the end, the gap is zeros.

logical.resizefunctionno test imports it
function resize(bytes: Uint8Array<ArrayBufferLike>, length: number): Uint8Array<ArrayBufferLike>

The bytes made as long as asked: cut where longer, and padded with zeros where shorter.

logical.concatfunctionno test imports it
function concat(bytes: Uint8Array<ArrayBufferLike>, more: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>

The bytes with others added at the end.

Basetypeno test imports it
type Base = { readonly kind: "absent" } | { readonly kind: "rev"; readonly rev: Revision };

What an open object was when it was read: no object, or the object at a revision.

OpenFiletypeno test imports it
type OpenFile = {
  readonly fd: Fd;
  readonly path: PosixPath;
  readonly storePath: Path;
  readonly flags: OpenFlags;
  base: Base;
  bytes: Uint8Array;
  position: number;
  dirty: boolean;
};

An open object. Its fields change as it is read and written, and only the view changes them.

HandleTabletypeno test imports it
type HandleTable = {
  /** Opens an object and gives its number. */
  open(file: Omit<OpenFile, "fd">): Fd;
  get(fd: Fd): OpenFile | undefined;
  /** Lets a number go. */
  release(fd: Fd): void;
  /** How many are open. */
  readonly size: number;
};

The open objects, by number.

newHandleTablefunction
function newHandleTable(): HandleTable

A table with nothing open. Numbers start at 3, as a process's do after its three standard streams.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

writeAtfunction
function writeAt(bytes: Uint8Array<ArrayBufferLike>, offset: number, data: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>

The bytes with some written at an offset: past the end, the gap is zeros.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

resizefunction
function resize(bytes: Uint8Array<ArrayBufferLike>, length: number): Uint8Array<ArrayBufferLike>

The bytes made as long as asked: cut where longer, and padded with zeros where shorter.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

concatfunction
function concat(bytes: Uint8Array<ArrayBufferLike>, more: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>

The bytes with others added at the end.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.