Options
All
  • Public
  • Public/Protected
  • All
Menu

Project raiden-ts - v3.1.1

Index

Type aliases

Address

Address: HexString<20> & t.Brand<AddressB>

ContractsInfo

ContractsInfo: t.TypeOf<typeof ContractsInfo>

Decodable

Decodable<T>: T extends BigNumber ? BigNumberish : T extends string ? string : T extends boolean ? boolean : T extends number ? number : T extends null | symbol ? T : unknown extends T ? unknown : {[ K in keyof T]: Decodable<T[K]> }

Type helper to recursively map decodable properties to their simpler encoded types; This allows e.g. types decodable as BigNumbers to be passed in [recursive] properties where BigNumbers are expected at runtime, as long as the object is decoded/validated before use.

Type parameters

  • T

ErrorCodes

ErrorCodes: keyof typeof ErrorCodes

ErrorMatch

ErrorMatch: string | number | {}

ErrorMatches

ErrorMatches: readonly ErrorMatch[]

Hash

Hash: HexString<32>

HexString

HexString<S>: string & t.Brand<HexStringB<S>>

Type parameters

  • S: number = number

Int

Int<S>: BigNumber & t.Brand<IntB<S>>

Type parameters

  • S: number = number

Last

Last<T>: T extends readonly [...unknown[], infer L] ? L : T[number] | undefined

Infer type of last element of a tuple or array Currently supports tuples of up to 9 elements before falling back to array's inference

Type parameters

  • T: readonly unknown[]

OnChange

OnChange<T, P>: (event: ChangeEvent<T, P>) => void

Type parameters

  • T: string

  • P

Type declaration

PfsMode

PfsMode: typeof PfsMode[keyof typeof PfsMode]

PrivateKey

PrivateKey: HexString<32>

PublicKey

PublicKey: HexString<65>

RaidenAction

RaidenAction: Action

RaidenEvent

RaidenEvent: ActionType<typeof RaidenEvents>

RaidenPFS

RaidenPFS: Decodable<PFS>

Public Raiden interface for PFS info

RaidenPaths

RaidenPaths: Decodable<Paths>

Public Raiden interface for routes data

Secret

Secret: HexString<32>

Signature

Signature: HexString<65>

Signed

Signed<M>: M & { signature: Signature }

Type parameters

  • M

Timed

Timed<T>: T & { ts: number }

Helper type to extend a given type T to contain a timestamp ts member

Type parameters

  • T

UInt

UInt<S>: BigNumber & t.Brand<UIntB<S>>

Type parameters

  • S: number = number

UnionToIntersection

