Thanks to visit codestin.com
Credit goes to effect-ts.github.io

Skip to main content Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

Socket.ts overview

Since v1.0.0


Exports Grouped by Category


combinators

toChannel

Signature

declare const toChannel: <IE>(
  self: Socket
) => Channel.Channel<
  Chunk.Chunk<Uint8Array>,
  Chunk.Chunk<Uint8Array | string | CloseEvent>,
  SocketError | IE,
  IE,
  void,
  unknown
>

Source

Since v1.0.0

toChannelMap

Signature

declare const toChannelMap: <IE, A>(
  self: Socket,
  f: (data: Uint8Array | string) => A
) => Channel.Channel<Chunk.Chunk<A>, Chunk.Chunk<Uint8Array | string | CloseEvent>, SocketError | IE, IE, void, unknown>

Source

Since v1.0.0

toChannelString

Signature

declare const toChannelString: {
  (
    encoding?: string | undefined
  ): <IE>(
    self: Socket
  ) => Channel.Channel<
    Chunk.Chunk<string>,
    Chunk.Chunk<Uint8Array | string | CloseEvent>,
    SocketError | IE,
    IE,
    void,
    unknown
  >
  <IE>(
    self: Socket,
    encoding?: string | undefined
  ): Channel.Channel<
    Chunk.Chunk<string>,
    Chunk.Chunk<Uint8Array | string | CloseEvent>,
    SocketError | IE,
    IE,
    void,
    unknown
  >
}

Source

Since v1.0.0

toChannelWith

Signature

declare const toChannelWith: <IE = never>() => (
  self: Socket
) => Channel.Channel<
  Chunk.Chunk<Uint8Array>,
  Chunk.Chunk<Uint8Array | string | CloseEvent>,
  SocketError | IE,
  IE,
  void,
  unknown
>

Source

Since v1.0.0

constructors

fromTransformStream

Signature

declare const fromTransformStream: <R>(
  acquire: Effect.Effect<InputTransformStream, SocketError, R>,
  options?: { readonly closeCodeIsError?: (code: number) => boolean }
) => Effect.Effect<Socket, never, Exclude<R, Scope.Scope>>

Source

Since v1.0.0

fromWebSocket

Signature

declare const fromWebSocket: <RO>(
  acquire: Effect.Effect<globalThis.WebSocket, SocketError, RO>,
  options?: { readonly closeCodeIsError?: (code: number) => boolean; readonly openTimeout?: DurationInput }
) => Effect.Effect<Socket, never, Exclude<RO, Scope.Scope>>

Source

Since v1.0.0

makeChannel

Signature

declare const makeChannel: <IE = never>() => Channel.Channel<
  Chunk.Chunk<Uint8Array>,
  Chunk.Chunk<Uint8Array | string | CloseEvent>,
  SocketError | IE,
  IE,
  void,
  unknown,
  Socket
>

Source

Since v1.0.0

makeWebSocket

Signature

declare const makeWebSocket: (
  url: string | Effect.Effect<string>,
  options?: {
    readonly closeCodeIsError?: ((code: number) => boolean) | undefined
    readonly openTimeout?: DurationInput | undefined
    readonly protocols?: string | Array<string> | undefined
  }
) => Effect.Effect<Socket, never, WebSocketConstructor>

Source

Since v1.0.0

makeWebSocketChannel

Signature

declare const makeWebSocketChannel: <IE = never>(
  url: string,
  options?: { readonly closeCodeIsError?: (code: number) => boolean }
) => Channel.Channel<
  Chunk.Chunk<Uint8Array>,
  Chunk.Chunk<Uint8Array | string | CloseEvent>,
  SocketError | IE,
  IE,
  void,
  unknown,
  WebSocketConstructor
>

Source

Since v1.0.0

errors

SocketCloseError (class)

Signature

declare class SocketCloseError

Source

Since v1.0.0

is (static method)

Signature

declare const is: (u: unknown) => u is SocketCloseError

Source

Since v1.0.0

isClean (static method)

Signature

declare const isClean: (isClean: (code: number) => boolean) => (u: unknown) => u is SocketCloseError

Source

Since v1.0.0

SocketError (type alias)

Signature

type SocketError = SocketGenericError | SocketCloseError

Source

