ipterate
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -19,2 +19,9 @@ 'use strict'; | ||
} | ||
async iterateAsync(callback) { | ||
let lastIp; | ||
while (lastIp = this.subnet.nextIp(lastIp)) { | ||
await callback(lastIp); | ||
} | ||
} | ||
}; |
{ | ||
"name": "ipterate", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": " A small utility library to allow you to iterate through all IPs within a given subnet. Remains efficient no matter how many IPs there are in the range.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -34,4 +34,15 @@ # About | ||
If you want to perform an asynchronous action, make sure that your function returns a promise and call `iterateAsync` | ||
instead. `iterateAsync` itself returns a promise and will wait for the resolution of the promise returned by | ||
your delegate, before it provides you with another IP. | ||
const ipterate = require('ipterate'); | ||
const rp = require('request-promise'); | ||
ipterate.range('0.0.0.0/0').iterateAsync(ip => { | ||
return rp.get(ip); | ||
}); | ||
# Installation | ||
npm install --save ipterate |
8498
192
47