UnionToIntersection<U>: (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never

Converts a union to the respective intersection Example: type UnionToIntersection<{ a: string } | { b: number }> = { a: string } & { b: number }

Type parameters

  • U

Variables

Address

Address: AddressC

BigNumberC

BigNumberC: BigNumberC

Const CapsFallback

CapsFallback: { Delivery: 1; Mediate: 1; Receive: 1; immutableMetadata: 0; toDevice: 1; webRTC: 0 } = ...

Type declaration

  • Delivery: 1
  • Mediate: 1
  • Receive: 1
  • immutableMetadata: 0
  • toDevice: 1
  • webRTC: 0

Const ContractsInfo

ContractsInfo: ReadonlyC<RecordC<KeyofC<{ MonitoringService: null; OneToN: null; SecretRegistry: null; ServiceRegistry: null; TokenNetworkRegistry: null; UserDeposit: null }>, ReadonlyC<TypeC<{ address: AddressC; block_number: NumberC }>>>> = ...

Const DEFAULT_CONFIRMATIONS

DEFAULT_CONFIRMATIONS: 5 = 5

Const DEFAULT_MS_REWARD

DEFAULT_MS_REWARD: UInt<32> = ...

Const DEFAULT_PFS_IOU_TIMEOUT

DEFAULT_PFS_IOU_TIMEOUT: number = ...

Const DEFAULT_PFS_MAX_PATHS

DEFAULT_PFS_MAX_PATHS: 3 = 3

Const DEFAULT_POLLING_INTERVAL

DEFAULT_POLLING_INTERVAL: 5 = 5

Const DEFAULT_REVEAL_TIMEOUT

DEFAULT_REVEAL_TIMEOUT: number = ...

Const ErrorCodec

ErrorCodec: Type<Error, { details?: unknown; message?: string; name: string; stack?: string }, unknown> = ...

Simple Error codec

This codec doesn't decode to an instance of the exact same error class object, but instead to a generic Error, but assigning 'name', 'stack' & 'message' properties, more as an informative object.

Const ErrorCodes

ErrorCodes: { CNL_CLOSECHANNEL_FAILED: string; CNL_COOP_SETTLE_FAILED: string; CNL_COOP_SETTLE_NOT_POSSIBLE: string; CNL_INVALID_STATE: string; CNL_NO_OPEN_CHANNEL_FOUND: string; CNL_NO_OPEN_OR_CLOSING_CHANNEL_FOUND: string; CNL_NO_SETTLEABLE_OR_SETTLING_CHANNEL_FOUND: string; CNL_ONCHAIN_UNLOCK_FAILED: string; CNL_OPENCHANNEL_FAILED: string; CNL_SETTLE_AUTO_ENABLED: string; CNL_SETTLE_FAILED: string; CNL_SETTLE_INVALID_BALANCEHASH: string; CNL_SETTOTALDEPOSIT_FAILED: string; CNL_UPDATE_NONCLOSING_BP_FAILED: string; CNL_WITHDRAW_AMOUNT_TOO_HIGH: string; CNL_WITHDRAW_AMOUNT_TOO_LOW: string; CNL_WITHDRAW_EXPIRED: string; CNL_WITHDRAW_EXPIRES_SOON: string; CNL_WITHDRAW_PENDING: string; CNL_WITHDRAW_RETRY_CONFIRMATION: string; CNL_WITHDRAW_TRANSACTION_FAILED: string; DTA_ARRAY_LENGTH_DIFFERENCE: string; DTA_INVALID_ADDRESS: string; DTA_INVALID_AMOUNT: string; DTA_INVALID_DEPOSIT: string; DTA_INVALID_PATH: string; DTA_INVALID_PAYMENT_ID: string; DTA_INVALID_PFS: string; DTA_INVALID_TIMEOUT: string; DTA_NEGATIVE_NUMBER: string; DTA_NON_POSITIVE_NUMBER: string; DTA_NUMBER_TOO_LARGE: string; DTA_UNENCODABLE_DATA: string; PFS_DISABLED: string; PFS_EMPTY_URL: string; PFS_ERROR_RESPONSE: string; PFS_INVALID_INFO: string; PFS_INVALID_URL: string; PFS_IOU_SIGNATURE_MISMATCH: string; PFS_LAST_IOU_REQUEST_FAILED: string; PFS_NO_ROUTES_BETWEEN_NODES: string; PFS_NO_ROUTES_FOUND: string; PFS_TARGET_NO_RECEIVE: string; PFS_TARGET_OFFLINE: string; PFS_TOO_EXPENSIVE: string; PFS_UNKNOWN_TOKEN_NETWORK: string; RDN_ACCOUNT_NOT_FOUND: string; RDN_ALREADY_STARTED: string; RDN_APPROVE_TRANSACTION_FAILED: string; RDN_ASSERT_ERROR: string; RDN_DATABASE_DELETED: string; RDN_DEPOSIT_TRANSACTION_FAILED: string; RDN_GENERAL_ERROR: string; RDN_INSUFFICIENT_ALLOWANCE: string; RDN_INSUFFICIENT_BALANCE: string; RDN_INVALID_SECRET: string; RDN_INVALID_SECRETHASH: string; RDN_MINT_FAILED: string; RDN_MINT_MAINNET: string; RDN_NOT_A_TOKEN: string; RDN_REGISTER_TOKEN_FAILED: string; RDN_REGISTER_TOKEN_MAINNET: string; RDN_REGISTER_TOKEN_REGISTERED: string; RDN_SECRET_SECRETHASH_MISMATCH: string; RDN_SIGNER_NOT_CONNECTED: string; RDN_STATE_ADDRESS_MISMATCH: string; RDN_STATE_MIGRATION: string; RDN_STATE_NETWORK_MISMATCH: string; RDN_STRING_ACCOUNT_INVALID: string; RDN_TRANSACTION_FAILED: string; RDN_TRANSACTION_REORG: string; RDN_TRANSFER_ONCHAIN_BALANCE_FAILED: string; RDN_TRANSFER_ONCHAIN_TOKENS_FAILED: string; RDN_UNKNOWN_TOKEN_NETWORK: string; RDN_UNKNOWN_TRANSFER: string; RDN_UNRECOGNIZED_NETWORK: string; TRNS_MESSAGE_SIGNATURE_MISMATCH: string; TRNS_NO_MATRIX_SERVERS: string; TRNS_NO_SERVERNAME: string; TRNS_NO_VALID_USER: string; UDC_DEPOSIT_OUTDATED: string; UDC_PLAN_WITHDRAW_EXCEEDS_AVAILABLE: string; UDC_PLAN_WITHDRAW_FAILED: string; UDC_PLAN_WITHDRAW_GT_ZERO: string; UDC_WITHDRAW_AUTO_ENABLED: string; UDC_WITHDRAW_FAILED: string; UDC_WITHDRAW_NO_BALANCE: string; UDC_WITHDRAW_NO_PLAN: string; UDC_WITHDRAW_TOO_LARGE: string; XFER_ALREADY_COMPLETED: string; XFER_CHANNEL_CLOSED_PREMATURELY: string; XFER_EXPIRED: string; XFER_INVALID_SECRETREQUEST: string; XFER_REFUNDED: string; XFER_REGISTERSECRET_TX_FAILED: string } = ...

Type declaration

  • CNL_CLOSECHANNEL_FAILED: string
  • CNL_COOP_SETTLE_FAILED: string
  • CNL_COOP_SETTLE_NOT_POSSIBLE: string
  • CNL_INVALID_STATE: string
  • CNL_NO_OPEN_CHANNEL_FOUND: string
  • CNL_NO_OPEN_OR_CLOSING_CHANNEL_FOUND: string
  • CNL_NO_SETTLEABLE_OR_SETTLING_CHANNEL_FOUND: string
  • CNL_ONCHAIN_UNLOCK_FAILED: string
  • CNL_OPENCHANNEL_FAILED: string
  • CNL_SETTLE_AUTO_ENABLED: string
  • CNL_SETTLE_FAILED: string
  • CNL_SETTLE_INVALID_BALANCEHASH: string
  • CNL_SETTOTALDEPOSIT_FAILED: string
  • CNL_UPDATE_NONCLOSING_BP_FAILED: string
  • CNL_WITHDRAW_AMOUNT_TOO_HIGH: string
  • CNL_WITHDRAW_AMOUNT_TOO_LOW: string
  • CNL_WITHDRAW_EXPIRED: string
  • CNL_WITHDRAW_EXPIRES_SOON: string
  • CNL_WITHDRAW_PENDING: string
  • CNL_WITHDRAW_RETRY_CONFIRMATION: string
  • CNL_WITHDRAW_TRANSACTION_FAILED: string
  • DTA_ARRAY_LENGTH_DIFFERENCE: string
  • DTA_INVALID_ADDRESS: string
  • DTA_INVALID_AMOUNT: string
  • DTA_INVALID_DEPOSIT: string
  • DTA_INVALID_PATH: string
  • DTA_INVALID_PAYMENT_ID: string
  • DTA_INVALID_PFS: string
  • DTA_INVALID_TIMEOUT: string
  • DTA_NEGATIVE_NUMBER: string
  • DTA_NON_POSITIVE_NUMBER: string
  • DTA_NUMBER_TOO_LARGE: string
  • DTA_UNENCODABLE_DATA: string
  • PFS_DISABLED: string
  • PFS_EMPTY_URL: string
  • PFS_ERROR_RESPONSE: string
  • PFS_INVALID_INFO: string
  • PFS_INVALID_URL: string
  • PFS_IOU_SIGNATURE_MISMATCH: string
  • PFS_LAST_IOU_REQUEST_FAILED: string
  • PFS_NO_ROUTES_BETWEEN_NODES: string
  • PFS_NO_ROUTES_FOUND: string
  • PFS_TARGET_NO_RECEIVE: string
  • PFS_TARGET_OFFLINE: string
  • PFS_TOO_EXPENSIVE: string
  • PFS_UNKNOWN_TOKEN_NETWORK: string
  • RDN_ACCOUNT_NOT_FOUND: string
  • RDN_ALREADY_STARTED: string
  • RDN_APPROVE_TRANSACTION_FAILED: string
  • RDN_ASSERT_ERROR: string
  • RDN_DATABASE_DELETED: string
  • RDN_DEPOSIT_TRANSACTION_FAILED: string
  • RDN_GENERAL_ERROR: string
  • RDN_INSUFFICIENT_ALLOWANCE: string
  • RDN_INSUFFICIENT_BALANCE: string
  • RDN_INVALID_SECRET: string
  • RDN_INVALID_SECRETHASH: string
  • RDN_MINT_FAILED: string
  • RDN_MINT_MAINNET: string
  • RDN_NOT_A_TOKEN: string
  • RDN_REGISTER_TOKEN_FAILED: string
  • RDN_REGISTER_TOKEN_MAINNET: string
  • RDN_REGISTER_TOKEN_REGISTERED: string
  • RDN_SECRET_SECRETHASH_MISMATCH: string
  • RDN_SIGNER_NOT_CONNECTED: string
  • RDN_STATE_ADDRESS_MISMATCH: string
  • RDN_STATE_MIGRATION: string
  • RDN_STATE_NETWORK_MISMATCH: string
  • RDN_STRING_ACCOUNT_INVALID: string
  • RDN_TRANSACTION_FAILED: string
  • RDN_TRANSACTION_REORG: string
  • RDN_TRANSFER_ONCHAIN_BALANCE_FAILED: string
  • RDN_TRANSFER_ONCHAIN_TOKENS_FAILED: string
  • RDN_UNKNOWN_TOKEN_NETWORK: string
  • RDN_UNKNOWN_TRANSFER: string
  • RDN_UNRECOGNIZED_NETWORK: string
  • TRNS_MESSAGE_SIGNATURE_MISMATCH: string
  • TRNS_NO_MATRIX_SERVERS: string
  • TRNS_NO_SERVERNAME: string
  • TRNS_NO_VALID_USER: string
  • UDC_DEPOSIT_OUTDATED: string
  • UDC_PLAN_WITHDRAW_EXCEEDS_AVAILABLE: string
  • UDC_PLAN_WITHDRAW_FAILED: string
  • UDC_PLAN_WITHDRAW_GT_ZERO: string
  • UDC_WITHDRAW_AUTO_ENABLED: string
  • UDC_WITHDRAW_FAILED: string
  • UDC_WITHDRAW_NO_BALANCE: string
  • UDC_WITHDRAW_NO_PLAN: string
  • UDC_WITHDRAW_TOO_LARGE: string
  • XFER_ALREADY_COMPLETED: string
  • XFER_CHANNEL_CLOSED_PREMATURELY: string
  • XFER_EXPIRED: string
  • XFER_INVALID_SECRETREQUEST: string
  • XFER_REFUNDED: string
  • XFER_REGISTERSECRET_TX_FAILED: string

Const Hash

Hash: HexStringC<32> = ...

Const LocksrootZero

LocksrootZero: Hash = ...

Const PfsMode

PfsMode: { auto: "auto"; disabled: "disabled"; onlyAdditional: "onlyAdditional" } = ...

Type declaration

  • auto: "auto"
  • disabled: "disabled"
  • onlyAdditional: "onlyAdditional"

Const PrivateKey

PrivateKey: HexStringC<32> = ...

Const PublicKey

PublicKey: HexStringC<65> = ...

Const RAIDEN_DEVICE_ID

RAIDEN_DEVICE_ID: "RAIDEN" = 'RAIDEN'

Const RaidenConfig

RaidenConfig: ReadonlyC<IntersectionC<[TypeC<{ additionalServices: ReadonlyArrayC<UnionC<[AddressC, StringC]>>; autoSettle: BooleanC; autoUDCWithdraw: BooleanC; caps: UnionC<[NullC, ReadonlyC<RecordC<StringC, UnionC<[UnionC<[StringC, NumberC, BooleanC, NullC]>, ArrayC<UnionC<[StringC, NumberC, BooleanC, NullC]>>]>>>]>; confirmationBlocks: NumberC; encryptSecret: BooleanC; expiryFactor: NumberC; fallbackIceServers: ArrayC<TypeC<{ urls: UnionC<[StringC, ArrayC<StringC>]> }>>; httpTimeout: NumberC; logger: KeyofC<{ : null; debug: null; error: null; info: null; trace: null; warn: null }>; matrixServerLookup: StringC; mediationFees: UnknownC; minimumAllowance: UIntC<32>; monitoringReward: UnionC<[NullC, UIntC<32>]>; pfsIouTimeout: NumberC; pfsMaxFee: UIntC<32>; pfsMaxPaths: NumberC; pfsMode: KeyofC<{ auto: any; disabled: any; onlyAdditional: any }>; pfsSafetyMargin: UnionC<[NumberC, TupleC<[NumberC, NumberC]>]>; pollingInterval: NumberC; rateToSvt: RecordC<StringC, UIntC<32>>; revealTimeout: NumberC }>, PartialC<{ gasPriceFactor: UnionC<[NumberC, NullC]>; matrixServer: StringC; subkey: BooleanC }>]>> = ...

A Raiden configuration object with required and optional params from [[PartialRaidenConfig]].

Notice partial/undefined values are special: when a raidenConfigUpdate is called with an undefined value, it won't be set, as they can't be [re]stored in the JSON state, but instead means it'll be reset to the default value; therefore, if a partial value has a defined default, it can't be unset; if you want to support "empty" values, use null, empty string or other falsy serializable types, and/or ensure it never gets a default

  • matrixServerLookup - Matrix server URL to fetch existing matrix servers from. After intializing a Raiden instance, the matrix server can't be changed later on.
  • revealTimeout - Timeout for secrets to be revealed (in seconds)
  • expiryFactor - Multiply revealTimeout to get how far in the future transfer expiration should be
  • httpTimeout - Used in http fetch requests
  • additionalServices - Array of extra services URLs (or addresses, if URL set on SecretRegistry)
  • pfsMode - One of 'disabled' (disables PFS usage and notifications), 'auto' (notifies all of registered and additionalServices, picks cheapest for transfers without explicit pfs), or 'onlyAdditional' (notifies all, but pick first responding from additionalServices only).
  • pfsSafetyMargin - Safety margin to be added to fees received from PFS. Either a fee multiplier, or a [fee, amount] pair ofmultipliers. Use 1.1 to add a 10% over estimated fee margin, or [0.03, 0.0005] to add a 3% over fee plus 0.05% over amount.
  • pfsMaxPaths - Limit number of paths requested from PFS for a route.
  • pfsMaxFee - Maximum fee we're willing to pay a PFS for a route (in SVT/RDN wei)
  • pfsIouTimeout - Number of seconds to timeout an IOU to a PFS.
  • confirmationBlocks - How many blocks to wait before considering a transaction as confirmed
  • monitoringReward - Reward to be paid to MS, in SVT/RDN; use Zero or null to disable
  • logger - String specifying the console log level of redux-logger. Use '' to silence.
  • caps - Own transport capabilities overrides. Set to null to disable all, including defaults
  • fallbackIceServers - STUN servers to be used as a fallback for WebRTC
  • rateToSvt - Exchange rate between tokens and SVT, in wei: e.g. rate[TKN]=2e18 => 1TKN = 2SVT
  • pollingInterval - Interval at which to poll ETH provider for new blocks/events (milliseconds) Honored only at start time
  • minimumAllowance - Minimum value to call approve on tokens; default to MaxUint256, so approving tokens should be needed only once, trusting TokenNetwork's & UDC contracts; Set to Zero to fallback to approving the strictly needed deposit amounts
  • autoSettle - Whether to channelSettle.request settleable channels automatically
  • autoUDCWithdraw - Whether to udcWithdraw.request planned withdraws automatically
  • mediationFees - deps.mediationFeeCalculator config. It's typed as unknown because it'll be validated and decoded by [[FeeModel.decodeConfig]].
  • encryptSecret - Whether to send secret encrypted to target by default on transfers
  • matrixServer? - Specify a matrix server to use.
  • subkey? - When using subkey, this sets the behavior when { subkey } option isn't explicitly set in on-chain method calls. false (default) = use main key; true = use subkey
  • gasPriceFactor - Multiplier to be applied over base estimated/average gasPrice; post-EPI1559 (London), this gets applied only to maxPriorityFeePerGas, or eth-node's eth_gasPrice returned value; default does nothing and let provider guess (e.g. Metamask); default ethers maxPriorityFeePerGas is 2.5 Gwei

RaidenState

RaidenState: RaidenStateC

Const Secret

Secret: HexStringC<32> = ...

Const Signature

Signature: HexStringC<65> = ...

Const SignatureZero

SignatureZero: Signature = ...

Const commonAndFailTxErrors

commonAndFailTxErrors: ErrorMatches = ...

Const commonTxErrors

commonTxErrors: ErrorMatches = ...

Const networkErrors

networkErrors: ErrorMatches = ...

Functions

Const HexString

  • Helper function to create codecs to validate an arbitrary or variable-sized hex bytestring A branded codec to indicate validated hex-strings

    Type parameters

    • S: number = number

    Parameters

    • Optional size: S

      Required number of bytes. Pass undefined or zero to have a variable-sized type

    Returns HexStringC<S>

    branded codec for hex-encoded bytestrings

Const Int

  • Int<S>(size?: S): IntC<S>
  • Helper function to create codecs to validate an arbitrary or variable-sized BigNumbers A branded codec/type to indicate size-validated BigNumbers

    Type parameters

    • S: number = number

    Parameters

    • Optional size: S

      Required number of bytes. Pass undefined to have a variable-sized type

    Returns IntC<S>

    branded codec for hex-encoded bytestrings

Const Signed

Const Timed

  • Timed<T>(codec: T): TimedC<T>
  • Helper function to create codecs to validate derived types containing a timestamp ts

    Type parameters

    • T: Mixed<T>

    Parameters

    • codec: T

      Codec to compose with a ts timestamp property

    Returns TimedC<T>

    Codec validating such subtype

Const UInt

  • UInt<S>(size?: S): UIntC<S>
  • Helper function to create codecs to validate an arbitrary or variable-sized BigNumbers A branded codec/type to indicate size-validated BigNumbers

    Type parameters

    • S: number = number

    Parameters

    • Optional size: S

      Required number of bytes. Pass undefined to have a variable-sized type

    Returns UIntC<S>

    branded codec for hex-encoded bytestrings

assert

  • assert<E>(condition: any, error?: string | E | ((condition?: any) => E | never) | ConstructorParameters<typeof RaidenError>, log?: (...args: any[]) => void): asserts condition
  • Type-safe assertion function (TS3.7)

    Type parameters

    Parameters

    • condition: any

      Condition to validate as truthy

    • Optional error: string | E | ((condition?: any) => E | never) | ConstructorParameters<typeof RaidenError>

      Message, Error, error factory or tuple of RaidenError constructor parameters to throw if condition is falsy

    • Optional log: (...args: any[]) => void

      Logger to log error to

        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns asserts condition

bnMax

  • bnMax<T>(...args: [T, ...T[]]): T
  • Math.max for BigNumbers

    Type parameters

    • T: BigNumber<T>

    Parameters

    • Rest ...args: [T, ...T[]]

      Parameters to compare, must have at least one element

    Returns T

    Maxium of parameters as per BigNumber's lt comparison

decode

  • decode<C>(codec: C, data: C["_I"], customError?: string | Error, log?: (...args: any[]) => void): C["_A"]
  • Decode/validate like codec.decode, but throw or return right instead of Either

    Type parameters

    • C: Mixed<C>

    Parameters

    • codec: C

      io-ts codec to be used for decoding/validation

    • data: C["_I"]

      data to decode/validate

    • Optional customError: string | Error

      Message or error to throw if the decoding fails

    • Optional log: (...args: any[]) => void

      Logger to log error to

        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns C["_A"]

    Decoded value of codec type

getNetworkName

  • getNetworkName(network: Network): string
  • Return a network name, if known, or stringified chainId otherwise

    Parameters

    • network: Network

      Network to get name from

    Returns string

    name or chainId as string

Const instanceOf

  • instanceOf<C>(name: string): Type<C, C, unknown>
  • Memoized factory to create codecs validating an arbitrary class C

    Type parameters

    • C

    Parameters

    • name: string

      Class to create a codec for

    Returns Type<C, C, unknown>

    Codec validating class C

isntNil

  • isntNil<T>(value: T): value is NonNullable<T>
  • Test for value's non-nulliness Like lodash's negate(isNil), but also works as type guard (e.g. useful for filters)

    Type parameters

    • T

    Parameters

    • value: T

      to be tested

    Returns value is NonNullable<T>

    true if value is not null nor undefined

last

  • last<T>(arr: T): Last<T>
  • Like lodash's last, but properly infer return type when argument is a tuple

    Type parameters

    • T: readonly unknown[]

    Parameters

    • arr: T

      Tuple or array to get last element from

    Returns Last<T>

    Last element from arr

matchError

shouldRetryError

  • shouldRetryError(opts: { log?: LogFunc; maxRetries?: number; neverOnErrors?: ErrorMatches; onErrors?: ErrorMatches; predicate?: PredicateFunc; stopPredicate?: PredicateFunc }): (error: any) => boolean
  • Creates a function to decide if a given error should be retried or not

    Parameters

    • opts: { log?: LogFunc; maxRetries?: number; neverOnErrors?: ErrorMatches; onErrors?: ErrorMatches; predicate?: PredicateFunc; stopPredicate?: PredicateFunc }

      Options object

      • Optional Readonly log?: LogFunc

        Log using this function

      • Optional Readonly maxRetries?: number

        maximum number of retries before rejecting

      • Optional Readonly neverOnErrors?: ErrorMatches

        Never retry on these errors

      • Optional Readonly onErrors?: ErrorMatches

        retry only on these errors

      • Optional Readonly predicate?: PredicateFunc

        Retry if this predicate matches

      • Optional Readonly stopPredicate?: PredicateFunc

        Don't retry if this predicate match

    Returns (error: any) => boolean

    Function to test if errors should be retried or not

      • (error: any): boolean
      • Parameters

        • error: any

        Returns boolean

templateLiteral

  • templateLiteral<L>(regex: RegExp | string, name?: string): RefinementType<StringC, L, string, unknown>
  • Creates a refinement of t.string which validates a template literal string

    Type parameters

    • L: string

    Parameters

    • regex: RegExp | string

      Regex which matches the generic parameter L

    • Optional name: string

      codec name

    Returns RefinementType<StringC, L, string, unknown>

    refinement type of string to tempalte literal

timed

  • timed<T>(v: T, ts?: number): Timed<T>
  • Given a value of type T, returns a Timed with current time as 'ts' member

    Type parameters

    • T

    Parameters

    • v: T

      Value to return with time

    • ts: number = ...

      Timestamp to use, defaults to now

    Returns Timed<T>

    copy of v added of a ts numeric timestamp

untime

  • untime<T>(v: T): Omit<T, "ts">
  • Remove ts timestamp field (from timed) from object passed as parameter (immutably)

    Type parameters

    • T: { ts: number }

    Parameters

    • v: T

      Timed object

    Returns Omit<T, "ts">

    return a copy of v without ts property

Generated using TypeDoc