Skip to main content
16-bit unsigned integer with overflow checking.
import * as Uint16 from 'voltaire-effect/Uint16'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'

// Schema
const value = Schema.decodeSync(Uint16.Number)(65535)

// Effect with arithmetic
const program = Effect.gen(function* () {
  const a = yield* Uint16.from(30000)
  const b = yield* Uint16.from(20000)
  return yield* Uint16.plus(a, b) // 50000
})

API

FunctionReturns
toNumber(v)number
toHex(v)'0xffff'
equals(a, b)boolean

Constants

MAX = 65535, MIN = 0, ZERO, ONE