Licence
MPL-2.0
Version
0.1.1
Deps
1
Size
110 kB
Vulns
0
Weekly
0
@stateforward/yamux.ts
Browser-native Yamux multiplexing over Web Streams.
Installation
npm install @stateforward/yamux.ts
Runtime Dependency
@stateforward/hsm.ts
Development
npm run buildnpm run benchmarknpm run conformancenpm testnpm run test:browsernpm run test:coveragenpm run test:fuzznpm run typecheck
Conformance
npm run conformance builds this package and runs bidirectional echo, concurrency, half-close, reset, GOAWAY, peer-close, and malformed-frame cases against github.com/hashicorp/yamux pinned by conformance/go.mod.
Benchmark
npm run benchmark builds this package and compares client-opened echo streams over an in-memory transport against yamux-js.
See docs/performance.md for profiling notes and optimization history.
API
SessionSessionRoleSessionOptionsWaitOptionsPingOptionsSessionEventClientClientOptionsclientStreamIDsClientEventcreateClientServerServerOptionsserverStreamIDsServerEventcreateServerStreamStreamOptionsStreamEventPROTOCOL_VERSIONHEADER_SIZEINITIAL_STREAM_WINDOWMAX_UINT32YamuxHeaderYamuxFramedecodeHeaderencodeHeaderhasFlagframeToBytesisFrameTypeYamuxFrameTypeYamuxFlagYamuxGoAwayCodeYamuxErrorYamuxErrorCodeabortedErrortimeoutError
Example
import { createClient } from "@stateforward/yamux.ts";
const session = createClient({
readable: socket.readable,
writable: socket.writable,
});
const stream = await session.openStream();
const writer = stream.writable.getWriter();
await writer.write(new TextEncoder().encode("hello"));
await writer.close();