1652085928
ipaddr.js — An IPv6 and IPv4 address manipulation library
ipaddr.js is a small (1.9K minified and gzipped) library for manipulating IP addresses in JavaScript environments. It runs on both CommonJS runtimes (e.g. nodejs) and in a web browser.
ipaddr.js allows you to verify and parse string representation of an IP address, match it against a CIDR range or range list, determine if it falls into some reserved ranges (examples include loopback and private ranges), and convert between IPv4 and IPv4-mapped IPv6 addresses.
npm install ipaddr.js
or
bower install ipaddr.js
Use 2.x release for nodejs versions 10+. Use the 1.x release for versions of nodejs older than 10.
ipaddr.js defines one object in the global scope: ipaddr
. In CommonJS, it is exported from the module:
const ipaddr = require('ipaddr.js');
The API consists of several global methods and two classes: ipaddr.IPv6 and ipaddr.IPv4.
There are three global methods defined: ipaddr.isValid
, ipaddr.parse
and ipaddr.process
. All of them receive a string as a single parameter.
The ipaddr.isValid
method returns true
if the address is a valid IPv4 or IPv6 address, and false
otherwise. It does not throw any exceptions.
The ipaddr.parse
method returns an object representing the IP address, or throws an Error
if the passed string is not a valid representation of an IP address.
The ipaddr.process
method works just like the ipaddr.parse
one, but it automatically converts IPv4-mapped IPv6 addresses to their IPv4 counterparts before returning. It is useful when you have a Node.js instance listening on an IPv6 socket, and the net.ivp6.bindv6only
sysctl parameter (or its equivalent on non-Linux OS) is set to 0. In this case, you can accept IPv4 connections on your IPv6-only socket, but the remote address will be mangled. Use ipaddr.process
method to automatically demangle it.
Parsing methods return an object which descends from ipaddr.IPv6
or ipaddr.IPv4
. These objects share some properties, but most of them differ.
One can determine the type of address by calling addr.kind()
. It will return either "ipv6"
or "ipv4"
.
An address can be converted back to its string representation with addr.toString()
. Note that this method:
A match(range, bits)
method can be used to check if the address falls into a certain CIDR range. Note that an address can be (obviously) matched only against an address of the same type.
For example:
const addr = ipaddr.parse('2001:db8:1234::1');
const range = ipaddr.parse('2001:db8::');
addr.match(range, 32); // => true
Alternatively, match
can also be called as match([range, bits])
. In this way, it can be used together with the parseCIDR(string)
method, which parses an IP address together with a CIDR range.
For example:
const addr = ipaddr.parse('2001:db8:1234::1');
addr.match(ipaddr.parseCIDR('2001:db8::/32')); // => true
A range()
method returns one of predefined names for several special ranges defined by IP protocols. The exact names (and their respective CIDR ranges) can be looked up in the source: IPv6 ranges and IPv4 ranges. Some common ones include "unicast"
(the default one) and "reserved"
.
You can match against your own range list by using ipaddr.subnetMatch(address, rangeList, defaultName)
method. It can work with a mix of IPv6 or IPv4 addresses, and accepts a name-to-subnet map as the range list. For example:
const rangeList = {
documentationOnly: [ ipaddr.parse('2001:db8::'), 32 ],
tunnelProviders: [
[ ipaddr.parse('2001:470::'), 32 ], // he.net
[ ipaddr.parse('2001:5c0::'), 32 ] // freenet6
]
};
ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "tunnelProviders"
The addresses can be converted to their byte representation with toByteArray()
. (Actually, JavaScript mostly does not know about byte buffers. They are emulated with arrays of numbers, each in range of 0..255.)
const bytes = ipaddr.parse('2a00:1450:8007::68').toByteArray(); // ipv6.google.com
bytes // => [42, 0x00, 0x14, 0x50, 0x80, 0x07, 0x00, <zeroes...>, 0x00, 0x68 ]
The ipaddr.IPv4
and ipaddr.IPv6
objects have some methods defined, too. All of them have the same interface for both protocols, and are similar to global methods.
ipaddr.IPvX.isValid(string)
can be used to check if the string is a valid address for particular protocol, and ipaddr.IPvX.parse(string)
is the error-throwing parser.
ipaddr.IPvX.isValid(string)
uses the same format for parsing as the POSIX inet_ntoa
function, which accepts unusual formats like 0xc0.168.1.1
or 0x10000000
. The function ipaddr.IPv4.isValidFourPartDecimal(string)
validates the IPv4 address and also ensures that it is written in four-part decimal format.
Sometimes you will want to convert IPv6 not to a compact string representation (with the ::
substitution); the toNormalizedString()
method will return an address where all zeroes are explicit.
For example:
const addr = ipaddr.parse('2001:0db8::0001');
addr.toString(); // => '2001:db8::1'
addr.toNormalizedString(); // => '2001:db8:0:0:0:0:0:1'
The isIPv4MappedAddress()
method will return true
if this address is an IPv4-mapped one, and toIPv4Address()
will return an IPv4 object address.
To access the underlying binary representation of the address, use addr.parts
.
const addr = ipaddr.parse('2001:db8:10::1234:DEAD');
addr.parts // => [0x2001, 0xdb8, 0x10, 0, 0, 0, 0x1234, 0xdead]
A IPv6 zone index can be accessed via addr.zoneId
:
const addr = ipaddr.parse('2001:db8::%eth0');
addr.zoneId // => 'eth0'
toIPv4MappedAddress()
will return a corresponding IPv4-mapped IPv6 address.
To access the underlying representation of the address, use addr.octets
.
const addr = ipaddr.parse('192.168.1.1');
addr.octets // => [192, 168, 1, 1]
prefixLengthFromSubnetMask()
will return a CIDR prefix length for a valid IPv4 netmask or null if the netmask is not valid.
ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask() == 28
ipaddr.IPv4.parse('255.192.164.0').prefixLengthFromSubnetMask() == null
subnetMaskFromPrefixLength()
will return an IPv4 netmask for a valid CIDR prefix length.
ipaddr.IPv4.subnetMaskFromPrefixLength(24) == '255.255.255.0'
ipaddr.IPv4.subnetMaskFromPrefixLength(29) == '255.255.255.248'
broadcastAddressFromCIDR()
will return the broadcast address for a given IPv4 interface and netmask in CIDR notation.
ipaddr.IPv4.broadcastAddressFromCIDR('172.0.0.1/24') == '172.0.0.255'
networkAddressFromCIDR()
will return the network address for a given IPv4 interface and netmask in CIDR notation.
ipaddr.IPv4.networkAddressFromCIDR('172.0.0.1/24') == '172.0.0.0'
IPv4 and IPv6 can be converted bidirectionally to and from network byte order (MSB) byte arrays.
The fromByteArray()
method will take an array and create an appropriate IPv4 or IPv6 object if the input satisfies the requirements. For IPv4 it has to be an array of four 8-bit values, while for IPv6 it has to be an array of sixteen 8-bit values.
For example:
const addr = ipaddr.fromByteArray([0x7f, 0, 0, 1]);
addr.toString(); // => '127.0.0.1'
or
const addr = ipaddr.fromByteArray([0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
addr.toString(); // => '2001:db8::1'
Both objects also offer a toByteArray()
method, which returns an array in network byte order (MSB).
For example:
const addr = ipaddr.parse('127.0.0.1');
addr.toByteArray(); // => [0x7f, 0, 0, 1]
or
const addr = ipaddr.parse('2001:db8::1');
addr.toByteArray(); // => [0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
Author: Whitequark
Source Code: https://github.com/whitequark/ipaddr.js
License: MIT license
1632537859
Not babashka. Node.js babashka!?
Ad-hoc CLJS scripting on Node.js.
Experimental. Please report issues here.
Nbb's main goal is to make it easy to get started with ad hoc CLJS scripting on Node.js.
Additional goals and features are:
Nbb requires Node.js v12 or newer.
CLJS code is evaluated through SCI, the same interpreter that powers babashka. Because SCI works with advanced compilation, the bundle size, especially when combined with other dependencies, is smaller than what you get with self-hosted CLJS. That makes startup faster. The trade-off is that execution is less performant and that only a subset of CLJS is available (e.g. no deftype, yet).
Install nbb
from NPM:
$ npm install nbb -g
Omit -g
for a local install.
Try out an expression:
$ nbb -e '(+ 1 2 3)'
6
And then install some other NPM libraries to use in the script. E.g.:
$ npm install csv-parse shelljs zx
Create a script which uses the NPM libraries:
(ns script
(:require ["csv-parse/lib/sync$default" :as csv-parse]
["fs" :as fs]
["path" :as path]
["shelljs$default" :as sh]
["term-size$default" :as term-size]
["zx$default" :as zx]
["zx$fs" :as zxfs]
[nbb.core :refer [*file*]]))
(prn (path/resolve "."))
(prn (term-size))
(println (count (str (fs/readFileSync *file*))))
(prn (sh/ls "."))
(prn (csv-parse "foo,bar"))
(prn (zxfs/existsSync *file*))
(zx/$ #js ["ls"])
Call the script:
$ nbb script.cljs
"/private/tmp/test-script"
#js {:columns 216, :rows 47}
510
#js ["node_modules" "package-lock.json" "package.json" "script.cljs"]
#js [#js ["foo" "bar"]]
true
$ ls
node_modules
package-lock.json
package.json
script.cljs
Nbb has first class support for macros: you can define them right inside your .cljs
file, like you are used to from JVM Clojure. Consider the plet
macro to make working with promises more palatable:
(defmacro plet
[bindings & body]
(let [binding-pairs (reverse (partition 2 bindings))
body (cons 'do body)]
(reduce (fn [body [sym expr]]
(let [expr (list '.resolve 'js/Promise expr)]
(list '.then expr (list 'clojure.core/fn (vector sym)
body))))
body
binding-pairs)))
Using this macro we can look async code more like sync code. Consider this puppeteer example:
(-> (.launch puppeteer)
(.then (fn [browser]
(-> (.newPage browser)
(.then (fn [page]
(-> (.goto page "https://clojure.org")
(.then #(.screenshot page #js{:path "screenshot.png"}))
(.catch #(js/console.log %))
(.then #(.close browser)))))))))
Using plet
this becomes:
(plet [browser (.launch puppeteer)
page (.newPage browser)
_ (.goto page "https://clojure.org")
_ (-> (.screenshot page #js{:path "screenshot.png"})
(.catch #(js/console.log %)))]
(.close browser))
See the puppeteer example for the full code.
Since v0.0.36, nbb includes promesa which is a library to deal with promises. The above plet
macro is similar to promesa.core/let
.
$ time nbb -e '(+ 1 2 3)'
6
nbb -e '(+ 1 2 3)' 0.17s user 0.02s system 109% cpu 0.168 total
The baseline startup time for a script is about 170ms seconds on my laptop. When invoked via npx
this adds another 300ms or so, so for faster startup, either use a globally installed nbb
or use $(npm bin)/nbb script.cljs
to bypass npx
.
Nbb does not depend on any NPM dependencies. All NPM libraries loaded by a script are resolved relative to that script. When using the Reagent module, React is resolved in the same way as any other NPM library.
To load .cljs
files from local paths or dependencies, you can use the --classpath
argument. The current dir is added to the classpath automatically. So if there is a file foo/bar.cljs
relative to your current dir, then you can load it via (:require [foo.bar :as fb])
. Note that nbb
uses the same naming conventions for namespaces and directories as other Clojure tools: foo-bar
in the namespace name becomes foo_bar
in the directory name.
To load dependencies from the Clojure ecosystem, you can use the Clojure CLI or babashka to download them and produce a classpath:
$ classpath="$(clojure -A:nbb -Spath -Sdeps '{:aliases {:nbb {:replace-deps {com.github.seancorfield/honeysql {:git/tag "v2.0.0-rc5" :git/sha "01c3a55"}}}}}')"
and then feed it to the --classpath
argument:
$ nbb --classpath "$classpath" -e "(require '[honey.sql :as sql]) (sql/format {:select :foo :from :bar :where [:= :baz 2]})"
["SELECT foo FROM bar WHERE baz = ?" 2]
Currently nbb
only reads from directories, not jar files, so you are encouraged to use git libs. Support for .jar
files will be added later.
The name of the file that is currently being executed is available via nbb.core/*file*
or on the metadata of vars:
(ns foo
(:require [nbb.core :refer [*file*]]))
(prn *file*) ;; "/private/tmp/foo.cljs"
(defn f [])
(prn (:file (meta #'f))) ;; "/private/tmp/foo.cljs"
Nbb includes reagent.core
which will be lazily loaded when required. You can use this together with ink to create a TUI application:
$ npm install ink
ink-demo.cljs
:
(ns ink-demo
(:require ["ink" :refer [render Text]]
[reagent.core :as r]))
(defonce state (r/atom 0))
(doseq [n (range 1 11)]
(js/setTimeout #(swap! state inc) (* n 500)))
(defn hello []
[:> Text {:color "green"} "Hello, world! " @state])
(render (r/as-element [hello]))
Working with callbacks and promises can become tedious. Since nbb v0.0.36 the promesa.core
namespace is included with the let
and do!
macros. An example:
(ns prom
(:require [promesa.core :as p]))
(defn sleep [ms]
(js/Promise.
(fn [resolve _]
(js/setTimeout resolve ms))))
(defn do-stuff
[]
(p/do!
(println "Doing stuff which takes a while")
(sleep 1000)
1))
(p/let [a (do-stuff)
b (inc a)
c (do-stuff)
d (+ b c)]
(prn d))
$ nbb prom.cljs
Doing stuff which takes a while
Doing stuff which takes a while
3
Also see API docs.
Since nbb v0.0.75 applied-science/js-interop is available:
(ns example
(:require [applied-science.js-interop :as j]))
(def o (j/lit {:a 1 :b 2 :c {:d 1}}))
(prn (j/select-keys o [:a :b])) ;; #js {:a 1, :b 2}
(prn (j/get-in o [:c :d])) ;; 1
Most of this library is supported in nbb, except the following:
:syms
.-x
notation. In nbb, you must use keywords.See the example of what is currently supported.
See the examples directory for small examples.
Also check out these projects built with nbb:
See API documentation.
See this gist on how to convert an nbb script or project to shadow-cljs.
Prequisites:
To build:
bb release
Run bb tasks
for more project-related tasks.
Download Details:
Author: borkdude
Download Link: Download The Source Code
Official Website: https://github.com/borkdude/nbb
License: EPL-1.0
#node #javascript
1608637001
How to get country name from IP address in Laravel 8 app. In this tutorial, i will show you How to get country city state zip code metro code from IP address in Laravel 8 app.
https://www.tutsmake.com/laravel-8-get-country-city-address-from-ip-address-tutorial/
#get location from ip address in laravel #laravel address from ip address #laravel get country city from ip address #laravel get user country by ip #laravel geoip to address
1652085928
ipaddr.js — An IPv6 and IPv4 address manipulation library
ipaddr.js is a small (1.9K minified and gzipped) library for manipulating IP addresses in JavaScript environments. It runs on both CommonJS runtimes (e.g. nodejs) and in a web browser.
ipaddr.js allows you to verify and parse string representation of an IP address, match it against a CIDR range or range list, determine if it falls into some reserved ranges (examples include loopback and private ranges), and convert between IPv4 and IPv4-mapped IPv6 addresses.
npm install ipaddr.js
or
bower install ipaddr.js
Use 2.x release for nodejs versions 10+. Use the 1.x release for versions of nodejs older than 10.
ipaddr.js defines one object in the global scope: ipaddr
. In CommonJS, it is exported from the module:
const ipaddr = require('ipaddr.js');
The API consists of several global methods and two classes: ipaddr.IPv6 and ipaddr.IPv4.
There are three global methods defined: ipaddr.isValid
, ipaddr.parse
and ipaddr.process
. All of them receive a string as a single parameter.
The ipaddr.isValid
method returns true
if the address is a valid IPv4 or IPv6 address, and false
otherwise. It does not throw any exceptions.
The ipaddr.parse
method returns an object representing the IP address, or throws an Error
if the passed string is not a valid representation of an IP address.
The ipaddr.process
method works just like the ipaddr.parse
one, but it automatically converts IPv4-mapped IPv6 addresses to their IPv4 counterparts before returning. It is useful when you have a Node.js instance listening on an IPv6 socket, and the net.ivp6.bindv6only
sysctl parameter (or its equivalent on non-Linux OS) is set to 0. In this case, you can accept IPv4 connections on your IPv6-only socket, but the remote address will be mangled. Use ipaddr.process
method to automatically demangle it.
Parsing methods return an object which descends from ipaddr.IPv6
or ipaddr.IPv4
. These objects share some properties, but most of them differ.
One can determine the type of address by calling addr.kind()
. It will return either "ipv6"
or "ipv4"
.
An address can be converted back to its string representation with addr.toString()
. Note that this method:
A match(range, bits)
method can be used to check if the address falls into a certain CIDR range. Note that an address can be (obviously) matched only against an address of the same type.
For example:
const addr = ipaddr.parse('2001:db8:1234::1');
const range = ipaddr.parse('2001:db8::');
addr.match(range, 32); // => true
Alternatively, match
can also be called as match([range, bits])
. In this way, it can be used together with the parseCIDR(string)
method, which parses an IP address together with a CIDR range.
For example:
const addr = ipaddr.parse('2001:db8:1234::1');
addr.match(ipaddr.parseCIDR('2001:db8::/32')); // => true
A range()
method returns one of predefined names for several special ranges defined by IP protocols. The exact names (and their respective CIDR ranges) can be looked up in the source: IPv6 ranges and IPv4 ranges. Some common ones include "unicast"
(the default one) and "reserved"
.
You can match against your own range list by using ipaddr.subnetMatch(address, rangeList, defaultName)
method. It can work with a mix of IPv6 or IPv4 addresses, and accepts a name-to-subnet map as the range list. For example:
const rangeList = {
documentationOnly: [ ipaddr.parse('2001:db8::'), 32 ],
tunnelProviders: [
[ ipaddr.parse('2001:470::'), 32 ], // he.net
[ ipaddr.parse('2001:5c0::'), 32 ] // freenet6
]
};
ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "tunnelProviders"
The addresses can be converted to their byte representation with toByteArray()
. (Actually, JavaScript mostly does not know about byte buffers. They are emulated with arrays of numbers, each in range of 0..255.)
const bytes = ipaddr.parse('2a00:1450:8007::68').toByteArray(); // ipv6.google.com
bytes // => [42, 0x00, 0x14, 0x50, 0x80, 0x07, 0x00, <zeroes...>, 0x00, 0x68 ]
The ipaddr.IPv4
and ipaddr.IPv6
objects have some methods defined, too. All of them have the same interface for both protocols, and are similar to global methods.
ipaddr.IPvX.isValid(string)
can be used to check if the string is a valid address for particular protocol, and ipaddr.IPvX.parse(string)
is the error-throwing parser.
ipaddr.IPvX.isValid(string)
uses the same format for parsing as the POSIX inet_ntoa
function, which accepts unusual formats like 0xc0.168.1.1
or 0x10000000
. The function ipaddr.IPv4.isValidFourPartDecimal(string)
validates the IPv4 address and also ensures that it is written in four-part decimal format.
Sometimes you will want to convert IPv6 not to a compact string representation (with the ::
substitution); the toNormalizedString()
method will return an address where all zeroes are explicit.
For example:
const addr = ipaddr.parse('2001:0db8::0001');
addr.toString(); // => '2001:db8::1'
addr.toNormalizedString(); // => '2001:db8:0:0:0:0:0:1'
The isIPv4MappedAddress()
method will return true
if this address is an IPv4-mapped one, and toIPv4Address()
will return an IPv4 object address.
To access the underlying binary representation of the address, use addr.parts
.
const addr = ipaddr.parse('2001:db8:10::1234:DEAD');
addr.parts // => [0x2001, 0xdb8, 0x10, 0, 0, 0, 0x1234, 0xdead]
A IPv6 zone index can be accessed via addr.zoneId
:
const addr = ipaddr.parse('2001:db8::%eth0');
addr.zoneId // => 'eth0'
toIPv4MappedAddress()
will return a corresponding IPv4-mapped IPv6 address.
To access the underlying representation of the address, use addr.octets
.
const addr = ipaddr.parse('192.168.1.1');
addr.octets // => [192, 168, 1, 1]
prefixLengthFromSubnetMask()
will return a CIDR prefix length for a valid IPv4 netmask or null if the netmask is not valid.
ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask() == 28
ipaddr.IPv4.parse('255.192.164.0').prefixLengthFromSubnetMask() == null
subnetMaskFromPrefixLength()
will return an IPv4 netmask for a valid CIDR prefix length.
ipaddr.IPv4.subnetMaskFromPrefixLength(24) == '255.255.255.0'
ipaddr.IPv4.subnetMaskFromPrefixLength(29) == '255.255.255.248'
broadcastAddressFromCIDR()
will return the broadcast address for a given IPv4 interface and netmask in CIDR notation.
ipaddr.IPv4.broadcastAddressFromCIDR('172.0.0.1/24') == '172.0.0.255'
networkAddressFromCIDR()
will return the network address for a given IPv4 interface and netmask in CIDR notation.
ipaddr.IPv4.networkAddressFromCIDR('172.0.0.1/24') == '172.0.0.0'
IPv4 and IPv6 can be converted bidirectionally to and from network byte order (MSB) byte arrays.
The fromByteArray()
method will take an array and create an appropriate IPv4 or IPv6 object if the input satisfies the requirements. For IPv4 it has to be an array of four 8-bit values, while for IPv6 it has to be an array of sixteen 8-bit values.
For example:
const addr = ipaddr.fromByteArray([0x7f, 0, 0, 1]);
addr.toString(); // => '127.0.0.1'
or
const addr = ipaddr.fromByteArray([0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
addr.toString(); // => '2001:db8::1'
Both objects also offer a toByteArray()
method, which returns an array in network byte order (MSB).
For example:
const addr = ipaddr.parse('127.0.0.1');
addr.toByteArray(); // => [0x7f, 0, 0, 1]
or
const addr = ipaddr.parse('2001:db8::1');
addr.toByteArray(); // => [0x20, 1, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
Author: Whitequark
Source Code: https://github.com/whitequark/ipaddr.js
License: MIT license
1626321063
PixelCrayons: Our JavaScript web development service offers you a feature-packed & dynamic web application that effectively caters to your business challenges and provide you the best RoI. Our JavaScript web development company works on all major frameworks & libraries like Angular, React, Nodejs, Vue.js, to name a few.
With 15+ years of domain expertise, we have successfully delivered 13800+ projects and have successfully garnered 6800+ happy customers with 97%+ client retention rate.
Looking for professional JavaScript web app development services? We provide custom JavaScript development services applying latest version frameworks and libraries to propel businesses to the next level. Our well-defined and manageable JS development processes are balanced between cost, time and quality along with clear communication.
Our JavaScript development companies offers you strict NDA, 100% money back guarantee and agile/DevOps approach.
#javascript development company #javascript development services #javascript web development #javascript development #javascript web development services #javascript web development company
1652134380
node-cidr
node-cidr is a Javascript library that makes it easy to manipulate IPs and Subnets. Currently only IPv4 is supported, but IPv6 support is planned for a future release.
Variables
● invalidChars: RegExp
= /^.?(?=[^#%&$*:<>?/{|}[a-zA-Z]).$/
Defined in index.ts:3
Functions
► address(ip: string
): string
Defined in index.ts:155
Parameters:
Param | Type | Description |
---|---|---|
ip | string | - |
Returns: string
► broadcast(cidr: string
): string
Defined in index.ts:175
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
► cidrCommonCidr(cidrs: string
[]): string
Defined in index.ts:166
Parameters:
Param | Type | Description |
---|---|---|
cidrs | string [] | - |
Returns: string
► count(cidr: string
): number
Defined in index.ts:190
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: number
► includes(cidr: string
, ip: string
): boolean
Defined in index.ts:240
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
ip | string | - |
Returns: boolean
► intCommonCidr(ips: number
[]): string
Defined in index.ts:5
Parameters:
Param | Type | Description |
---|---|---|
ips | number [] | - |
Returns: string
► ipCommonCidr(ips: string
[]): string
Defined in index.ts:57
Parameters:
Param | Type | Description |
---|---|---|
ips | string [] | - |
Returns: string
► ips(cidr: string
): string
[]
Defined in index.ts:229
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
[]
► mask(ip: string
): number
Defined in index.ts:157
Parameters:
Param | Type | Description |
---|---|---|
ip | string | - |
Returns: number
► max(cidr: string
): string
Defined in index.ts:184
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
► min(cidr: string
): string
Defined in index.ts:177
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
► netmask(cidr: string
): string
Defined in index.ts:172
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
► next(ip: string
): string
Defined in index.ts:111
Returns the next adjacent address.
Parameters:
Param | Type | Description |
---|---|---|
ip | string | - |
Returns: string
► nextCidr(cidr: string
): string
Defined in index.ts:245
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
► padLeft(input: string
, char: string
, min: number
): string
Defined in index.ts:26
Parameters:
Param | Type | Description |
---|---|---|
input | string | - |
char | string | - |
min | number | - |
Returns: string
► previous(ip: string
): string
Defined in index.ts:117
Returns the previous adjacent address.
Parameters:
Param | Type | Description |
---|---|---|
ip | string | - |
Returns: string
► previousCidr(cidr: string
): string
Defined in index.ts:248
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
► random(cidr: string
): string
Defined in index.ts:251
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
► reverse(ip: string
⎮number
): string
Defined in index.ts:73
Returns the reverse lookup hostname for the address.
Parameters:
Param | Type | Description |
---|---|---|
ip | string ⎮number | - |
Returns: string
► subnets(cidr: string
, subMask: number
, limit: number
): string
[]
Defined in index.ts:206
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
subMask | number | - |
limit | number | - |
Returns: string
[]
► toBinary(ip: string
⎮number
): string
Defined in index.ts:84
Returns the binary representation of the address, in string form.
Parameters:
Param | Type | Description |
---|---|---|
ip | string ⎮number | - |
Returns: string
► toCidr(ip: string
⎮number
): string
Defined in index.ts:119
Parameters:
Param | Type | Description |
---|---|---|
ip | string ⎮number | - |
Returns: string
► toHex(ip: string
⎮number
): string
Defined in index.ts:97
Provides the hex value of the address.
Parameters:
Param | Type | Description |
---|---|---|
ip | string ⎮number | - |
Returns: string
► toInt(ipAddress: string
): number
Defined in index.ts:35
Parameters:
Param | Type | Description |
---|---|---|
ipAddress | string | - |
Returns: number
► toIntRange(cidr: string
): number
[]
Defined in index.ts:159
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: number
[]
► toOctets(input: string
⎮number
): number
[]
Defined in index.ts:62
Parameters:
Param | Type | Description |
---|---|---|
input | string ⎮number | - |
Returns: number
[]
► toRange(cidr: string
): string
[]
Defined in index.ts:164
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
[]
► toString(ipInt: number
): string
Defined in index.ts:43
Parameters:
Param | Type | Description |
---|---|---|
ipInt | number | - |
Returns: string
► usable(cidr: string
): string
[]
Defined in index.ts:192
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
[]
► validateCidr(cidr: string
): string
⎮null
Defined in index.ts:256
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
⎮null
► validateIp(ip: string
): string
⎮null
Defined in index.ts:126
Parameters:
Param | Type | Description |
---|---|---|
ip | string | - |
Returns: string
⎮null
► wildcardmask(cidr: string
): string
Defined in index.ts:203
Parameters:
Param | Type | Description |
---|---|---|
cidr | string | - |
Returns: string
● address: address
Defined in index.ts:287
● broadcast: broadcast
Defined in index.ts:280
● commonCidr: cidrCommonCidr = cidrCommonCidr
Defined in index.ts:274
● count: count
Defined in index.ts:277
● includes: includes
Defined in index.ts:283
● ips: ips
Defined in index.ts:282
● mask: mask
Defined in index.ts:288
● max: max
Defined in index.ts:275
● min: min
Defined in index.ts:276
● netmask: netmask
Defined in index.ts:278
● next: nextCidr = nextCidr
Defined in index.ts:285
● previous: previousCidr = previousCidr
Defined in index.ts:286
● random: random
Defined in index.ts:284
● subnets: subnets
Defined in index.ts:281
● toIntRange: toIntRange
Defined in index.ts:273
● toRange: toRange
Defined in index.ts:271
● usable: usable
Defined in index.ts:272
● validate: validateCidr = validateCidr
Defined in index.ts:289
● wildcardmask: wildcardmask
Defined in index.ts:279
● commonCidr: ipCommonCidr = ipCommonCidr
Defined in index.ts:142
● next: next
Defined in index.ts:148
● previous: previous
Defined in index.ts:147
● reverse: reverse
Defined in index.ts:146
● toBinary: toBinary
Defined in index.ts:145
● toCidr: toCidr
Defined in index.ts:149
● toHex: toHex
Defined in index.ts:143
● toInt: toInt
Defined in index.ts:140
● toOctets: toOctets
Defined in index.ts:144
● toString: toString
Defined in index.ts:141
● validate: validateIp = validateIp
Defined in index.ts:150
Author: Arminhammer
Source Code: https://github.com/arminhammer/node-cidr
License: Apache-2.0 license