New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

currency-converter-lt

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-converter-lt - npm Package Compare versions

Comparing version

to
1.2.4

25

index.js

@@ -164,2 +164,3 @@ const cheerio = require("cheerio")

this.convertedValue = 0
this.isDecimalComma = false

@@ -175,2 +176,5 @@ if(params != undefined){

this.amount(params["amount"])
if(params["isDecimalComma"] !== undefined)
this.setDecimalComma(params["isDecimalComma"])
}

@@ -210,2 +214,10 @@

setDecimalComma (isDecimalComma){
if(typeof isDecimalComma !== "boolean")
throw new TypeError("isDecimalComma should be a boolean")
this.isDecimalComma = isDecimalComma
return this
}
rates(){

@@ -227,4 +239,13 @@ if(this.currencyFrom === this.currencyTo)

.then((rates) => {
if(rates.includes(","))
rates = rates.replaceAll(",", "")
if(this.isDecimalComma){
if(rates.includes("."))
rates = rates.replaceAll(".", "")
if(rates.includes(","))
rates = rates.replaceAll(",", ".")
}
else{
if(rates.includes(","))
rates = rates.replaceAll(",", "")
}
return parseFloat(rates)

@@ -231,0 +252,0 @@ })

2

package.json
{
"name": "currency-converter-lt",
"version": "1.2.3",
"version": "1.2.4",
"description": "A nodejs currency converter library that doesn't require subscribing to any API calls.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -26,2 +26,7 @@ const chai = require("chai")

it("should instantiate an object with json object as a parameter with isDecimalComma", () => {
let CC_ = new CC({from:"GBP", to:"CAD", amount: 100, isDecimalComma: true})
assert.equal(CC_.currencyFrom, "GBP")
})
it("should instantiate an object with json object with partial parameters", () => {

@@ -102,2 +107,13 @@ let CC_ = new CC({from:"GBP", amount: 100})

describe("setDecimalComma", () => {
it("should be true", () => {
currencyConverter.setDecimalComma(true)
assert.equal(currencyConverter.isDecimalComma, true)
})
it("should throw TypeError", () => {
expect(() => currencyConverter.isDecimalComma("10")).to.throw(TypeError);
})
})
describe("rates", () => {

@@ -108,2 +124,7 @@ it("should not return undefined values", () => {

})
it("should not return undefined values when isDecimalComma is true", () => {
currencyConverter.from("USD").to("JPY").setDecimalComma(true)
return expect(currencyConverter.rates()).to.eventually.not.equal(undefined)
})
})

@@ -110,0 +131,0 @@