Comparing version 0.1.0 to 0.1.1
@@ -97,3 +97,3 @@ const fs = require('fs') | ||
code = code.toString().toUpperCase() | ||
return VALID_BASE_CODES.indexOf(code) | ||
return VALID_BASE_CODES.indexOf(code) === -1 ? false : true | ||
} | ||
@@ -100,0 +100,0 @@ |
{ | ||
"name": "xchanger", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Currency exhange api with auto caching of api calls for better performance and bandwidth utilization", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,5 +17,20 @@ ~~~~ | ||
# Usage | ||
//TODO | ||
Its really simple to use. Just require the module and create a new xchange | ||
instance. | ||
~~~~ | ||
const xchange = (require('xchanger'))() | ||
xchange.setBase('inr') //Set the base exchange currency to use as a default | ||
xchange.convert(100, 'usd').then(result => { | ||
console.log(result) | ||
}).catch(error => { | ||
console.log(error) | ||
}) | ||
~~~~ | ||
Thats it! | ||
#Author | ||
@author Hanut Singh Gusain <hanutsingh@gmail.com> [http://www.hanutsingh.in] | ||
Created and maintained by Hanut Singh Gusain <hanutsingh@gmail.com> [http://www.hanutsingh.in] |
@@ -112,2 +112,22 @@ const expect = require('chai').expect | ||
}) | ||
context('provided base is invalid', function() { | ||
it('should throw an error ', function(){ | ||
expect(() => xchange.setBase('abcd')).to.throw('invalid base code') | ||
}) | ||
}) | ||
context('provided base is valid', function() { | ||
let xchange = new XCHANGER('USD') | ||
before(function(done) { | ||
xchange.sync().then((rates) => { | ||
xchange.rates = rates | ||
done() | ||
}).catch(done) | ||
}) | ||
it('should set the modules base currency ', function(){ | ||
xchange.setBase('inr') | ||
expect(xchange.base).is.eql('INR') | ||
}) | ||
}) | ||
}) | ||
@@ -114,0 +134,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
146961
868
36
0