Add degreesToRads and radsToDegrees
This commit is contained in:
@ -10,5 +10,5 @@ const functionName = arguments =>
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
functionName('sampleInput') // 'sampleOutput'
|
functionName('sampleInput'); // 'sampleOutput'
|
||||||
```
|
```
|
||||||
|
|||||||
13
snippets/degreesToRads.md
Normal file
13
snippets/degreesToRads.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### degreesToRads
|
||||||
|
|
||||||
|
Converts an angle from degrees to radians.
|
||||||
|
|
||||||
|
Use `Math.PI` and the degree to radian formula to convert the angle from degrees to radians.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const degreesToRads = deg => deg * Math.PI / 180.0;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
degreesToRads(90.0); // ~1.5708
|
||||||
|
```
|
||||||
13
snippets/radsToDegrees.md
Normal file
13
snippets/radsToDegrees.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### radsToDegrees
|
||||||
|
|
||||||
|
Converts an angle from radians to degrees.
|
||||||
|
|
||||||
|
Use `Math.PI` and the radian to degree formula to convert the angle from radians to degrees.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const radsToDegrees = rad => rad * 180.0 / Math.PI;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
radsToDegrees(Math.PI / 2); // 90
|
||||||
|
```
|
||||||
@ -42,6 +42,7 @@ deepClone:object,recursion
|
|||||||
deepFlatten:array,recursion
|
deepFlatten:array,recursion
|
||||||
defaults:object
|
defaults:object
|
||||||
defer:function
|
defer:function
|
||||||
|
degreesToRads:math
|
||||||
delay:function
|
delay:function
|
||||||
detectDeviceType:browser
|
detectDeviceType:browser
|
||||||
difference:array,math
|
difference:array,math
|
||||||
@ -189,6 +190,7 @@ pull:array
|
|||||||
pullAtIndex:array
|
pullAtIndex:array
|
||||||
pullAtValue:array
|
pullAtValue:array
|
||||||
pullBy:array,function,advanced
|
pullBy:array,function,advanced
|
||||||
|
radsToDegrees:math
|
||||||
randomHexColorCode:utility,random
|
randomHexColorCode:utility,random
|
||||||
randomIntArrayInRange:math,utility,random
|
randomIntArrayInRange:math,utility,random
|
||||||
randomIntegerInRange:math,utility,random
|
randomIntegerInRange:math,utility,random
|
||||||
|
|||||||
@ -1,6 +1,3 @@
|
|||||||
const bifurcate = (arr, filter) =>
|
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;
|
module.exports = bifurcate;
|
||||||
@ -1,6 +1,3 @@
|
|||||||
const bifurcateBy = (arr, fn) =>
|
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;
|
module.exports = bifurcateBy;
|
||||||
2
test/degreesToRads/degreesToRads.js
Normal file
2
test/degreesToRads/degreesToRads.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const degreesToRads = deg => deg * Math.PI / 180.0;
|
||||||
|
module.exports = degreesToRads;
|
||||||
15
test/degreesToRads/degreesToRads.test.js
Normal file
15
test/degreesToRads/degreesToRads.test.js
Normal 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();
|
||||||
|
});
|
||||||
2
test/radsToDegrees/radsToDegrees.js
Normal file
2
test/radsToDegrees/radsToDegrees.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const radsToDegrees = rad => rad * 180.0 / Math.PI;
|
||||||
|
module.exports = radsToDegrees;
|
||||||
14
test/radsToDegrees/radsToDegrees.test.js
Normal file
14
test/radsToDegrees/radsToDegrees.test.js
Normal 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();
|
||||||
|
});
|
||||||
16
test/testlog
16
test/testlog
@ -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
|
> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
|
||||||
> tape test/**/*.test.js | tap-spec
|
> 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
|
√ defer is a Function
|
||||||
|
|
||||||
|
Testing degreesToRads
|
||||||
|
|
||||||
|
√ degreesToRads is a Function
|
||||||
|
√ Returns the appropriate value
|
||||||
|
|
||||||
Testing delay
|
Testing delay
|
||||||
|
|
||||||
√ delay is a Function
|
√ 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(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
|
√ 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
|
Testing randomHexColorCode
|
||||||
|
|
||||||
√ randomHexColorCode is a Function
|
√ 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
|
√ Works with multiple promises
|
||||||
|
|
||||||
|
|
||||||
total: 909
|
total: 913
|
||||||
passing: 909
|
passing: 913
|
||||||
duration: 2.4s
|
duration: 2.4s
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user