node-netmask icon indicating copy to clipboard operation
node-netmask copied to clipboard

Add .slice method to retrieve a list of IPs within a block within a range

Open mdwheele opened this issue 1 year ago • 0 comments

Hello!

💁 This PR adds a method to retrieve a subset of IP addresses within a block based on offset.

The primary reasoning for me putting this together was that in order to do this, I was having to either chain calls to .next(1) over and over or use .forEach to build a list of the IPs I needed based on offset.

Alternative Approaches

  • Instead of implementing .slice, we could instead provide an accessor that returns an array of all IP addresses within a block. With this, the client can apply whatever transform they want.

Remaining work

  • [ ] Add tests for "un-happy paths" (what happens when I slice out of range?)
  • [ ] Update documentation

mdwheele avatar Oct 18 '24 13:10 mdwheele