@fuman/bun 0.0.4 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ import { ITcpConnection, ITlsConnection, TcpEndpoint } from '@fuman/net';
2
+ import { Socket } from 'bun';
3
+ /**
4
+ * Implementation of {@link ITcpConnection} and {@link ITlsConnection} interfaces
5
+ * using Bun's `connect` function.
6
+ */
7
+ export declare class TcpConnection implements ITcpConnection, ITlsConnection {
8
+ #private;
9
+ /** Underlying socket */
10
+ readonly socket: Socket<any>;
11
+ /** Connect to the given endpoint (must be called as the first thing before using the connection) */
12
+ connect(endpoint: TcpEndpoint, tls?: boolean): Promise<void>;
13
+ /** Create a new TcpConnection from an existing socket */
14
+ static from(socket: Socket<any>): TcpConnection;
15
+ read(into: Uint8Array): Promise<number>;
16
+ write(bytes: Uint8Array): Promise<void>;
17
+ close(): void;
18
+ get localAddress(): TcpEndpoint;
19
+ get remoteAddress(): TcpEndpoint;
20
+ setKeepAlive(_val: boolean): void;
21
+ setNoDelay(_val: boolean): void;
22
+ getAlpnProtocol(): string | null;
23
+ }
@@ -0,0 +1,5 @@
1
+ import { ConnectFunction, IListener, ListenFunction, TcpEndpoint, TlsConnectOptions } from '@fuman/net';
2
+ import { TcpConnection } from './connection.js';
3
+ export declare const connectTcp: ConnectFunction<TcpEndpoint, TcpConnection>;
4
+ export declare const connectTls: ConnectFunction<TlsConnectOptions, TcpConnection>;
5
+ export declare const listenTcp: ListenFunction<TcpEndpoint, IListener<TcpEndpoint>>;
package/index.d.cts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './connection.js';
2
+ export * from './functions.js';
3
+ export * from './listener.js';
package/listener.d.cts ADDED
@@ -0,0 +1,11 @@
1
+ import { IListener, TcpEndpoint } from '@fuman/net';
2
+ import { TcpConnection } from './connection.js';
3
+ export declare class TcpListener implements IListener<TcpEndpoint, TcpConnection> {
4
+ #private;
5
+ constructor();
6
+ /** listen on the given endpoint; must be called before any other methods */
7
+ listen(endpoint: TcpEndpoint): void;
8
+ close(): void;
9
+ get address(): TcpEndpoint;
10
+ accept(): Promise<TcpConnection>;
11
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@fuman/bun",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.9",
5
5
  "description": "bun-specific utilities",
6
6
  "license": "MIT",
7
7
  "scripts": {},
8
8
  "dependencies": {
9
- "@fuman/io": "^0.0.4",
10
- "@fuman/net": "^0.0.4",
9
+ "@fuman/io": "^0.0.8",
10
+ "@fuman/net": "^0.0.9",
11
11
  "@fuman/utils": "^0.0.4"
12
12
  },
13
13
  "exports": {