Socket
Socket
Sign inDemoInstall

ip2buf

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ip2buf

Convert IPv4 or IPv6 address to the Buffer.


Version published
Weekly downloads
2.5K
decreased by-1.81%
Maintainers
1
Install size
16.0 kB
Created
Weekly downloads
 

Readme

Source

ip2buf

travis npm license downloads

Convert IPv4 or IPv6 address to the Buffer.

Usage

const { pton4, pton6 } = require('ip2buf')

pton4('8.8.8.8') // Buffer<0x8, 0x8, 0x8, 0x8>
pton6('2001::')  // Buffer<0x20, 0x01, 0, ...>

Perfomance

  • IPv4
librarytime (2e6 times)
native296.627ms
ip2buf283.710ms
ipaddr.js1728.538ms
  • IPv6
librarytime (1e6 times)
native333.071ms
ip2buf767.788ms
ipaddr.js1828.334ms

API

  • pton(af: number, addr: string, [[dest: Buffer], index: number]): Buffer

Convert IPv4 or IPv6 address to the Buffer.

const { pton, constants: { IPV4_OCTETS, IPV6_OCTETS } } = require('ip2buf')

pton(IPV4_OCTETS, '127.0.0.1')
pton(IPV6_OCTETS, '::1')
  • pton4(addr: string, [[dest: Buffer], index: number]): Buffer

Convert IPv4 address to the Buffer.

  • pton6(addr: string, [[dest: Buffer], index: number]): Buffer

Convert IPv6 address to the Buffer.

  • constants: Object

    • IPV4_OCTETS - size of IPv4 target buffer.
    • IPV6_OCTETS - size of IPv6 target buffer.

License

MIT, 2017 (c) Dmitry Tsvettsikh

Keywords

FAQs

Last updated on 02 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc