parse-hosts

1.0.1 • Public • Published

parse-hosts

Parse the hosts file and return its list.

Install

npm install parse-hosts

Usage

var ph = require('parse-hosts');
 
// just call this
ph.get();
 
// the return value is object.
// key is ip address and value is array of hostnames.
// {
//   '127.0.0.1': ['localhost'],
//   '192.168.50.1': ['host1', 'host2']
// }
 
// you can specify the location of the hosts file.
ph.get('/path/to/hosts');
 
// if you want to get "127.0.0.1" mapped to "localhost" regardless of whether
// it's in the hosts file, use optimize(). this method ensures generating it.
ph.optimize();

Test

npm test

License

Licensed under the MIT license.

Special thanks to

Readme

Keywords

Package Sidebar

Install

npm i parse-hosts

Weekly Downloads

12

Version

1.0.1

License

MIT

Last publish

Collaborators

  • takanopontaro