@@ -150,4 +150,51 @@ ws.lookup(ip, addon, lang, (err, data) => {
150150 }
151151});
152152
153- ```
153+ ```
154+
155+ ## IPTOOLS CLASS
156+
157+ ## Methods
158+ Below are the methods supported in this module.
159+
160+ | Method Name| Description|
161+ | ---| ---|
162+ | isIPV4(myIP)| Returns true if string contains an IPv4 address. Otherwise false.|
163+ | isIPV6(myIP)| Returns true if string contains an IPv6 address. Otherwise false.|
164+ | ipV4ToDecimal(myIP)| Returns the IP number for an IPv4 address.|
165+ | ipV6ToDecimal(myIP)| Returns the IP number for an IPv6 address.|
166+ | decimalToIPV4(ipNum)| Returns the IPv4 address for the supplied IP number.|
167+ | decimalToIPV6(ipNum)| Returns the IPv6 address for the supplied IP number.|
168+ | compressIPV6(myIP)| Returns the IPv6 address in compressed form.|
169+ | expandIPV6(myIP)| Returns the IPv6 address in expanded form.|
170+ | ipV4ToCIDR(ipFrom, ipTo)| Returns a list of CIDR from the supplied IPv4 range.|
171+ | ipV6ToCIDR(ipFrom, ipTo)| Returns a list of CIDR from the supplied IPv6 range.|
172+ | cidrToIPV4(cidr)| Returns the IPv4 range from the supplied CIDR.|
173+ | cidrToIPV6(cidr)| Returns the IPv6 range from the supplied CIDR.|
174+
175+ ## Usage
176+
177+ ``` javascript
178+ const {IPTools } = require (" ip2location-nodejs" );
179+
180+ let tools = new IPTools ();
181+
182+ console .log (tools .isIPV4 (" 60.54.166.38" ));
183+ console .log (tools .isIPV6 (" 2001:4860:4860::8888" ));
184+ console .log (tools .ipV4ToDecimal (" 60.54.166.38" ));
185+ console .log (tools .ipV6ToDecimal (" 2001:4860:4860::8888" ));
186+ console .log (tools .decimalToIPV4 (1010214438 ));
187+ console .log (tools .decimalToIPV6 (" 530610913025797008819807084026527744" ));
188+ console .log (tools .compressIPV6 (" 66:3123:4860:3234:411:23:000:000" ));
189+ console .log (tools .expandIPV6 (" 66:023:40:34:411:23:000:000" ));
190+ let cidr = tools .ipV4ToCIDR (" 10.0.0.0" , " 10.10.2.255" );
191+ for (const x of cidr) {
192+ console .log (x);
193+ }
194+ cidr = tools .ipV6ToCIDR (" 2001:4860:4860:0000:0000:0000:0000:8888" , " 2001:4860:4860:0000:eeee:ffff:ffff:ffff" );
195+ for (const x of cidr) {
196+ console .log (x);
197+ }
198+ console .log (tools .cidrToIPV4 (" 10.123.80.0/12" ));
199+ console .log (tools .cidrToIPV6 (" 2002:1234::abcd:ffff:c0a8:101/62" ));
200+ ```
0 commit comments