Since v1.0.0

SocketGenericError (class)

Signature

declare class SocketGenericError

Source

Since v1.0.0

fiber refs

currentSendQueueCapacity

Signature

declare const currentSendQueueCapacity: FiberRef.FiberRef<number>

Source

Since v1.0.0

guards

isSocket

Signature

declare const isSocket: (u: unknown) => u is Socket

Source

Since v1.0.0

layers

layerWebSocket

Signature

declare const layerWebSocket: (
  url: string,
  options?: { readonly closeCodeIsError?: (code: number) => boolean }
) => Layer.Layer<Socket, never, WebSocketConstructor>

Source

Since v1.0.0

layerWebSocketConstructorGlobal

Signature

declare const layerWebSocketConstructorGlobal: Layer.Layer<WebSocketConstructor, never, never>

Source

Since v1.0.0

models

CloseEvent (class)

Signature

declare class CloseEvent { constructor(readonly code = 1000, readonly reason?: string) }

Source

Since v1.0.0

toString (method)

Signature

declare const toString: () => string

Source

Since v1.0.0

[CloseEventTypeId] (property)

Signature

readonly [CloseEventTypeId]: unique symbol

Source

Since v1.0.0

InputTransformStream (interface)

Signature

export interface InputTransformStream {
  readonly readable: ReadableStream<Uint8Array> | ReadableStream<string> | ReadableStream<Uint8Array | string>
  readonly writable: WritableStream<Uint8Array>
}

Source

Since v1.0.0

Socket (interface)

Signature

export interface Socket {
  readonly [TypeId]: TypeId
  readonly run: <_, E = never, R = never>(
    handler: (_: Uint8Array) => Effect.Effect<_, E, R> | void,
    options?: {
      readonly onOpen?: Effect.Effect<void> | undefined
    }
  ) => Effect.Effect<void, SocketError | E, R>
  readonly runRaw: <_, E = never, R = never>(
    handler: (_: string | Uint8Array) => Effect.Effect<_, E, R> | void,
    options?: {
      readonly onOpen?: Effect.Effect<void> | undefined
    }
  ) => Effect.Effect<void, SocketError | E, R>
  readonly writer: Effect.Effect<
    (chunk: Uint8Array | string | CloseEvent) => Effect.Effect<void, SocketError>,
    never,
    Scope.Scope
  >
}

Source

Since v1.0.0

refinements

isCloseEvent

Signature

declare const isCloseEvent: (u: unknown) => u is CloseEvent

Source

Since v1.0.0

isSocketError

Signature

declare const isSocketError: (u: unknown) => u is SocketError

Source

Since v1.0.0

tags

Socket

Signature

declare const Socket: Context.Tag<Socket, Socket>

Source

Since v1.0.0

WebSocket

Signature

declare const WebSocket: Context.Tag<WebSocket, globalThis.WebSocket>

Source

Since v1.0.0

WebSocket (interface)

Signature

export interface WebSocket {
  readonly _: unique symbol
}

Source

Since v1.0.0

WebSocketConstructor

Signature

declare const WebSocketConstructor: Context.Tag<
  WebSocketConstructor,
  (url: string, protocols?: string | Array<string> | undefined) => globalThis.WebSocket
>

Source

Since v1.0.0

WebSocketConstructor (interface)

Signature

export interface WebSocketConstructor {
  readonly _: unique symbol
}

Source

Since v1.0.0

type ids

CloseEventTypeId

Signature

declare const CloseEventTypeId: unique symbol

Source

Since v1.0.0

CloseEventTypeId (type alias)

Signature

type CloseEventTypeId = typeof CloseEventTypeId

Source

Since v1.0.0

SocketErrorTypeId

Signature

declare const SocketErrorTypeId: unique symbol

Source

Since v1.0.0

SocketErrorTypeId (type alias)

Signature

type SocketErrorTypeId = typeof SocketErrorTypeId

Source

Since v1.0.0

TypeId

Signature

declare const TypeId: unique symbol

Source

Since v1.0.0

TypeId (type alias)

Signature

type TypeId = typeof TypeId

Source

Since v1.0.0

utils

defaultCloseCodeIsError

Signature

declare const defaultCloseCodeIsError: (code: number) => boolean

Source

Since v1.0.0