Registry / payments / fp-money

fp-money

JSON →
library2.0.0jsnpmunverified

fp-money is a currency input formatter and selector library for the web, currently at version 2.0.0. It provides real-time formatting of monetary values with support for custom currencies, locale-aware display, and utility functions for converting between float and integer representations. Key differentiators include built-in Vue 3 component support, full TypeScript typings, and a lightweight footprint with no external dependencies. Released under MIT, it receives active maintenance.

npm install fp-money
INSTALL
IMPORT
SIG · FP-MONEY
F
fp-money
paymentsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FPMoney
import FPMoney from 'fp-money'; import 'fp-money/style.css';
const FPMoney = require('fp-money');
FPMoney is a default export. The CSS must be imported separately.
fractionToInt
import { fractionToInt } from 'fp-money';
import fractionToInt from 'fp-money';
Utility functions are named exports, not default.
Vue component
import FPMoney from 'fp-money/vue'; import 'fp-money/vue/style.css';
import FPMoney from 'fp-money';
For Vue 3, import from the subpath 'fp-money/vue' and use the Vue-specific CSS.

Creates a basic currency input with initial value, USD currency, and a change handler.

import FPMoney from 'fp-money'; import 'fp-money/style.css'; const container = document.createElement('div'); document.body.appendChild(container); const moneyInput = new FPMoney({ container, value: 1000.5, currency: 'USD', locale: 'en-US', onChange: (values) => { console.log('Changed:', values); } }); // Clean up after 3 seconds setTimeout(() => moneyInput.destroy(), 3000);
Debug
Known issues
breakingVersion 2.0.0 changed the import path for the Vue component from 'fp-money' to 'fp-money/vue'. Previous imports may break.
fix
Update import to 'import FPMoney from 'fp-money/vue'; import 'fp-money/vue/style.css';'
affects: <2.0.0
breakingIn version 2.0.0, the CSS import path changed. Old path 'fp-money/dist/style.css' no longer works.
fix
Import CSS as 'import 'fp-money/style.css';' or 'import 'fp-money/vue/style.css';' for Vue.
affects: <2.0.0
deprecatedThe 'change' event callback was deprecated in 2.0.0; use 'onChange' option instead.
fix
Replace the 'change' option with 'onChange'.
affects: >=2.0.0
gotchaWhen using the Vue component, v-model expects a number but the internal value may be a float; ensure v-model is bound to a Number ref.
fix
Use 'const value = ref(1000.5)' (number) and not a string.
affects: >=2.0.0
gotchaThe 'currencies' option overrides built-in currencies completely; if you only want to add custom currencies, merge them with the defaults.
fix
Provide a merged object: { ...defaultCurrencies, BTC: { symbol: '₿', fraction: 8 } }
affects: >=1.0.0
gotchaThe 'valueFormat' option only affects output in onChange; the input always displays formatted value.
fix
Set 'valueFormat' to 'int' if you need integer values in the callback.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: FPMoney is not a constructor
Importing the Vue component subpath as default instead of from 'fp-money'.
fix
Use 'import FPMoney from 'fp-money'' for vanilla JS, not 'from 'fp-money/vue''.
Module not found: Error: Can't resolve 'fp-money/style.css'
Missing CSS import or wrong path after version upgrade.
fix
Ensure you have imported 'fp-money/style.css' or 'fp-money/vue/style.css'.
Cannot read properties of undefined (reading 'querySelector')
The 'container' option is missing or not a valid DOM element.
fix
Pass a valid DOM element to the 'container' option.
Vue warn: Failed to resolve component: FPMoney
Importing FPMoney from 'fp-money' instead of 'fp-money/vue' in a Vue project.
fix
Use 'import FPMoney from 'fp-money/vue'' and register it.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
28
OpenAI (training)
1
Resources
fp-money — npm install fp-money · libregistry