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

nuxt-toolkit

v1.1.0

Published

A comprehensive toolkit for enhancing Nuxt.js development.

Downloads

45

Readme

Nuxt-Toolkit

Nuxt-Toolkit is a comprehensive utility plugin for Nuxt.js, offering a range of functions to enhance your development experience in Vue.js and Nuxt.js projects.

Features

This toolkit includes a variety of utility functions:

  • handle: Efficiently handle promises by returning a tuple [data, error], making error handling and data processing simpler in asynchronous operations.
  • addTransparency: Add transparency to a HEX color.
  • formatDateAndTime: Format Unix timestamps into readable date and time.
  • copyTextToClipboard: Copy a provided text to the clipboard.
  • openNewTab: Open a link in a new browser tab.
  • formatBalance: Format numerical balance into a readable string with commas.
  • getTimeAgo: Calculate how much time has passed since a given date.
  • goTo: Navigate to a specified path using Vue Router.
  • areObjectsEqual: Deep comparison of two objects to check for equality.
  • extractKeys: Extract specific keys from an object.
  • deepClone: Perform a deep clone of an object.

Installation

To install Nuxt-Toolkit, run the following command in your project's root directory:

npm install nuxt-toolkit

1. Create a Plugin File:

Navigate to the plugins directory in your Nuxt.js project. If it doesn't exist, create it. Inside the plugins directory, create a new file, for example, nuxt-toolkit.js.

2. Set Up the Plugin File:

In the newly created file (nuxt-toolkit.js), import the Nuxt-Toolkit package and set it up as follows:

import * as toolkit from "nuxt-toolkit";

export default (_, inject) => {
  inject("toolkit", toolkit);
};

3. Include the Plugin in Your Nuxt Configuration:

Add a reference to this plugin in your nuxt.config.js file:

export default {
  plugins: ["~/plugins/nuxt-toolkit.js"],
  // ...other configurations
};

With this setup, Nuxt-Toolkit will be available throughout your Nuxt.js application, and you can access its functions using this.$toolkit.

Usage

You can use the toolkit in your Vue components:

<script>
  export default {
    mounted() {
      let transparentColor = this.$toolkit.addTransparency("#ff5733", 0.5);
      console.log(transparentColor); // rgba(255, 87, 51, 0.5)

      let formattedDate = this.$toolkit.formatDateAndTime(Date.now());
      console.log(formattedDate); // { date: "1 Jan, 2023", time: "12:00 AM" }

      // ... other function usages
    },
  };
</script>

Documentation

handle(promise)

Handles a Promise and returns a tuple [data, error]. If the promise resolves successfully, data will contain the result and error will be undefined. If the promise is rejected, data will be undefined and error will contain the error information.

Usage Example:

async function exampleUsage() {
  const [data, dataError] = await this.$toolkit.handle(somePromise);

  if (dataError) {
    console.error("An error occurred:", dataError);
    return;
  }

  console.log("Received data:", data);
}

addTransparency(hexColor, transparency)

Converts a HEX color code to RGBA with a specified transparency level.

formatDateAndTime(timestamp)

Formats a Unix timestamp into a human-readable date and time format.

copyTextToClipboard(link)

Copies a provided text to the clipboard and shows a notification.

openNewTab(link)

Opens a provided URL in a new browser tab.

formatBalance(balance)

Formats a numeric balance into a string with commas.

getTimeAgo(timestamp)

Calculates the time elapsed since the given timestamp.

goTo(path)

Navigates to a specified path using Vue Router.

areObjectsEqual(obj1, obj2)

Deeply compares two objects for equality.

extractKeys(sourceObject, keysToExtract)

Extracts specified keys from an object.

deepClone(obj)

Creates a deep clone of an object.

Contributing

Contributions, issues, and feature requests are welcome. Feel free to check issues page if you want to contribute.

Author

Motion Routes LTD

License

This project is ISC licensed.