Kind: Function
Source: src/utils/ipaddr.ts
Part of: Utils
Convert IPv4 to Uint8Array
Converts an IPv4 address string into a Uint8Array representation. It supports code in src/utils/ipaddr.ts that needs address data in byte form.
Signature
tsfunction convertIPv4ToBinary(ipv4: string): bigint
Parameters
| Name | Type |
|---|---|
ipv4 | string |
Returns: bigint
Diagram
mermaidgraph LR Input[IPv4 address string] --> Convert[convertIPv4ToBinary] Convert --> Output[Uint8Array]
Usage
tsimport { convertIPv4ToBinary } from './utils/ipaddr';
declare const ipv4Address: string;
const addressBytes = convertIPv4ToBinary(ipv4Address);
console.log(addressBytes);
AI Coding Instructions
- Pass a valid IPv4 address string to this function.
- Keep the returned value as a
Uint8Arraywhen passing address data to byte-oriented APIs. - Handle invalid address input at the caller when the surrounding flow requires user-facing errors.
- Import the helper from
src/utils/ipaddr.tsrather than duplicating address-to-byte conversion logic.
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)
IPRestrictionRule—src/middleware/ip-restriction/index.ts:38
Was this page helpful?