|
1 | | -# @rc-component/mini-decimal |
| 1 | +<div align="center"> |
| 2 | + <h1>@rc-component/mini-decimal</h1> |
| 3 | + <p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p> |
| 4 | + <p>🧮 Small decimal calculator for precise string-based arithmetic.</p> |
2 | 5 |
|
3 | | -A mini decimal calculator which only support `add`, `multi` or compare operation for mini bundle size. |
| 6 | + <p> |
| 7 | + <a href="https://npmjs.org/package/@rc-component/mini-decimal"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/mini-decimal.svg?style=flat-square"></a> |
| 8 | + <a href="https://npmjs.org/package/@rc-component/mini-decimal"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/mini-decimal.svg?style=flat-square"></a> |
| 9 | + <a href="https://github.com/react-component/mini-decimal/actions/workflows/test.yml"><img alt="build status" src="https://github.com/react-component/mini-decimal/actions/workflows/test.yml/badge.svg"></a> |
| 10 | + <a href="https://app.codecov.io/gh/react-component/mini-decimal"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/mini-decimal/master.svg?style=flat-square"></a> |
| 11 | + <a href="https://bundlephobia.com/package/@rc-component/mini-decimal"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/mini-decimal?style=flat-square"></a> |
| 12 | + <a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a> |
| 13 | + </p> |
| 14 | +</div> |
4 | 15 |
|
5 | | -[![NPM version][npm-image]][npm-url] [](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![npm download][download-image]][download-url] |
| 16 | +<p align="center">English | [简体中文](./README.zh-CN.md)</p> |
6 | 17 |
|
7 | | -[npm-image]: http://img.shields.io/npm/v/@rc-component/mini-decimal.svg?style=flat-square |
8 | | -[npm-url]: http://npmjs.org/package/@rc-component/mini-decimal |
9 | | -[github-actions-image]: https://github.com/react-component/mini-decimal/workflows/CI/badge.svg |
10 | | -[github-actions-url]: https://github.com/react-component/mini-decimal/actions |
11 | | -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/mini-decimal/master.svg?style=flat-square |
12 | | -[codecov-url]: https://codecov.io/gh/react-component/mini-decimal/branch/master |
13 | | -[download-image]: https://img.shields.io/npm/dm/@rc-component/mini-decimal.svg?style=flat-square |
14 | | -[download-url]: https://npmjs.org/package/@rc-component/mini-decimal |
| 18 | +## Highlights |
15 | 19 |
|
16 | | -## Development |
| 20 | +| Area | Support | |
| 21 | +| ------- | ------------------------------------------------------------- | |
| 22 | +| Purpose | Small decimal calculator for precise string-based arithmetic. | |
| 23 | +| Package | `@rc-component/mini-decimal` | |
| 24 | +| Release | `@rc-component/np` / `rc-np` | |
| 25 | + |
| 26 | +## Install |
17 | 27 |
|
18 | 28 | ```bash |
19 | | -npm install |
20 | | -npm test |
| 29 | +npm install @rc-component/mini-decimal |
21 | 30 | ``` |
22 | 31 |
|
23 | 32 | ## Usage |
24 | 33 |
|
25 | | -```tsx |
| 34 | +```tsx | pure |
26 | 35 | import getMiniDecimal from '@rc-component/mini-decimal'; |
27 | 36 |
|
28 | | -// Add |
29 | 37 | getMiniDecimal('0.1').add('0.2').toString(); // 0.3 |
30 | | - |
31 | | -// Multi |
32 | 38 | getMiniDecimal('0.1').multi('0.2').toString(); // 0.02 |
| 39 | +``` |
| 40 | + |
| 41 | +## API |
33 | 42 |
|
34 | | -// Negate |
35 | | -getMiniDecimal('0.1').negate().toString(); // -0.1 |
| 43 | +| Method | Description | |
| 44 | +| ------------------- | ---------------------------------- | |
| 45 | +| `add(value)` | Add another decimal value. | |
| 46 | +| `multi(value)` | Multiply by another decimal value. | |
| 47 | +| `negate()` | Return the negated value. | |
| 48 | +| `equal(value)` | Check equality. | |
| 49 | +| `lessEquals(value)` | Compare two decimal values. | |
36 | 50 |
|
37 | | -// Equal |
38 | | -getMiniDecimal('0.1').equal('0.1'); // true |
39 | | -getMiniDecimal('0.1').equal('0.2'); // false |
| 51 | +## Development |
40 | 52 |
|
41 | | -// Less Equals |
42 | | -getMiniDecimal('0.1').lessEquals('0.2'); // true |
43 | | -getMiniDecimal('0.1').lessEquals('0.1'); // false |
| 53 | +```bash |
| 54 | +npm install |
| 55 | +npm test |
| 56 | +npm run lint |
| 57 | +npm run tsc |
| 58 | +npm run compile |
44 | 59 | ``` |
| 60 | + |
| 61 | +The dumi site runs at `http://localhost:8000`. |
| 62 | + |
| 63 | +## Release |
| 64 | + |
| 65 | +```bash |
| 66 | +npm run prepublishOnly |
| 67 | +``` |
| 68 | + |
| 69 | +The release flow is handled by `@rc-component/np` through the `rc-np` command when the package uses the shared release flow. |
| 70 | + |
| 71 | +## License |
| 72 | + |
| 73 | +@rc-component/mini-decimal is released under the [MIT](./LICENSE) license. |
0 commit comments