@mann-conomy/tf-exchange
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

tf-exchange

A collection of Node.js classes for easy conversion between TF2 currencies.

npm version npm downloads Node.js version GitHub actions GitHub license

Installation

Using npm:

$ npm install @mann-conomy/tf-exchange

Using yarn:

$ yarn add @mann-conomy/tf-exchange

Testing

Using npm:

$ npm test

Using yarn:

$ yarn test

Examples

Easily convert between TF2 currencies with a single exchange rate for all arithmetic operations.

try {
    const calculator = new Calculator({ exchange: 66.88 });

    const first = new Currency({ keys: 5, refined: 23.88 });
    const second = new Currency({ keys: 2, refined: 47.33 });
    
    const currency = calculator.subtract(first, second);

    console.log(currency.toString()); // 2 keys, 43.44 refined
} catch (error) {
    console.error("Error adding the two currencies", error.message);
}

Some more examples are available in the examples and test directories.

Documentation

See the Wiki pages for further documentation.

License

MIT

Copyright 2024, The Mann-Conomy Project

Package Sidebar

Install

npm i @mann-conomy/tf-exchange

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

32.4 kB

Total Files

24

Last publish

Collaborators

  • snabe