Skip to content

Commit

Permalink
Added @SInCE tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicklason committed Aug 5, 2018
1 parent 40e830d commit 9652a2c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/addRefined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const toScrap = require('./toScrap');
const toRefined = require('./toRefined');

/**
* Adds refined together
* @since 1.2.0
* @param {*} args Refined to add together
* @return {number} Returns all the refined added together
* @example Currencies.addRefined(10.11, 20.05, 0.11)
*/
module.exports = function (...args) {
let value = 0;

for (let i = 0; i < args.length; i++) {
const refined = args[i];
value += toScrap(refined);
}

const metal = toRefined(value);
return metal;
};
3 changes: 3 additions & 0 deletions lib/currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Currencies (currencies) {

/**
* Get the value of the currencies in scrap
* @since 1.0.0
* @param {number} conversion The refined value of keys
* @return {number} The value of the this currencies instance
* @throws Will throw an error if missing key conversion rate and there are keys
Expand All @@ -48,6 +49,7 @@ Currencies.prototype.toValue = function (conversion) {

/**
* Creates a string that represents this currencies object
* @since 1.0.0
* @return {string} Example: 1 key, 20.11 ref
*/
Currencies.prototype.toString = function () {
Expand All @@ -73,6 +75,7 @@ Currencies.prototype.toString = function () {

/**
* Creates an object that represents this currencies object
* @since 1.1.0
* @return {object} Currencies object
*/
Currencies.prototype.toJSON = function () {
Expand Down
1 change: 1 addition & 0 deletions lib/round.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Rounds a number to the closest step
* @since 1.0.0
* @param {number} number Number to round
* @param {number} [step=1] Closest step to round to
* @return {number} Returns the rounded number
Expand Down
1 change: 1 addition & 0 deletions lib/rounding.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Rounds a number up or down if the value is less than 0 or not
* @since 1.2.0
* @param {number} number Number to round
* @return {number} Returns the rounded number
*/
Expand Down
1 change: 1 addition & 0 deletions lib/toCurrencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const rounding = require('./rounding');

/**
* Converts scrap into a currencies object
* @since 1.0.0
* @param {number} value Value in scrap
* @param {number} conversion The refined value of keys
* @return {Object} Returns a new instance of Currencies
Expand Down
1 change: 1 addition & 0 deletions lib/toRefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const truncate = require('./truncate');

/**
* Coverts scrap to refined
* @since 1.0.0
* @param {number} scrap Scrap to convert
* @return {number} Returns the value of refined
*/
Expand Down
1 change: 1 addition & 0 deletions lib/toScrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const round = require('./round');

/**
* Coverts refined to scrap
* @since 1.0.0
* @param {number} refined Refined to convert
* @return {number} Returns the value of scrap
*/
Expand Down
1 change: 1 addition & 0 deletions lib/truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const rounding = require('./rounding');

/**
* Truncate a number
* @since 1.0.0
* @param {number} number Number to truncate
* @param {number} decimals Amount of decimal places to keep
* @return {number} Returns the truncated number
Expand Down

0 comments on commit 9652a2c

Please sign in to comment.