Skip to content

Commit

Permalink
type: add client type
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceat committed Aug 9, 2024
1 parent d998dd1 commit 82a650c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { fromBinary, fromJson, toBinary, toJson } from '@bufbuild/protobuf'

import * as Packets from '../generated/ares_pb.js'

/** @typedef {ReturnType<create_client>} Client */

export function create_client({ socket_write, socket_end }) {
const controller = new AbortController()
const stream = new PassThrough({
Expand Down
2 changes: 2 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface TypedEmitter<T extends EventMap> {
removeAllListeners(): this
}

type Client = import('./index').Client

type Position = {
x: number
y: number
Expand Down
25 changes: 16 additions & 9 deletions types/src/chunk.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
export function to_chunk_position(position: any): {
x: number;
z: number;
};
export function spiral_array(center: any, min_distance: any, max_distance: any): any[];
export function square_array(center: any, max_distance: any): {
x: number;
z: number;
}[];
export const CHUNK_SIZE: 500;
x: number
z: number
}
export function spiral_array(
center: any,
min_distance: any,
max_distance: any,
): any[]
export function square_array(
center: any,
max_distance: any,
): {
x: number
z: number
}[]
export const CHUNK_SIZE: 500
2 changes: 1 addition & 1 deletion types/src/create_spell.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {};
export {}
2 changes: 2 additions & 0 deletions types/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @typedef {ReturnType<create_client>} Client */
export function create_client({ socket_write, socket_end }: {
socket_write: any;
socket_end: any;
Expand All @@ -14,4 +15,5 @@ export function create_client({ socket_write, socket_end }: {
/** @type {(message: ArrayBuffer) => void} */
notify_message(message: ArrayBuffer): void;
};
export type Client = ReturnType<typeof create_client>;
import { PassThrough } from 'stream';

0 comments on commit 82a650c

Please sign in to comment.