Skip to content

convertIPv6ToBinary

reference
1 min readUpdated

Kind: Function

Source: src/utils/ipaddr.ts

Part of: Utils

Convert IPv6 to Uint8Array

convertIPv6ToBinary accepts an IPv6 address string and converts it into a Uint8Array. It belongs to the IP address utility layer, where callers can use the byte representation for address processing and comparisons.

Signature

ts
function convertIPv6ToBinary(ipv6: string): bigint

Parameters

NameType
ipv6string

Returns: bigint

Diagram

mermaid
graph LR
  Address[IPv6 address string] --> Convert[convertIPv6ToBinary]
  Convert --> Bytes[Uint8Array]

Usage

ts
import { convertIPv6ToBinary } from './utils/ipaddr';

const address = 'fe80::abcd';
const bytes = convertIPv6ToBinary(address);

console.log(bytes);

AI Coding Instructions

  • Pass IPv6 address strings to convertIPv6ToBinary; do not use it for IPv4 addresses.
  • Treat the returned value as binary address data rather than a formatted address string.
  • Keep address parsing and conversion logic in src/utils/ipaddr.ts.
  • Match existing caller behavior for invalid or malformed IPv6 input.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • IPRestrictionRulesrc/middleware/ip-restriction/index.ts:38

Was this page helpful?

Download as PDF
convertIPv6ToBinary — Hono (narrator proof)