Skip to content

Commit

Permalink
Merge pull request #9 from karelkryda/dev
Browse files Browse the repository at this point in the history
Version 2.0.0
  • Loading branch information
karelkryda authored Dec 10, 2021
2 parents 545475f + b1fdd19 commit 469ef22
Show file tree
Hide file tree
Showing 26 changed files with 3,470 additions and 2,388 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
74 changes: 37 additions & 37 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"env": {
"es6": true,
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"no-console": "off",
"linebreak-style": "off",
"quotes": [
"error",
"double",
{
"allowTemplateLiterals": true
}
],
"env": {
"es6": true,
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
"keyword-spacing": [
"error",
{
"before": true
}
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-console": "off",
"linebreak-style": "off",
"quotes": [
"error",
"double",
{
"allowTemplateLiterals": true
}
],
"keyword-spacing": [
"error",
{
"before": true
}
],
"space-before-blocks": [
"error"
]
}
"space-before-blocks": [
"error"
]
}
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ dist
.dynamodb/

# TernJS port file
.tern-port
.tern-port

# Test file
test.ts
32 changes: 16 additions & 16 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"cache": false,
"check-coverage": true,
"extension": [
".ts"
],
"include": [
"**/src/*.ts"
],
"reporter": [
"cobertura",
"text-summary"
],
"statements": 90,
"branches": 90,
"functions": 90,
"lines": 90
"cache": false,
"check-coverage": true,
"extension": [
".ts"
],
"include": [
"**/src/*.ts"
],
"reporter": [
"cobertura",
"text-summary"
],
"statements": 90,
"branches": 90,
"functions": 90,
"lines": 90
}
70 changes: 10 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,22 @@
<a href="https://fast.com"><img src="https://fast.com/assets/new-logo-vert-37861c.svg" alt="fast.com logo" height="120px" /></a>

<a href="https://www.netmetr.cz/en"><img src="https://www.netmetr.cz/theme/images/netmetr-logo.svg" alt="netmetr.cz logo" height="120px" /></a>

<a href="https://www.speedtest.net/"><img src="https://upload.wikimedia.org/wikipedia/commons/0/09/Speedtest.net_logo.svg" alt="netmetr.cz logo" height="120px" /></a>
# Universal Speedtest

# universal-speedtest
[![Build Status](https://travis-ci.com/karelkryda/universal-speedtest.svg?branch=master)](https://travis-ci.com/github/karelkryda/universal-speedtest)
[![NPM version](https://img.shields.io/npm/v/universal-speedtest.svg?colorB=0a7bbb)](https://www.npmjs.com/package/universal-speedtest)
[![GitHub license](https://img.shields.io/github/license/karelkryda/universal-speedtest.svg?colorB=0a7bbb)](https://github.com/karelkryda/universal-speedtest/blob/master/LICENSE)

Measure the speed of your internet connection with Netflix's Fast.com speed test, cz.nic's Netmetr.cz speed test or Ookla's Speedtest.net speed test.
Measure the speed of your internet connection with various speed tests.

## Installation

```bash
$ npm install --save universal-speedtest
```
## Documentation:
For Universal Speedtest v2, visit the new [documentation](https://karel-kryda.gitbook.io/universal-speedtest/)

## Example usage
```js
const { UniversalSpeedTest, SpeedUnits } = require('universal-speedtest');

const SpeedTest = new UniversalSpeedTest({
measureUpload: true,
downloadUnit: SpeedUnits.MBps,
timeout: 60000
});

SpeedTest.runTestByFast().then(result => {
console.log(`Ping: ${result.ping} ${result.pingUnit}`);
console.log(`Download speed: ${result.downloadSpeed} ${result.downloadUnit}`);
console.log(`Upload speed: ${result.uploadSpeed} ${result.uploadUnit}`);
}).catch(e => {
console.error(e.message);
});
```

## Available Test Pages
|Function | Page |
| :--------------------| :------ |
|runTestByFast() | Fast.com |
|runTestByNetmetr() | Netmetr.cz |
|runTestBySpeedtest() | Speedtest.net |

## Available Options
|Property | Type | Default | Description |
| :-------------------------------| :------ | :--------- | :---------------------------------------------------------------------------- |
|measureUpload <sup>**F**</sup> | Boolean | false | To wait for the upload speed result |
|uploadUnit | SpeedUnits / String | Mbps | The resulting unit of upload speed |
|downloadUnit | SpeedUnits / String | Mbps | The resulting unit of download speed |
|timeout | Number | 40000 | Limit how long the speed test can run |
|executablePath | String | - | Path to the Chrome startup file. You can use it if Puppeteer failed to start. |

**F** only available for Fast.com speed test

## Test result
|Property | Type | Description |
| :--------------------------------| :------ | :---------------------------- |
|ping* | Number | Network ping |
|downloadSpeed | Number | Network download speed |
|uploadSpeed* | Number | Network upload speed |
|pingUnit* | String | Network ping unit |
|downloadUnit | String | Network download speed unit |
|uploadUnit* | String | Network upload speed unit |
|servers <sup>**F**</sup> | String[] | Location(s) of test server(s) |

\* only available when the "measureUpload" property is set to true

**F** only available for Fast.com speed test
## Beta release
Until release 2.1, this is a beta version. There may be bugs in the library that will need to be fixed.
<br>
I'll be happy if you open and report a problem, if you find one, and help me improve this library.

## TODO
I want to make this package multifunctional to allow the use of additional speed testing sites and to allow you to choose the best test exactly for you.
Thank you for understanding
50 changes: 25 additions & 25 deletions codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,34 @@ jobs:
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
Loading

0 comments on commit 469ef22

Please sign in to comment.