https://github.com/pine/is-lo
:repeat: Check if it is a loopback network interface or not
https://github.com/pine/is-lo
ip ipv4 ipv6 javascript nodejs
Last synced: 8 months ago
JSON representation
:repeat: Check if it is a loopback network interface or not
- Host: GitHub
- URL: https://github.com/pine/is-lo
- Owner: pine
- License: mit
- Created: 2016-07-19T05:48:46.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-01-04T07:32:52.000Z (over 3 years ago)
- Last Synced: 2025-07-20T05:52:25.709Z (9 months ago)
- Topics: ip, ipv4, ipv6, javascript, nodejs
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/is-lo
- Size: 52.7 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-lo [](https://www.npmjs.org/package/is-lo) [](https://github.com/pine/is-lo/actions/workflows/build.yml) [](LICENSE)
:repeat: Check if it is a loopback network interface or not
## Features
- Supports TypeScript
- Supports both CommonJS and ESModules
## Getting Started
```sh
$ npm install --save is-lo # for npm users
$ yarn add is-lo # for yarn users
```
## Breaking Changes
There are breaking changes in `v1.0.0`.
See [the release note](https://github.com/pine/is-lo/releases/tag/v1.0.0) for more details.
## Usage
### ESModules
```js
import os from 'node:os'
import { isLo } from 'is-lo'
const interfaces = os.networkInterfaces()
const names = Object.keys(interfaces)
console.log(isLo(interfaces[names[0]])) // true or false
```
### CommonJS
```js
const os = require('node:os')
const { isLo } = require('is-lo')
const interfaces = os.networkInterfaces()
const names = Object.keys(interfaces)
console.log(isLo(interfaces[names[0]])) // true or false
```
## Reference
### `isLo({ family: 'IPv4', address: '127.0.0.1' })`
### `isLo([ { family: 'IPv4', address: '127.0.0.1' }, ... ])`
- `family` (string): `'IPv4'` or `'IPv6'`
- `address` (string): IP address
- **Result** (bool): true if it is loopback network interface
## Development
### Test
```
$ yarn test
```
### Publish
```
$ yarn publish
```
## License
MIT © [Pine Mizune](https://profile.pine.moe)