common.d.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /// <reference types="node" />
  2. /**
  3. * Converts IP string into buffer, 4 bytes for IPv4, and 16 bytes for IPv6.
  4. * It will return null when IP string invalid.
  5. *
  6. * ```js
  7. * console.log(bytesFromIP('::1')) // <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01>
  8. * ```
  9. * @param ip IP string to convert
  10. */
  11. export declare function bytesFromIP(ip: string): Buffer | null;
  12. /**
  13. * Converts 4-bytes into an IPv4 string representation or 16-bytes into
  14. * an IPv6 string representation. The bytes must be in network order.
  15. *
  16. * ```js
  17. * console.log(bytesToIP(Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]))) // '::1'
  18. * ```
  19. * @param bytes buffer to convert
  20. */
  21. export declare function bytesToIP(bytes: Buffer): string;
  22. /**
  23. * Returns Object Identifier (dot-separated numeric string) that registered by initOID function.
  24. * It will return empty string if not exists.
  25. * @param nameOrId OID name or OID
  26. */
  27. export declare function getOID(nameOrId: string): string;
  28. /**
  29. * Returns Object Identifier name that registered by initOID function.
  30. * It will return the argument nameOrId if not exists.
  31. * @param nameOrId OID name or OID
  32. */
  33. export declare function getOIDName(nameOrId: string): string;