-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d2191cb
Showing
19 changed files
with
4,791 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"modules": false | ||
} | ||
], | ||
"@babel/preset-typescript" | ||
], | ||
"plugins": [ | ||
// "@babel/plugin-external-helpers", | ||
"@babel/plugin-proposal-class-properties", | ||
["@babel/plugin-proposal-decorators", { "legacy": true }], | ||
"@babel/plugin-proposal-do-expressions", | ||
"@babel/plugin-proposal-export-default-from", | ||
"@babel/plugin-proposal-export-namespace-from", | ||
"@babel/plugin-proposal-function-bind", | ||
"@babel/plugin-proposal-function-sent", | ||
"@babel/plugin-proposal-json-strings", | ||
"@babel/plugin-proposal-logical-assignment-operators", | ||
"@babel/plugin-proposal-nullish-coalescing-operator", | ||
"@babel/plugin-proposal-numeric-separator", | ||
"@babel/plugin-proposal-optional-chaining", | ||
["@babel/plugin-proposal-pipeline-operator", { "proposal": "hack", "topicToken": "^^" }], | ||
"@babel/plugin-proposal-throw-expressions", | ||
"@babel/plugin-syntax-dynamic-import", | ||
"@babel/plugin-syntax-import-meta" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
tab_width = 4 | ||
quote_type = single | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
MODULE_NAME=$npm_package_name | ||
MODULE_VERSION=$npm_package_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules | ||
|
||
/dist | ||
/stats | ||
/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
parser: '@babel/eslint-parser', | ||
extends: ['standard', 'typescript'], | ||
env: { | ||
es6: true, | ||
jest: true | ||
}, | ||
plugins: ['typescript', 'prettier'], | ||
parserOptions: { | ||
sourceType: 'module' | ||
}, | ||
rules: { | ||
semi: [2, 'always'], | ||
indent: ['error', 4], | ||
'space-before-function-paren': 0, | ||
'prettier/prettier': 'error' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/dist | ||
/stats | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Type can be | ||
# - feat (new feature) | ||
# - change (code change) | ||
# - fix (bug fix) | ||
# - refactor (refactoring production code) | ||
# - style (formatting, missing semi colons, etc; no code change) | ||
# - docs (changes to documentation) | ||
# - test (adding or refactoring tests; no production code change) | ||
# - chore (updating grunt tasks etc; no production code change) | ||
# - wip (work in progress commit to be squashed -- do not push!)\*\* | ||
|
||
# [type] Short summary (72 chars or less) | ||
|
||
# More detailed explanatory text. Wrap it to 72 characters. The blank | ||
# line separating the summary from the body is critical (unless you omit | ||
# the body entirely). | ||
|
||
# Write your commit message in the imperative: "Fix bug" and not "Fixed | ||
# bug" or "Fixes bug." This convention matches up with commit messages | ||
# generated by commands like git merge and git revert. | ||
|
||
# Further paragraphs come after blank lines. | ||
|
||
# - Bullet points are okay, too. | ||
# - Typically a hyphen or asterisk is used for the bullet, followed by a | ||
# - single space. Use a hanging indent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules/ | ||
|
||
/dist | ||
/stats | ||
|
||
.gitmessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"printWidth": 128 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## 1.0.0 - 2024-06-06 | ||
|
||
- init: public release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 m00nbyte | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# currency-converter | ||
|
||
[![npm version](https://img.shields.io/npm/v/@m00nbyte/currency-converter.svg)](https://www.npmjs.org/package/@m00nbyte/currency-converter) [![npm downloads](https://img.shields.io/npm/dm/@m00nbyte/currency-converter)](https://www.npmjs.org/package/@m00nbyte/currency-converter) | ||
|
||
--- | ||
|
||
## Description | ||
|
||
Effortlessly converts currency values between different denominations, utilizing the latest pricing data available from the frankfurter.app API. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install -D @m00nbyte/currency-converter | ||
yarn add -D @m00nbyte/currency-converter | ||
``` | ||
|
||
## Using parameters | ||
|
||
### Parameters | ||
|
||
### `query` | ||
|
||
Type: `string | number` | ||
Default: `undefined` | ||
|
||
Specifies the amount to convert. If only this parameter is provided, it is considered as the base currency. | ||
|
||
### `fromCurrency` | ||
|
||
Type: `string | null` | ||
Default: `null` | ||
|
||
Specifies the currency code for the base currency. Defaults to null for automatic detection. | ||
|
||
### `toCurrency` | ||
|
||
Type: `string | null` | ||
Default: `null` | ||
|
||
Specifies the currency code for the target currency. Defaults to null for automatic detection. | ||
|
||
### Examples | ||
|
||
#### **Get currency list with default base currency (USD)** | ||
|
||
```js | ||
import fx from '@m00nbyte/currency-converter'; | ||
|
||
const usdRates = await fx(); | ||
console.log(usdRates); | ||
``` | ||
|
||
#### **Get currency list with custom base currency** | ||
|
||
```js | ||
import fx from '@m00nbyte/currency-converter'; | ||
|
||
const eurRates = await fx('eur'); | ||
console.log(eurRates); | ||
``` | ||
|
||
#### **Convert amount to all available currencies using custom base currency** | ||
|
||
```js | ||
import fx from '@m00nbyte/currency-converter'; | ||
|
||
const conversionResult = await fx(100, 'eur'); | ||
console.log('Converted 100 EUR to all available currencies:', conversionResult); | ||
``` | ||
|
||
#### **Convert amount from base currency to target currency** | ||
|
||
```js | ||
import fx from '@m00nbyte/currency-converter'; | ||
|
||
const conversionResult = await fx(100, 'eur', 'usd'); | ||
console.log(`Converted 100 EUR to USD: ${conversionResult}`); | ||
``` | ||
|
||
## Using Method Chaining | ||
|
||
### Methods | ||
|
||
### `fx(amount: Number): fx` | ||
|
||
#### `amount` | ||
|
||
Type: `Number` | ||
Default: `undefined` | ||
|
||
Specifies the amount for the conversion. | ||
|
||
### `from(currency: String): fx` | ||
|
||
#### `currency` | ||
|
||
Type: `String` | ||
Default: `undefined` | ||
|
||
Sets the base currency for the conversion. | ||
|
||
### `to(currency: String): Promise<Number>` | ||
|
||
#### `currency` | ||
|
||
Type: `String` | ||
Default: `undefined` | ||
|
||
Sets the target currency for the conversion and returns the converted amount. | ||
|
||
### Examples | ||
|
||
#### **Convert amount from base currency to target currency** | ||
|
||
```js | ||
import fx from '@m00nbyte/currency-converter'; | ||
|
||
const conversionResult = await fx(100).from('eur').to('usd'); | ||
console.log(`Converted 100 EUR to USD: ${conversionResult}`); | ||
``` | ||
|
||
## Contribution | ||
|
||
Feel free to submit issues or pull requests. | ||
|
||
## Like my work? | ||
|
||
This project needs a :star: from you. | ||
Don't forget to leave a star. | ||
|
||
<a href="https://www.buymeacoffee.com/m00nbyte" target="_blank"> | ||
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" width="217" height="60"> | ||
</a> | ||
|
||
## [Changelog](CHANGELOG.md) | ||
|
||
## [License](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"name": "@m00nbyte/currency-converter", | ||
"version": "1.0.0", | ||
"description": "Effortlessly converts currency values between different denominations, utilizing the latest pricing data available from the frankfurter.app API", | ||
"author": "m00nbyte <office@moonbyte.at>", | ||
"keywords": [ | ||
"currency", | ||
"convert", | ||
"frankfurter", | ||
"typescript" | ||
], | ||
"license": "MIT", | ||
"main": "dist/cjs/index.min.js", | ||
"module": "dist/es/index.min.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/es/index.min.js", | ||
"default": "./dist/cjs/index.min.js" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=18.12.0" | ||
}, | ||
"scripts": { | ||
"start": "cross-env NODE_ENV=development rollup -c -w", | ||
"build": "cross-env NODE_ENV=production rollup -c", | ||
"deploy": "yarn build && yarn publish", | ||
"test": "yarn build && npx mocha test" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"url": "git+ssh://git@github.com/m00nbyte/currency-converter.git" | ||
}, | ||
"homepage": "https://github.com/m00nbyte/currency-converter#readme", | ||
"bugs": { | ||
"url": "https://github.com/m00nbyte/currency-converter/issues" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.24.6", | ||
"@babel/eslint-parser": "^7.24.6", | ||
"@babel/plugin-external-helpers": "^7.24.6", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-proposal-decorators": "^7.24.6", | ||
"@babel/plugin-proposal-do-expressions": "^7.24.6", | ||
"@babel/plugin-proposal-export-default-from": "^7.24.6", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.18.9", | ||
"@babel/plugin-proposal-function-bind": "^7.24.6", | ||
"@babel/plugin-proposal-function-sent": "^7.24.6", | ||
"@babel/plugin-proposal-json-strings": "^7.18.6", | ||
"@babel/plugin-proposal-logical-assignment-operators": "^7.20.7", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", | ||
"@babel/plugin-proposal-numeric-separator": "^7.18.6", | ||
"@babel/plugin-proposal-optional-chaining": "^7.21.0", | ||
"@babel/plugin-proposal-pipeline-operator": "^7.24.6", | ||
"@babel/plugin-proposal-throw-expressions": "^7.24.6", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@babel/plugin-syntax-import-meta": "^7.10.4", | ||
"@babel/preset-env": "^7.24.6", | ||
"@babel/preset-typescript": "^7.24.6", | ||
"@rollup-extras/plugin-clean": "^1.3.9", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^25.0.8", | ||
"@rollup/plugin-dynamic-import-vars": "^2.1.2", | ||
"@rollup/plugin-replace": "^5.0.5", | ||
"@rollup/plugin-strip": "^3.0.4", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@types/node": "^20.14.0", | ||
"assert": "^2.1.0", | ||
"cross-env": "^7.0.3", | ||
"mocha": "^10.4.0", | ||
"rollup": "^4.18.0", | ||
"rollup-plugin-filesize": "^10.0.0", | ||
"rollup-plugin-progress": "^1.1.2", | ||
"rollup-plugin-strip-code": "^0.2.7", | ||
"rollup-plugin-tsconfig-paths": "^1.5.2", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"rollup-plugin-visualizer": "^5.12.0", | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"node-fetch": "^3.3.2" | ||
} | ||
} |
Oops, something went wrong.