@latedream/ping
v0.1.0
Published
just a simple ping utility to measure latency to a host.
Maintainers
Readme
@latedream/ping
just a simple ping utility to measure latency to a host.
usage
installation
pnpm add @latedream/ping
# yarn add @latedream/ping
# npm install @latedream/ping
# bun install @latedream/pingesm
import Ping from '@latedream/ping';
const ping = new Ping({
hosts: ['github.com', 'https://latedream.cn', 'http://localhost:5173'],
timeout: 1000
});
(async() => {
const results = await ping.start();
/** ... */
})();cjs
const Ping = require('@latedream/ping');
const ping = new Ping({
hosts: ['github.com', 'https://latedream.cn', 'http://localhost:5173'],
timeout: 1000
});
(async() => {
const results = await ping.start();
/** ... */
})();results
{
'github.com': {
valid: true,
reachable: true,
timeouted: false,
latency: 569,
status: 200,
protocol: 'https:',
url: 'https://github.com',
message: 'OK',
port: 443,
ipType: false
},
'https://latedream.cn': {
valid: true,
reachable: true,
timeouted: false,
latency: 442,
status: 200,
protocol: 'https:',
url: 'https://latedream.cn',
message: 'OK',
port: 443,
ipType: false
},
'http://localhost:5173': {
valid: true,
reachable: true,
timeouted: false,
latency: 12,
status: 200,
protocol: 'http:',
url: 'http://localhost:5173',
message: 'OK',
port: 5173,
ipType: false
}
}umd
<script src="https://cdn.jsdelivr.net/npm/@latedream/[email protected]/dist/index.umd.js"></script>
<script>
const ping = new Ping({
hosts: ['https://github.com', 'https://latedream.cn', 'http://localhost:5173'],
timeout: 1000
});
(async() => {
const results = await ping.start();
/** ... */
})();
</script>results
{
"https://github.com": {
"valid": true,
"reachable": false,
"timeouted": false,
"latency": 679,
"status": 0,
"protocol": "https:",
"url": "https://github.com",
"message": "",
"port": 443,
"ipType": false
},
"https://latedream.cn": {
"valid": true,
"reachable": false,
"timeouted": false,
"latency": 137,
"status": 0,
"protocol": "https:",
"url": "https://latedream.cn",
"message": "",
"port": 443,
"ipType": false
},
"http://localhost:5173": {
"valid": true,
"reachable": false,
"timeouted": false,
"latency": 16,
"status": 0,
"protocol": "http:",
"url": "http://localhost:5173",
"message": "",
"port": 5173,
"ipType": false
}
}license
MIT Copyright (c) 2026 LateDream
