Add degreesToRads and radsToDegrees

This commit is contained in:
Angelos Chalaris
2018-02-14 12:24:50 +02:00
parent d351fc3fe6
commit ed5e4e3398
11 changed files with 77 additions and 12 deletions

View File

@ -1,6 +1,3 @@
const bifurcate = (arr, filter) =>
arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [
[],
[],
]);
arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]);
module.exports = bifurcate;

View File

@ -1,6 +1,3 @@
const bifurcateBy = (arr, fn) =>
arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [
[],
[],
]);
arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]);
module.exports = bifurcateBy;

View File

@ -0,0 +1,2 @@
const degreesToRads = deg => deg * Math.PI / 180.0;
module.exports = degreesToRads;

View File

@ -0,0 +1,15 @@
const test = require('tape');
const degreesToRads = require('./degreesToRads.js');
test('Testing degreesToRads', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
const approxeq = (v1,v2, diff = 0.001) => Math.abs(v1 - v2) < diff; // Use to account for rounding errors
t.true(typeof degreesToRads === 'function', 'degreesToRads is a Function');
t.true(approxeq(degreesToRads(90.0), Math.PI / 2), 'Returns the appropriate value');
//t.deepEqual(degreesToRads(args..), 'Expected');
//t.equal(degreesToRads(args..), 'Expected');
//t.false(degreesToRads(args..), 'Expected');
//t.throws(degreesToRads(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,2 @@
const radsToDegrees = rad => rad * 180.0 / Math.PI;
module.exports = radsToDegrees;

View File

@ -0,0 +1,14 @@
const test = require('tape');
const radsToDegrees = require('./radsToDegrees.js');
test('Testing radsToDegrees', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof radsToDegrees === 'function', 'radsToDegrees is a Function');
t.equal(radsToDegrees(Math.PI / 2), 90, 'Returns the appropriate value');
//t.deepEqual(radsToDegrees(args..), 'Expected');
//t.equal(radsToDegrees(args..), 'Expected');
//t.false(radsToDegrees(args..), 'Expected');
//t.throws(radsToDegrees(args..), 'Expected');
t.end();
});

View File

@ -1,4 +1,4 @@
Test log for: Wed Feb 14 2018 12:12:48 GMT+0200 (GTB Standard Time)
Test log for: Wed Feb 14 2018 12:24:07 GMT+0200 (GTB Standard Time)
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
> tape test/**/*.test.js | tap-spec
@ -278,6 +278,11 @@ Test log for: Wed Feb 14 2018 12:12:48 GMT+0200 (GTB Standard Time)
√ defer is a Function
Testing degreesToRads
√ degreesToRads is a Function
√ Returns the appropriate value
Testing delay
√ delay is a Function
@ -1221,6 +1226,11 @@ Test log for: Wed Feb 14 2018 12:12:48 GMT+0200 (GTB Standard Time)
√ quickSort(undefined) throws an error
√ quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run
Testing radsToDegrees
√ radsToDegrees is a Function
√ Returns the appropriate value
Testing randomHexColorCode
√ randomHexColorCode is a Function
@ -1820,8 +1830,8 @@ Test log for: Wed Feb 14 2018 12:12:48 GMT+0200 (GTB Standard Time)
√ Works with multiple promises
total: 909
passing: 909
total: 913
passing: 913
duration: 2.4s