@webextensions/parse-hosts
Version:
Parse the hosts file.
54 lines (32 loc) • 851 B
Markdown
**Note:** This is a fork of https://github.com/takanopontaro/node-parse-hosts
Parse the hosts file and return its list.
```shell
npm install parse-hosts
```
```js
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();
```
```shell
npm test
```
Licensed under the MIT license.
* [Keiko Kitagawa](http://official.stardust.co.jp/keiko/)