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

use-mask-money

v1.0.2

Published

A simple Nuxt composable to toggle masking and unmasking of monetary values.

Downloads

21

Readme

use-mask-money

use-mask-money is a simple and reusable Nuxt 3 composable that allows you to toggle masking and unmasking of monetary values with ease. It's designed to work seamlessly in Nuxt 3 projects and provides a straightforward API.

Installation

First, install the package via npm:

npm install use-mask-money

Usage

After installation, you can import and use the useMaskMoney composable in your Nuxt 3 components.

Basic Usage

The composable initializes with an initialValue and provides a method to toggle between the masked and unmasked states.

<template>
  <div>
    <button @click="toggleAmount">
      {{ displayAmount }}
    </button>
  </div>
</template>

<script setup>
import { useMaskMoney } from "use-mask-money";

// Initialize with the amount you want to manage
const { displayValue: displayAmount, toggleValue: toggleAmount } =
  useMaskMoney("10,000,000.00");
</script>

Explanation

  • useMaskMoney(initialValue): Initializes the composable with the provided initialValue.
  • displayValue: A computed property that returns the masked or unmasked value based on the internal visibility state.
  • toggleValue: A function to toggle between the masked and unmasked states.

Example with Multiple Values

You can use the composable to handle multiple amounts independently, allowing each amount to be toggled separately.

<template>
  <div>
    <button @click="toggleTraderAmount">
      {{ traderAmount.displayValue }}
    </button>
    <button @click="toggleBiwiAmount">
      {{ biwiAmount.displayValue }}
    </button>
  </div>
</template>

<script setup>
import { useMaskMoney } from "use-mask-money";

// Create instances for each amount
const traderAmount = useMaskMoney("10,000,000.00");
const biwiAmount = useMaskMoney("5,000,000.00");

// Destructure methods for toggling
const { toggleValue: toggleTraderAmount, displayValue: traderDisplayValue } =
  traderAmount;
const { toggleValue: toggleBiwiAmount, displayValue: biwiDisplayValue } =
  biwiAmount;
</script>

Explanation

  • useMaskMoney('10,000,000.00'): Initializes the composable for traderAmount with the specified value.
  • useMaskMoney('5,000,000.00'): Initializes the composable for biwiAmount with a different value.
  • toggleValue: Used to toggle the display of each amount between masked and unmasked states.
  • displayValue: Provides the current value to be displayed.

License

This project is licensed under the MIT License. See the LICENSE file for details.