Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes #70

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ dist
.DS_Store
untitled.sublime-project
untitled.sublime-workspace

.vscode
4 changes: 2 additions & 2 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This function converts all numbers to a positive number

### average

This function caculates the average of the numerical parameters
This function calculates the average of the numerical parameters

**Parameters**

Expand All @@ -61,7 +61,7 @@ This function caculates the average of the numerical parameters

### factorial

This function caculates the factorial of each numerical parameter
This function calculates the factorial of each numerical parameter

**Parameters**

Expand Down
2 changes: 1 addition & 1 deletion lib/absoluteValue.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
6 changes: 3 additions & 3 deletions lib/average.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { sum } = require('./sum');
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand All @@ -14,7 +14,7 @@ const handleErrors = (params) => {
};

/**
* This function caculates the average of the numerical parameters
* This function calculates the average of the numerical parameters
* @memberof variadic
* @author jmbothe
* @param {...*} params - One or more parameters.
Expand All @@ -26,7 +26,7 @@ exports.average = (...params) => {

// I couldn't actually find any examples of float imprecision
// when dividing a float by a whole number
// so this might not be neccessary. I just put it in for safety's sake - jmbothe
// so this might not be necessary. I just put it in for safety's sake - jmbothe
return floatPrecise(result);
};

8 changes: 4 additions & 4 deletions lib/factorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { isPositiveInteger } = require('./isPositiveInteger');

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => !Number.isInteger(param))) {
throw new Error('One of your parameters does not evaluate to a integer');
}
Expand All @@ -19,7 +19,7 @@ const handleErrors = (params) => {

const factorialCache = [1, 1];

const caclulateFactorial = (num) => {
const calculateFactorial = (num) => {
if (typeof factorialCache[num] !== 'undefined') {
return factorialCache[num];
}
Expand All @@ -33,13 +33,13 @@ const caclulateFactorial = (num) => {
};

/**
* This function caculates the factorial of each numerical parameter
* This function calculates the factorial of each numerical parameter
* @memberof variadic
* @author devNoiseConsulting
* @param {...*} params - One or more parameters.
*/
exports.factorial = (...params) => {
handleErrors(params);

return params.map(caclulateFactorial);
return params.map(calculateFactorial);
};
2 changes: 1 addition & 1 deletion lib/floatPrecise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.floatPrecise = (num) => {

// Reverse loop through number looking for index of last precise digit.
// Imprecise floats typically contain a long string of 9s or 0s,
// somtimes terminating in some other number,
// sometimes terminating in some other number,
// so begin loop at second to last index.
let i = str.length - 2;
const imprecise = str[i] === '9' ? '9' : '0';
Expand Down
2 changes: 1 addition & 1 deletion lib/isAscending.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @param {...*} params - One or more parameters.
*/
exports.isAscending = (...params) => {
if (params.length < 2) throw new Error('Must provide two or more paramters');
if (params.length < 2) throw new Error('Must provide two or more parameters');
let value = params.shift();
for (const param of params) {
if (Number.isNaN(parseFloat(param))) throw new Error('One of your parameters does not evaluate to a number');
Expand Down
8 changes: 4 additions & 4 deletions lib/isComposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const { isPrime } = require('./isPrime');
// `isPrime` checks if the number is an integer greater than 1
// but since we simply want `isPrime` to check if this number
// is prime, we need to do the check again to avoid a false result.
const testComposit = num => (num % 1 || num < 2 ? false : !isPrime(num));
const testComposite = num => (num % 1 || num < 2 ? false : !isPrime(num));

/**
* This function evaluates whether all numerical parameters are composit
* This function evaluates whether all numerical parameters are composite
* @memberof variadic
* @author tdnelson2
* @param {...*} params - One or more parameters.
*/
exports.isComposit = (...params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
return params.every(testComposit);
if (params.length === 0) throw new Error('Must provide one or more parameters');
return params.every(testComposite);
};
2 changes: 1 addition & 1 deletion lib/isDescending.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @param {...*} params - One or more parameters.
*/
exports.isDescending = (...params) => {
if (params.length < 2) throw new Error('Must provide two or more paramters');
if (params.length < 2) throw new Error('Must provide two or more parameters');

let value = params.shift();
for (const param of params) {
Expand Down
2 changes: 1 addition & 1 deletion lib/isEqual.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @param {...*} params - One or more parameters.
*/
exports.isEqual = (...params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
const firstParam = params.shift();
for (const param of params) {
switch (typeof param) {
Expand Down
2 changes: 1 addition & 1 deletion lib/isPrime.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const testPrime = (num) => {
* @param {...*} params - One or more parameters.
*/
exports.isPrime = (...params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => Number.isNaN(Number(param)))) throw new Error('One of your parameters does not evaluate to a number');
// JS can only safely represent and compare integers
// up to Number.MAX_SAFE_INTEGER: i.e., 9,007,199,254,740,991.
Expand Down
2 changes: 1 addition & 1 deletion lib/maximum.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameterss');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/median.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { average } = require('./average');

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/minimum.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/mode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/populationStandardDeviation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { populationVariance } = require('./populationVariance');
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length <= 1) throw new Error('Must provide two or more paramters');
if (params.length <= 1) throw new Error('Must provide two or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/populationVariance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { average } = require('./average');
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length <= 1) throw new Error('Must provide two or more paramters');
if (params.length <= 1) throw new Error('Must provide two or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const testMaxMinSafe = (params) => {
};

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/sampleStandardDeviation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { sampleVariance } = require('./sampleVariance');
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length <= 1) throw new Error('Must provide two or more paramters');
if (params.length <= 1) throw new Error('Must provide two or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/sampleVariance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { average } = require('./average');
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length <= 1) throw new Error('Must provide two or more paramters');
if (params.length <= 1) throw new Error('Must provide two or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/sum.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { floatPrecise } = require('./floatPrecise');

const handleErrors = (params) => {
if (params.length === 0) throw new Error('Must provide one or more paramters');
if (params.length === 0) throw new Error('Must provide one or more parameters');
if (params.some(param => typeof param !== 'number')) {
throw new Error('One of your parameters does not evaluate to a number');
}
Expand Down
Loading