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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gradin/vue-utils

v0.0.7

Published

Useful utilities for Vue projects.

Readme

vue-utils

Useful utilities for Vue projects.

npm (scoped) npm bundle size (scoped) npm

Table of Contents:

Installation

# Using npm
npm install @gradin/vue-utils

# Using Yarn
yarn add @gradin/vue-utils

Features

Improved Vue Reactive

The gReactive function is a wrapper around Vue's reactive function that adds some useful features.

  • Reset: The reset method resets the reactive object to its initial state.
  • Set: The set method sets the reactive object to a new value, merging the new value with the existing value.

Example reactive vs gReactive:

  // before
  import { reactive } from 'vue';
  const form = reactive({
    name: '',
    sku: '',
    description: '',
    price: 0,
    category_id: <number|null> null,
  })

  const resetForm = () => {
    form.name = '';
    form.sku = '';
    form.description = '';
    form.price = 0;
    form.category_id = null;
  }

  const setFormForUpdate = (product: Product) => {
    form.name = product.name;
    form.sku = product.sku;
    form.description = product.description;
    form.price = product.price;
    form.category_id = product.category_id;
  }

  const submitForm = () => {
    axios.post('/api/products', form)
      .then(response => {
        // handle success
      })
  }

  // after
  import { gReactive } from '@gradin/vue-utils';
  const form = gReactive({ // almost the same as vue reactive
    name: '',
    sku: '',
    description: '',
    price: 0,
    category_id: <number|null> null,
  })
  form.reset(); // reset the form
  form.set(product); // set the form for update

  const submitForm = () => { // exactly the same as before
    axios.post('/api/products', form)
      .then(response => {
        // handle success
      })
  }

Watch Route Query and Params Changes

The whenRouteChange will allow you to do something changes but still on the same page. It is also triggered on the first mount of the component.

whenRouteChange accepts two arguments:

  • callback: The function to be called when the route query or params changes.
  • watchSource: Optional. A function that returns the value to be watched. If not provided, it will watch the entire route query and route params object.

| When | Triggered | | :--------------------------------------------------------- | :-------: | | Route query changed (e.g /products to /products?page=2) | Yes | | Route params changed (e.g /products/1 to /products/2) | Yes | | Script setup loaded (using watch with immediate: true) | Yes | | Route name changed (e.g /products to /home) | No | | Also Route name changed (e.g /products to /product/1) | No |

Usage:

  import { whenRouteChange } from '@gradin/vue-utils';
  import { useRoute } from 'vue-router';
  import axios from 'axios';

  const route = useRoute();
  const products = ref<Product[]>([]);

  const getData = () => {
    const response = await axios.get('/api/products', {
      params: {
        page: route.query.page,
        search: route.query.search,
        category_id: route.query.category_id,
        sort: route.query.sort,
      }
    })
    products.value = response.data;
  }
  
  whenRouteChange(getData) // will call getData once at the beginning, and again when the route query or params changes.

  // or if you want just to track route query page
  const highlightMatchesSearch = () => { 
    //
  }
  whenRouteChange(
    () => {
      highlightMatchesSearch()
    },
    () => route.query.search
  )