Skip to content

Commit

Permalink
prepare for jsr
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmaSd committed Apr 6, 2024
1 parent 5406e4d commit c6eacda
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (import.meta.main) {

let frameNum = 0;
for await (const frame of stream.next({ delay: 100 })) {
if (frameNum == 5) break;
if (frameNum === 5) break;
writeBufferAsPPM(++frameNum, formatInfo.width, formatInfo.height, frame);
console.log(`Written frame to frame_${frameNum}.ppm`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class Stream {
* @param delay - Delay between frame captures in milliseconds.
* @returns An asynchronous generator yielding frames.
*/
async *next({ delay = 100 } = {}) {
async *next({ delay = 100 } = {}): AsyncGenerator<Uint8Array, void, unknown> {
while (true) {
while (true) {
if (this.#pnp.hasNewFrame(this.#streamId)) break;
Expand Down
4 changes: 2 additions & 2 deletions src/ffi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,12 @@ const SYMBOLS = {
parameters: [CapContext, CapStream],
result: "u32",
},
} satisfies Deno.ForeignLibraryInterface;
} as const;

/**
* Represents the dynamic library instance.
*/
export const LIBRARY = await instantiate();
export const LIBRARY: Deno.DynamicLibrary<typeof SYMBOLS> = await instantiate();

/**
* Instantiates the dynamic library.
Expand Down
4 changes: 1 addition & 3 deletions src/openpnp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,11 @@ export class OpenPnp {
* Captures a frame from the stream.
* @param id - The ID of the stream.
* @param buffer - The buffer to store the frame.
* @returns The captured frame.
*/
captureFrame(
id: number,
buffer: Uint8Array,
) {
): void {
const res = LIBRARY.symbols.Cap_captureFrame(
this.#ctx,
id,
Expand All @@ -295,7 +294,6 @@ export class OpenPnp {
if (res !== CAPRESULT_OK) {
throw new Error("Cap_captureFrame failed");
}
return buffer;
}

/**
Expand Down

0 comments on commit c6eacda

Please sign in to comment.