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-money-format

v1.2.4

Published

A Vue component that formats currency.

Downloads

12,456

Readme

vue-money-format

A Vue component that formats currency.

This uses Intl.NumberFormat: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat

Description

This is a lightweight display component for localized currency display. It has no dependencies other than Vue. It supports both float and integer input, and can adjust for values stored as decimal-based subunits, such as cents, dirham, groszy, etc. Storing currency values in terms of the subunit allows you to store integers, rather than floating numbers, which ensures accuracy.

Many libraries, such as the Ruby Money and Money-Rails gems, expect monetary values to be stored as integers.

Features

  • Supports currency value in super unit or subunit values (input can be $100.00 or 10000 cents)
  • Supports localized formatting keyed by BCP 47 language tags
  • Suuports currency symbols keyed by ISO 4217 currency codes
  • Supports suppression of the subunit display (you can display $100.65 or $101). When the subunit display is suppressed, the value will be rounded prior to display.

Installation

yarn add vue-money-format

Usage

<template>
  <div>
    <money-format :value="cost" 
      :locale='en' 
      :currency-code='USD' 
      :subunits-value=true 
      :hide-subunits=true>
    </money-format>
  </div>
</template>

<script>
  import MoneyFormat from 'vue-money-format'

  export default {
    components: {
    'money-format': MoneyFormat
    },

    data () {
      return {
        cost: 12345
        }
      }
    }
  }
</script>

Input options

  • value: Numerical input (only required input)
  • locale: Language and country information, such as 'en' or 'en-US'. Defaults to 'en'
  • currency-code: ISO 4217 3-character alpha code in upper or lower case. Defaults to 'USD'
  • subunits-value: Set to true if value is denominated in subunits, such as cents. Defaults to false
  • subunits-to-units: Set this only if you need to deviate from the minor unit value provided by ISO 4217. If you set this, the subunits-value option will be ignored.
  • hide-subunits: Do not display the subunits. Defaults to false. If you set this to true, the supplemental-precision option will be ignored.
  • supplemental-precision: Add extra precision digits beyond what is specified in ISO 4217. For example, a value of $2.2716 will normally be displaced as $2.27. If you set supplemental-precision to 1, it will be displayed as $2.272.

Changelog

Changes for the current version:

  • Fixed a typo in the usage instructions
  • Upgraded Lodash

References

  • Intl.NumberFormat: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
  • BCP 47 localization codes: https://tools.ietf.org/html/bcp47
  • ISO 4217 curency codes: https://www.currency-iso.org/en/home/tables/table-a1.html
  • Money-Rails gem: https://github.com/RubyMoney/money-rails
  • Money gem: https://github.com/Rubymoney/money
  • How to handle money and currency conversions: http://www.yacoset.com/how-to-handle-currency-conversions

License

Copyright (c) 2018-2020 Ed Gomolka. Released under the MIT license. MIT