Skip to content

Commit

Permalink
Fix: Update lowbandwidth condition to match new spec (Modernizr#2688)
Browse files Browse the repository at this point in the history
* Update lowbandwidth condition to match new spec

* Bump minimist and minimist

Bumps [minimist](https://github.com/substack/minimist) and [minimist](https://github.com/substack/minimist). These dependencies needed to be updated together.

Updates `minimist` from 1.2.6 to 1.2.6
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.6...1.2.6)

Updates `minimist` from 1.2.5 to 1.2.6
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.6...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: veeck <michael@veeck.de>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 12, 2022
1 parent 5c77c43 commit 6752ffb
Show file tree
Hide file tree
Showing 2 changed files with 332 additions and 64 deletions.
12 changes: 8 additions & 4 deletions feature-detects/network/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* DOC
Tests for determining low-bandwidth via `navigator.connection`
There are two iterations of the `navigator.connection` interface.
There are three iterations of the `navigator.connection` interface.
The first is present in Android 2.2+ and only in the Browser (not WebView)
Expand All @@ -22,15 +22,19 @@ The second is speced at https://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Over
Unknown devices are assumed as fast
The third is placed at https://wicg.github.io/netinfo/
- Support for the old type now only exists in Android 4 and below (https://caniuse.com/netinfo)
For more rigorous network testing, consider boomerang.js: https://github.com/bluesmoon/boomerang/
*/
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('lowbandwidth', function() {
// polyfill
var connection = navigator.connection || {type: 0};
// Polyfill the network info API to inculde both the old type and new effectiveType
var connection = navigator.connection || {type: 0, effectiveType: 0};

return connection.type === 3 || // connection.CELL_2G
connection.type === 4 || // connection.CELL_3G
/^[23]g$/.test(connection.type); // string value in new spec
/^[23]g$/.test(connection.effectiveType); // string value in new spec
});
});
Loading

0 comments on commit 6752ffb

Please sign in to comment.