Travis build: 1447 [cron]

This commit is contained in:
30secondsofcode
2018-01-26 20:13:34 +00:00
parent 93c5393a8a
commit 7fd1a87d47
29 changed files with 485 additions and 1515 deletions

8
test/bindAll/bindAll.js Normal file
View File

@ -0,0 +1,8 @@
const bindAll = (obj, ...fns) =>
fns.forEach(
fn =>
(obj[fn] = function() {
return fn.apply(obj);
})
);
module.exports = bindAll

View File

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

2
test/drop/drop.js Normal file
View File

@ -0,0 +1,2 @@
const drop = (arr, n = 1) => arr.slice(n);
module.exports = drop

13
test/drop/drop.test.js Normal file
View File

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

View File

@ -0,0 +1,5 @@
const dropRightWhile = (arr, func) => {
while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1);
return arr;
};
module.exports = dropRightWhile

View File

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

View File

@ -0,0 +1,5 @@
const dropWhile = (arr, func) => {
while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);
return arr;
};
module.exports = dropWhile

View File

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

10
test/pullBy/pullBy.js Normal file
View File

@ -0,0 +1,10 @@
const pullBy = (arr, ...args) => {
const length = args.length;
let fn = length > 1 ? args[length - 1] : undefined;
fn = typeof fn == 'function' ? (args.pop(), fn) : undefined;
let argState = (Array.isArray(args[0]) ? args[0] : args).map(val => fn(val));
let pulled = arr.filter((v, i) => !argState.includes(fn(v)));
arr.length = 0;
pulled.forEach(v => arr.push(v));
};
module.exports = pullBy

View File

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

View File

@ -0,0 +1,2 @@
const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
module.exports = removeNonASCII

View File

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

View File

@ -0,0 +1,7 @@
const sortedIndexBy = (arr, n, fn) => {
const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);
const val = fn(n);
const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el)));
return index === -1 ? arr.length : index;
};
module.exports = sortedIndexBy

View File

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

View File

@ -2,8 +2,8 @@ const sortedLastIndex = (arr, n) => {
const isDescending = arr[0] > arr[arr.length - 1];
const index = arr
.map((val, i) => [i, val])
.filter(el => (isDescending ? n >= el[1] : n >= el[1]))
.slice(-1)[0][0];
return index === -1 ? arr.length : index;
.reverse()
.findIndex(el => (isDescending ? n <= el[1] : n >= el[1]));
return index === -1 ? 0 : arr.length - index - 1;
};
module.exports = sortedLastIndex

View File

@ -0,0 +1,10 @@
const sortedLastIndexBy = (arr, n, fn) => {
const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);
const val = fn(n);
const index = arr
.map((val, i) => [i, fn(val)])
.reverse()
.findIndex(el => (isDescending ? val <= el[1] : val >= el[1]));
return index === -1 ? 0 : arr.length - index;
};
module.exports = sortedLastIndexBy

View File

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

View File

@ -0,0 +1,2 @@
const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
module.exports = stripHTMLTags

View File

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

View File

@ -0,0 +1,6 @@
const takeRightWhile = (arr, func) => {
for (let i of arr.reverse().keys())
if (func(arr[i])) return arr.reverse().slice(arr.length - i, arr.length);
return arr;
};
module.exports = takeRightWhile

View File

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

View File

@ -0,0 +1,5 @@
const takeWhile = (arr, func) => {
for (let i of arr.keys()) if (func(arr[i])) return arr.slice(0, i);
return arr;
};
module.exports = takeWhile

View File

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

File diff suppressed because it is too large Load Diff