npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-adaptive-utils

v0.2.1

Published

Deliver empathetic experiences to your users by adapting to their capabilities

Downloads

21

Readme

vue-adaptive-utils

Deliver empathetic experiences to your users by adapting to their capabilities

codecov Build Status Codacy Badge npm npm Average time to resolve an issue Percentage of issues still open

What is this

Inspired by react-adaptive-hooks, and a continuation of my work in vue-use-web.

This is a collection of Vue 3.0 composition API functions and utilties to allow your apps to adapt your user's:

  • Network conditions.
  • Battery Status.
  • CPU Cores.
  • Device Memory.

I have iterated on this idea multiple times, once in my article: Resource-Adaptive Vue Apps which discussed this idea prior to the introduction of the composition API, I have enhanced the idea even more in my work in vue-use-web.

With the Vue 3.0 composition API introduction, this is a perfect way to consume such functionalities into your components. This library is aimed to Vue 3.0 and already working with the Alpha releases.

Why

This is not "yet another web APIs wrappers for Vue's upcoming composition API", this project aims to focus on only the APIs that allow you to tailor your website experience based on various factors like network status, device memory and more. It allows you to build "adaptive" vue applications that are aware of your users devices limitation and to be more empathetic towards them.

This library aims to bring value with those composition functions, not only mirroring the native web APIs that's underneath.

Install

yarn add vue-adaptive-utils

# or

npm i vue-adaptive-utils --save

Usage

Import the composition function(s) that you will use:

import { useNetworkStatus } from 'vue-adaptive-utils';
import { useBattery } from 'vue-adaptive-utils';
import { useHardwareConcurrency } from 'vue-adaptive-utils';
import { useMemoryStatus } from 'vue-adaptive-utils';

All of the composition functions return an isSupported boolean ref to indicate if the API is supported or not.

⚠ All the values exposed are read only and cannot be mutated.

Network Status

This is a compounded API, meaning it collects various information from multiple APIs, them being the Connection API and online/offline events.

Partial Compatibility: The isSupported flag here refers to the availability of the Connection API, the isOnline and offlineAt properties should be available in all browsers.

import { useNetworkStatus } from 'vue-adaptive-utils';

const {
  isOnline,
  saveData,
  offlineAt,
  downlink,
  downlinkMax,
  effectiveConnectionType,
  networkType,
  isSupported
} = useNetworkStatus();

Battery Status

This is an experimental API and is only available on Chrome at the moment.

import { useBattery } from 'vue-adaptive-utils';

const { charging, chargingTime, dischargingTime, level, isSupported } = useBattery();

Hardware Concurrency (CPU Cores)

import { useHardwareConcurrency } from 'vue-adaptive-utils';

const { concurrency, isSupported } = useHardwareConcurrency();

Memory Status

This is a compounded API, meaning it collects various information from multiple APIs, mainly the navigator.deviceMemory and navigator.performance.

import { useHardwareConcurrency } from 'vue-adaptive-utils';

const { deviceMemory, totalJSHeapSize, usedJSHeapSize, jsHeapSizeLimit, isSupported } = useMemoryStatus();

Browser Support

  • Battery API is only available on Chrome.
  • Connection API is available on Chrome 61+ and Firefox.
  • Device Memory is available on Chrome 63+.
  • Performance memory API is a non-standard and only available in Chrome 7+, Opera, Chrome for Android 18+, Opera for Android.

📚 Documentation

You can find the docs here.

📜 License

Licensed under the MIT license.