What is @rc-component/mini-decimal?
@rc-component/mini-decimal is a lightweight JavaScript library designed to handle decimal calculations with high precision. It is particularly useful for financial applications or any other use case where precise decimal arithmetic is required.
What are @rc-component/mini-decimal's main functionalities?
Basic Arithmetic Operations
This feature allows you to perform basic arithmetic operations like addition, subtraction, multiplication, and division with high precision.
const MiniDecimal = require('@rc-component/mini-decimal');
const a = new MiniDecimal('0.1');
const b = new MiniDecimal('0.2');
const sum = a.add(b);
console.log(sum.toString()); // '0.3'
Comparison Operations
This feature allows you to compare two decimal numbers to check if one is less than, greater than, or equal to the other.
const MiniDecimal = require('@rc-component/mini-decimal');
const a = new MiniDecimal('0.1');
const b = new MiniDecimal('0.2');
console.log(a.lessThan(b)); // true
console.log(a.equals(b)); // false
Rounding
This feature allows you to round decimal numbers to a specified number of decimal places.
const MiniDecimal = require('@rc-component/mini-decimal');
const a = new MiniDecimal('0.12345');
const rounded = a.round(2);
console.log(rounded.toString()); // '0.12'
Other packages similar to @rc-component/mini-decimal
decimal.js
decimal.js is a library for arbitrary-precision decimal arithmetic. It provides a comprehensive set of methods for performing high-precision arithmetic operations, similar to @rc-component/mini-decimal, but with more extensive functionality and configurability.
bignumber.js
bignumber.js is a library for arbitrary-precision arithmetic with numbers. It supports both integer and decimal arithmetic, making it a versatile choice for applications requiring high-precision calculations. It is similar to @rc-component/mini-decimal but also includes support for very large integers.
big.js
big.js is a smaller, simpler library for arbitrary-precision decimal arithmetic. It is designed to be a lightweight alternative to decimal.js and bignumber.js, offering fewer features but a smaller footprint. It is similar to @rc-component/mini-decimal in its focus on simplicity and precision.
rc-portal
React 18 supported Portal Component.
Development
npm install
npm start
open http://localhost:8000
Feature
- React life cycle support portal component
Install
Usage
import Portal from 'rc-portal';
const Demo = () => {
return <Portal open>Hello World</Portal>;
};
export default Demo;
🔥 API
We use typescript to create the Type definition. You can view directly in IDE. But you can still check the type definition here.
Portal
Prop | Description | Type | Default |
---|
getContainer | Customize portal container element | Element | () => Element | document.body |
open | Show the portal | boolean | false |
autoLock | Lock screen scroll when open | boolean | false |