@mann-conomy/tf-exchange
v1.0.0
Published
A collection of Node.js classes for easy conversion between TF2 currencies.
Downloads
65
Maintainers
Readme
tf-exchange
A collection of Node.js classes for easy conversion between TF2 currencies.
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
Copyright 2024, The Mann-Conomy Project