jdfreder/pingjs
소개
클라이언트 측 JavaScript ping API.
기타 프로젝트측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalpingjs
JavaScript ping API for use in a web browser context. Released under the BSD-3-Clause license, see LICENSE.
Installation
There are three possible ways to install this.
HTML script tag
Drag and drop the ping.js file next to an HTML file. Inside the <head> tag
of the HTML file, use a script tag to load ping.js.
<script src="./ping.js"></script>
NPM
npm install --save web-pingjs
YARN
yarn add web-pingjs
Bower
bower install --save web-pingjs
Usage
This library uses a UMD header that allows it to be loaded as CommonJS, AMD, or a window global object.
A single function is exported, ping. Ping's signature follows:
/**
* Pings a url.
* @param {String} url
* @param {Number} multiplier - optional, factor to adjust the ping by. 0.3 works well for HTTP servers.
* @return {Promise} promise that resolves to a ping (ms, float).
*/
Example:
ping('https://google.com/').then(function(delta) {
console.log('Ping time was ' + String(delta) + ' ms');
}).catch(function(err) {
console.error('Could not ping remote URL', err);
});
Caveats
The user should be aware that this method relies on the HTTP protocol to ping remote URLs. Consequently, ping times are not as reliable as if they were performed using the ICMP protocol.
관련 프로젝트 살펴보기
불러오는 중…