~toastal/purescript-web-network-information

Type definitions & low-level interface implementations for the W3C Network Information API
Lint check + Flake update
Upgrade PureScript packages
Add 2022 year + α matches Hindley–Milner

clone

read-only
https://git.sr.ht/~toastal/purescript-web-network-information
read/write
git@git.sr.ht:~toastal/purescript-web-network-information

You can also use your local clone with git send-email.

purescript-web-networks-information

Type definitions & low-level interface implementations for the W3C Network Information API. Alternatively, MDN’s Network Information API. Currently this is in an unofficial draft state, however as seen on Can I Use support is sporadic, but exists. As such values will return Maybe values to cover undefined for practical use.

Example use cases reacting to the data provided from NetworkInformation
We have autoplaying video, but the user agent has requested that we “save data” so we will not not autoplay the video.
We have a payload that is medium-sized, but the user agent’s downlink speed indicates that we may want to show a spinner; however on 4G-like connections, we know the download will be under 200ms, low enough that a spinner would be a jarring experience be shown and then immediately dismissed.

Installation

When PureScript’s package-sets is finally extended to include alternative Git forges, including Sourcehut, install would be:

Via spago
$ spago install web-page-visibility

Until then, one will have to add this project to their packages.dhall

License

This project is licensed under The 3-Clause BSD License (BSD-3-Clause) — see the LICENSE file in this project for details.

Setup

Git

Hooks and config
$ git config --local include.path ../.gitconfig
$ git config --local core.hooksPath .githooks

Nix + Flakes

For dev shell
$ nix develop
For automatic shell via direnv
$ cp .envrc.example .envrc
$ direnv allow
Caching via Cachix
$ cachix use toastal-purescript-web

Not Nix

Requirements
package version
purs ~0.14.4
spago ^0.20.2
purs-tidy latest

Although assume the flake.{nix,lock} as the source of truth.


Funding

While this project is under my personal repository and not in purescript-web (and will be so long as it’s in such a draft state), you can to make a small contribution to the maintanence of this & other projects