realtonumber
TypeScript icon, indicating that this package has built-in type declarations

1.4.7 • Public • Published

RealToNumber

🔢 RealToNumber

Convert your real(pt-BR) string to float number ou other types.

Installation

This is a Node.js module available through the npm registry.

Use npm:

$ npm install realtonumber

Use yarn:

$ yarn add realtonumber

Features

  • realToFloat - Convert real to float
  • realToInt - Convert real to int

Examples

  1. Convert string to float.
const {realToFloat} = require('realtonumber');

let number = realToFloat('R$ 12.345,67');
// > 12345.67

let number = realToFloat('R$ 12.345,6789', {
    decimal: 3
});
// > 12345.678

Options:

  • decimal: number > Number of decimal cases in this number.
  1. Convert string to int.
const {realToInt} = require('realtonumber');

let number = realToInt('R$ 12.345,67');
// > 12346

let number = realToInt('R$ 12.345,6789', {
    useDecimal: true
});
// > 1234568

Options:

  • useDecimal: boolean > When you active this option, your number remove ',' and use 2 number after.

This project is under the MIT license. See the LICENSE file for more details

Package Sidebar

Install

npm i realtonumber

Weekly Downloads

2

Version

1.4.7

License

MIT

Unpacked Size

9.73 kB

Total Files

13

Last publish

Collaborators

  • marconwillian