1. parse-hosts
Parse the hosts file.
parse-hosts
Package: parse-hosts
Created by: takanopontaro
Last modified: Thu, 23 Jun 2022 10:45:12 GMT
Version: 1.0.1
License: MIT
Downloads: 75
Repository: https://github.com/takanopontaro/node-parse-hosts

Install

npm install parse-hosts
yarn add parse-hosts

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

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code