Numerous Panicky Mimes

    js-financial-tools

    1.0.15 • Public • Published

    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%

    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';

    Install

    npm i js-financial-tools

    DownloadsWeekly Downloads

    17

    Version

    1.0.15

    License

    Apache-2.0

    Unpacked Size

    292 kB

    Total Files

    47

    Last publish

    Collaborators

    • dirac_keeko