Merge branch 'master' into lev-dist
This commit is contained in:
6
test/stableSort/stableSort.js
Normal file
6
test/stableSort/stableSort.js
Normal file
@ -0,0 +1,6 @@
|
||||
const stableSort = (arr, compare) =>
|
||||
arr
|
||||
.map((item, index) => ({ item, index }))
|
||||
.sort((a, b) => compare(a.item, b.item) || a.index - b.index)
|
||||
.map(({ item }) => item);
|
||||
module.exports = stableSort;
|
||||
17
test/stableSort/stableSort.test.js
Normal file
17
test/stableSort/stableSort.test.js
Normal file
@ -0,0 +1,17 @@
|
||||
const test = require('tape');
|
||||
const stableSort = require('./stableSort.js');
|
||||
|
||||
test('Testing stableSort', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof stableSort === 'function', 'stableSort is a Function');
|
||||
//t.deepEqual(stableSort(args..), 'Expected');
|
||||
//t.equal(stableSort(args..), 'Expected');
|
||||
//t.false(stableSort(args..), 'Expected');
|
||||
//t.throws(stableSort(args..), 'Expected');
|
||||
|
||||
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
const compare = () => 0;
|
||||
t.deepEqual(stableSort(arr, compare), arr, 'Array is properly sorted');
|
||||
t.end();
|
||||
});
|
||||
@ -1,4 +1,4 @@
|
||||
Test log for: Sun Feb 18 2018 19:56:04 GMT+0530 (India Standard Time)
|
||||
Test log for: Sun Feb 18 2018 20:24:43 GMT+0000 (UTC)
|
||||
|
||||
> 30-seconds-of-code@0.0.2 test R:\github\30-seconds-of-code
|
||||
> tape test/**/*.test.js | tap-spec
|
||||
@ -1527,6 +1527,11 @@ Test log for: Sun Feb 18 2018 19:56:04 GMT+0530 (India Standard Time)
|
||||
√ spreadOver is a Function
|
||||
√ Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
|
||||
|
||||
Testing stableSort
|
||||
|
||||
✔ stableSort is a Function
|
||||
✔ Array is properly sorted
|
||||
|
||||
Testing standardDeviation
|
||||
|
||||
√ standardDeviation is a Function
|
||||
@ -1915,6 +1920,7 @@ Test log for: Sun Feb 18 2018 19:56:04 GMT+0530 (India Standard Time)
|
||||
√ Works with multiple promises
|
||||
|
||||
|
||||
|
||||
total: 974
|
||||
passing: 974
|
||||
duration: 2.9s
|
||||
|
||||
Reference in New Issue
Block a user