Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add eslint, support node>=6.0.0, update document, fix minor bugs #94

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
"extends": "standard",
"env": {
"node": true,
"mocha": true
},
"rules": {
"new-cap": ["error", { "properties": false }]
}
};
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
sudo: false
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "4"
#- "0.8"
#- "0.10"
#- "0.12"
#- "4.4"
- "6"
- "8"

before_install:
- travis_retry npm install -g npm@2.14.5
#- travis_retry npm install -g npm@v3.2.0
- travis_retry npm install

script:
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# IP
[![](https://badge.fury.io/js/ip.svg)](https://www.npmjs.com/package/ip)
[![](https://badge.fury.io/js/ip.svg)](https://www.npmjs.com/package/ip) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)


IP address utilities for node.js

Expand All @@ -22,8 +23,22 @@ Get your ip address, compare ip addresses, validate ip addresses, etc.
```js
var ip = require('ip');

/**
* @param {string} name **Optional** {'public'|'private'},
* Name or security of the network interface like "Docket" | "Wi-Fi",
* if neme set `undefined` return first address of the interface with `ipv4` or loopback address,
* if name set `public` return first public ip address,
* or if name set `private` return first public ip address.
* @param {string} family **Optional** {ipv4|ipv6} IP family of the address (defaults: ipv4).
* @returns {string} Returns the address for the network interface on the current system.
*/
ip.address() // my ip address
ip.isEqual('::1', '::0:1'); // true
ip.address('Wi-Fi') // Obtain Wi-Fi IPV4 address
ip.address('vEthernet (DockerNAT)') // Obtain DocketNAt IPV4 address
ip.address('private') // Obtain private IPV4 address
ip.address('public','ipv6') // Obtain public IPV6 address

ip.isEqual('::1', '::0:1') // true
ip.toBuffer('127.0.0.1') // Buffer([127, 0, 0, 1])
ip.toString(new Buffer([127, 0, 0, 1])) // 127.0.0.1
ip.fromPrefixLen(24) // 255.255.255.0
Expand All @@ -33,7 +48,7 @@ ip.not('255.255.255.0') // 0.0.0.255
ip.or('192.168.1.134', '0.0.0.255') // 192.168.1.255
ip.isPrivate('127.0.0.1') // true
ip.isV4Format('127.0.0.1'); // true
ip.isV6Format('::ffff:127.0.0.1'); // true
ip.isV6Format('::ffff:127.0.0.1') // true

// operate on buffers in-place
var buf = new Buffer(128);
Expand All @@ -60,10 +75,10 @@ ip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true


// ipv4 long conversion
ip.toLong('127.0.0.1'); // 2130706433
ip.fromLong(2130706433); // '127.0.0.1'
ip.toLong('127.0.0.1') // 2130706433
ip.fromLong(2130706433) // '127.0.0.1'
```

[![js-standard-style](https://cdn.rawgit.com/standard/standard/master/badge.svg)](http://standardjs.com)
### License

This software is licensed under the MIT License.
Expand Down
Loading