2.0.3 • Published 1 year ago

js-financial-tools v2.0.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

js-financial-tools

Tools commonly used in front-end development financial scenarios

npm version

Features

  • Simple API, support modular import
  • No dependencies
  • Unit function test coverage rate and line output coverage rate are both 100%
  • Refactor project by typescript, ts project can use those tools directly

Install

The library is the single JavaScript file js-financial-tools.js.

$ npm install js-financial-tools

Node.js

CommonJS:

const jsFinancialTools = require('js-financial-tools');

ES module:

import jsFinancialTools from 'js-financial-tools';

Browsers

Add jsFinancialTools to global scope:

<script src='path/to/js-financial-tools.js'></script>

Use

The library exports a single object, jsFinancialTools. Each key of this object corresponds to a secondary file in the src folder.

The directory list example is as follows

|-- src
    |-- index.js
    |-- calc
    |   |-- index.js
    |   |-- number.js
    |-- display
    |   |-- formatter.js
    |   |-- index.js
    |-- util
        |-- acquire.js
        |-- compare.js
        |-- index.js

Use the formatToPercent method in formatter module.

const res1 = jsFinancialTools.formatter.formatToPercent(0.233578, "+", 3);
console.log(res1); // +23.358%

const res2 = jsFinancialTools.formatter.formatToPercent(0.232323, "", 2);
console.log(res2); // 23.23%

Use the getIntPartLength method in acquire module.

const res3 = jsFinancialTools.acquire.getIntPartLength(123.456);
console.log(res3); // 3

Modular import

There is a modules directory in the project compilation product, the output format of these files is CJS

The directory list example is as follows

|-- modules
    |-- number.js
    |-- formatter.js
    |-- acquire.js
    |-- compare.js

CommonJS:

const { isRealNumber } = require('js-financial-tools/modules/number');

ES module:

import { isRealNumber } from 'js-financial-tools/modules/number';
2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago