Add semicolon for tdd exports

This commit is contained in:
Angelos Chalaris
2018-02-04 17:38:39 +02:00
parent ea2e45b969
commit 6709e181d7
290 changed files with 291 additions and 291 deletions

View File

@ -61,7 +61,7 @@ snippetFiles
.filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]);
// Export template for snippetName.js
const exportFile = `${fileFunction.join('\n')}\nmodule.exports = ${fileName}`.trim();
const exportFile = `${fileFunction.join('\n')}\nmodule.exports = ${fileName};`.trim();
// Export template for snippetName.test.js which generates a example test & other information
const exportTest = [

View File

@ -2,4 +2,4 @@ const JSONToDate = arr => {
const dt = new Date(parseInt(arr.toString().substr(6)));
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
};
module.exports = JSONToDate
module.exports = JSONToDate;

View File

@ -1,4 +1,4 @@
const fs = require('fs');
const JSONToFile = (obj, filename) =>
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
module.exports = JSONToFile
module.exports = JSONToFile;

View File

@ -1,2 +1,2 @@
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
module.exports = RGBToHex
module.exports = RGBToHex;

View File

@ -7,4 +7,4 @@ args
.replace(/\/(\?|&|#[^!])/g, '$1')
.replace(/\?/g, '&')
.replace('&', '?');
module.exports = URLJoin
module.exports = URLJoin;

View File

@ -2,4 +2,4 @@ const UUIDGeneratorBrowser = () =>
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
);
module.exports = UUIDGeneratorBrowser
module.exports = UUIDGeneratorBrowser;

View File

@ -3,4 +3,4 @@ const UUIDGeneratorNode = () =>
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
);
module.exports = UUIDGeneratorNode
module.exports = UUIDGeneratorNode;

View File

@ -8,4 +8,4 @@ acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)
[]
);
};
module.exports = anagrams
module.exports = anagrams;

View File

@ -1,3 +1,3 @@
const arrayToHtmlList = (arr, listID) =>
arr.map(item => (document.querySelector('#' + listID).innerHTML += `<li>${item}</li>`));
module.exports = arrayToHtmlList
module.exports = arrayToHtmlList;

View File

@ -1,2 +1,2 @@
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
module.exports = ary
module.exports = ary;

View File

@ -1,2 +1,2 @@
const atob = str => new Buffer(str, 'base64').toString('binary');
module.exports = atob
module.exports = atob;

View File

@ -5,4 +5,4 @@ return fn(args);
return e instanceof Error ? e : new Error(e);
}
};
module.exports = attempt
module.exports = attempt;

View File

@ -1,2 +1,2 @@
const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length;
module.exports = average
module.exports = average;

View File

@ -1,4 +1,4 @@
const averageBy = (arr, fn) =>
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
arr.length;
module.exports = averageBy
module.exports = averageBy;

View File

@ -5,4 +5,4 @@ if (arr[mid] > val) return binarySearch(arr, val, start, mid - 1);
if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end);
return mid;
}
module.exports = binarySearch
module.exports = binarySearch;

View File

@ -2,4 +2,4 @@ const bind = (fn, context, ...args) =>
function() {
return fn.apply(context, args.concat(...arguments));
};
module.exports = bind
module.exports = bind;

View File

@ -7,4 +7,4 @@ return f.apply(obj);
})
)
);
module.exports = bindAll
module.exports = bindAll;

View File

@ -2,4 +2,4 @@ const bindKey = (context, fn, ...args) =>
function() {
return context[fn].apply(context, args.concat(...arguments));
};
module.exports = bindKey
module.exports = bindKey;

View File

@ -1,4 +1,4 @@
const bottomVisible = () =>
document.documentElement.clientHeight + window.scrollY >=
(document.documentElement.scrollHeight || document.documentElement.clientHeight);
module.exports = bottomVisible
module.exports = bottomVisible;

View File

@ -1,2 +1,2 @@
const btoa = str => new Buffer(str, 'binary').toString('base64');
module.exports = btoa
module.exports = btoa;

View File

@ -1,2 +1,2 @@
const byteSize = str => new Blob([str]).size;
module.exports = byteSize
module.exports = byteSize;

View File

@ -1,2 +1,2 @@
const call = (key, ...args) => context => context[key](...args);
module.exports = call
module.exports = call;

View File

@ -1,3 +1,3 @@
const capitalize = ([first, ...rest], lowerRest = false) =>
first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));
module.exports = capitalize
module.exports = capitalize;

View File

@ -1,2 +1,2 @@
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
module.exports = capitalizeEveryWord
module.exports = capitalizeEveryWord;

View File

@ -1,2 +1,2 @@
const castArray = val => (Array.isArray(val) ? val : [val]);
module.exports = castArray
module.exports = castArray;

View File

@ -3,4 +3,4 @@ let curr = 0;
const next = () => fns[curr++](next);
next();
};
module.exports = chainAsync
module.exports = chainAsync;

View File

@ -2,4 +2,4 @@ const chunk = (arr, size) =>
Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>
arr.slice(i * size, i * size + size)
);
module.exports = chunk
module.exports = chunk;

View File

@ -1,2 +1,2 @@
const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
module.exports = clampNumber
module.exports = clampNumber;

View File

@ -8,4 +8,4 @@ delete obj[key];
});
return obj;
};
module.exports = cleanObj
module.exports = cleanObj;

View File

@ -1,2 +1,2 @@
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
module.exports = cloneRegExp
module.exports = cloneRegExp;

View File

@ -1,2 +1,2 @@
const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));
module.exports = coalesce
module.exports = coalesce;

View File

@ -1,2 +1,2 @@
const coalesceFactory = valid => (...args) => args.find(valid);
module.exports = coalesceFactory
module.exports = coalesceFactory;

View File

@ -1,2 +1,2 @@
const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1);
module.exports = collatz
module.exports = collatz;

View File

@ -1,2 +1,2 @@
const collectInto = fn => (...args) => fn(args);
module.exports = collectInto
module.exports = collectInto;

View File

@ -16,4 +16,4 @@ bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
});
module.exports = colorize
module.exports = colorize;

View File

@ -1,2 +1,2 @@
const compact = arr => arr.filter(Boolean);
module.exports = compact
module.exports = compact;

View File

@ -1,2 +1,2 @@
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
module.exports = compose
module.exports = compose;

View File

@ -1,2 +1,2 @@
const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
module.exports = composeRight
module.exports = composeRight;

View File

@ -15,4 +15,4 @@ document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
}
};
module.exports = copyToClipboard
module.exports = copyToClipboard;

View File

@ -3,4 +3,4 @@ arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) =>
acc[val] = (acc[val] || 0) + 1;
return acc;
}, {});
module.exports = countBy
module.exports = countBy;

View File

@ -1,2 +1,2 @@
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0);
module.exports = countOccurrences
module.exports = countOccurrences;

View File

@ -1,2 +1,2 @@
const countVowels = str => (str.match(/[aeiou]/gi) || []).length;
module.exports = countVowels
module.exports = countVowels;

View File

@ -3,4 +3,4 @@ const el = document.createElement('div');
el.innerHTML = str;
return el.firstElementChild;
};
module.exports = createElement
module.exports = createElement;

View File

@ -12,4 +12,4 @@ const i = (this.hub[event] || []).findIndex(h => h === handler);
if (i > -1) this.hub[event].splice(i, 1);
}
});
module.exports = createEventHub
module.exports = createEventHub;

View File

@ -1,2 +1,2 @@
const currentURL = () => window.location.href;
module.exports = currentURL
module.exports = currentURL;

View File

@ -1,3 +1,3 @@
const curry = (fn, arity = fn.length, ...args) =>
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
module.exports = curry
module.exports = curry;

View File

@ -7,4 +7,4 @@ clearTimeout(inDebounce);
inDebounce = setTimeout(() => fn.apply(context, args), wait);
};
};
module.exports = debounce
module.exports = debounce;

View File

@ -1,3 +1,3 @@
const decapitalize = ([first, ...rest], upperRest = false) =>
first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join(''));
module.exports = decapitalize
module.exports = decapitalize;

View File

@ -5,4 +5,4 @@ key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[ke
);
return clone;
};
module.exports = deepClone
module.exports = deepClone;

View File

@ -1,2 +1,2 @@
const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));
module.exports = deepFlatten
module.exports = deepFlatten;

View File

@ -1,2 +1,2 @@
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
module.exports = defaults
module.exports = defaults;

View File

@ -1,2 +1,2 @@
const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
module.exports = defer
module.exports = defer;

View File

@ -1,2 +1,2 @@
const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
module.exports = delay
module.exports = delay;

View File

@ -2,4 +2,4 @@ const detectDeviceType = () =>
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
? 'Mobile'
: 'Desktop';
module.exports = detectDeviceType
module.exports = detectDeviceType;

View File

@ -2,4 +2,4 @@ const difference = (a, b) => {
const s = new Set(b);
return a.filter(x => !s.has(x));
};
module.exports = difference
module.exports = difference;

View File

@ -2,4 +2,4 @@ const differenceBy = (a, b, fn) => {
const s = new Set(b.map(v => fn(v)));
return a.filter(x => !s.has(fn(x)));
};
module.exports = differenceBy
module.exports = differenceBy;

View File

@ -1,2 +1,2 @@
const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);
module.exports = differenceWith
module.exports = differenceWith;

View File

@ -1,2 +1,2 @@
const digitize = n => [...`${n}`].map(i => parseInt(i));
module.exports = digitize
module.exports = digitize;

View File

@ -1,2 +1,2 @@
const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
module.exports = distance
module.exports = distance;

View File

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

View File

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

View File

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

View File

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

View File

@ -6,4 +6,4 @@ return partiallyVisible
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
};
module.exports = elementIsVisibleInViewport
module.exports = elementIsVisibleInViewport;

View File

@ -16,4 +16,4 @@ j++;
}
return ratings;
};
module.exports = elo
module.exports = elo;

View File

@ -8,4 +8,4 @@ let keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) return false;
return keys.every(k => equals(a[k], b[k]));
};
module.exports = equals
module.exports = equals;

View File

@ -10,4 +10,4 @@ tag =>
'"': '&quot;'
}[tag] || tag)
);
module.exports = escapeHTML
module.exports = escapeHTML;

View File

@ -1,2 +1,2 @@
const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
module.exports = escapeRegExp
module.exports = escapeRegExp;

View File

@ -1,2 +1,2 @@
const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
module.exports = everyNth
module.exports = everyNth;

View File

@ -5,4 +5,4 @@ shortHex
.split('')
.map(x => x + x)
.join('');
module.exports = extendHex
module.exports = extendHex;

View File

@ -4,4 +4,4 @@ n < 0
throw new TypeError('Negative numbers are not allowed!');
})()
: n <= 1 ? 1 : n * factorial(n - 1);
module.exports = factorial
module.exports = factorial;

View File

@ -17,4 +17,4 @@ return acc;
}, []);
return primes ? array.filter(isPrime) : array;
};
module.exports = factors
module.exports = factors;

View File

@ -3,4 +3,4 @@ Array.from({ length: n }).reduce(
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
[]
);
module.exports = fibonacci
module.exports = fibonacci;

View File

@ -1,3 +1,3 @@
const fibonacciCountUntilNum = num =>
Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
module.exports = fibonacciCountUntilNum
module.exports = fibonacciCountUntilNum;

View File

@ -5,4 +5,4 @@ return Array.from({ length: n }).reduce(
[]
);
};
module.exports = fibonacciUntilNum
module.exports = fibonacciUntilNum;

View File

@ -1,2 +1,2 @@
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
module.exports = filterNonUnique
module.exports = filterNonUnique;

View File

@ -1,2 +1,2 @@
const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));
module.exports = findKey
module.exports = findKey;

View File

@ -1,2 +1,2 @@
const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0];
module.exports = findLast
module.exports = findLast;

View File

@ -3,4 +3,4 @@ arr
.map((val, i) => [i, val])
.filter(val => fn(val[1], val[0], arr))
.slice(-1)[0][0];
module.exports = findLastIndex
module.exports = findLastIndex;

View File

@ -2,4 +2,4 @@ const findLastKey = (obj, fn) =>
Object.keys(obj)
.reverse()
.find(key => fn(obj[key], key, obj));
module.exports = findLastKey
module.exports = findLastKey;

View File

@ -2,4 +2,4 @@ const flatten = (arr, depth = 1) =>
depth != 1
? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flatten(v, depth - 1) : v), [])
: arr.reduce((a, v) => a.concat(v), []);
module.exports = flatten
module.exports = flatten;

View File

@ -1,2 +1,2 @@
const flip = fn => (first, ...rest) => fn(...rest, first);
module.exports = flip
module.exports = flip;

View File

@ -3,4 +3,4 @@ arr
.slice(0)
.reverse()
.forEach(callback);
module.exports = forEachRight
module.exports = forEachRight;

View File

@ -1,2 +1,2 @@
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
module.exports = forOwn
module.exports = forOwn;

View File

@ -2,4 +2,4 @@ const forOwnRight = (obj, fn) =>
Object.keys(obj)
.reverse()
.forEach(key => fn(obj[key], key, obj));
module.exports = forOwnRight
module.exports = forOwnRight;

View File

@ -12,4 +12,4 @@ return Object.entries(time)
.map(val => val[1] + ' ' + (val[1] !== 1 ? val[0] + 's' : val[0]))
.join(', ');
};
module.exports = formatDuration
module.exports = formatDuration;

View File

@ -3,4 +3,4 @@ str
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2')
.toLowerCase();
module.exports = fromCamelCase
module.exports = fromCamelCase;

View File

@ -1,2 +1,2 @@
const functionName = fn => (console.debug(fn.name), fn);
module.exports = functionName
module.exports = functionName;

View File

@ -3,4 +3,4 @@ const functions = (obj, inherited = false) =>
? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]
: Object.keys(obj)
).filter(key => typeof obj[key] === 'function');
module.exports = functions
module.exports = functions;

View File

@ -2,4 +2,4 @@ const gcd = (...arr) => {
const _gcd = (x, y) => (!y ? x : gcd(y, x % y));
return [...arr].reduce((a, b) => _gcd(a, b));
};
module.exports = gcd
module.exports = gcd;

View File

@ -2,4 +2,4 @@ const geometricProgression = (end, start = 1, step = 2) =>
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
(v, i) => start * step ** i
);
module.exports = geometricProgression
module.exports = geometricProgression;

View File

@ -6,4 +6,4 @@ s
.filter(t => t !== '')
.reduce((prev, cur) => prev && prev[cur], from)
);
module.exports = get
module.exports = get;

View File

@ -1,2 +1,2 @@
const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
module.exports = getColonTimeFromDate
module.exports = getColonTimeFromDate;

View File

@ -1,3 +1,3 @@
const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
(dateFinal - dateInitial) / (1000 * 3600 * 24);
module.exports = getDaysDiffBetweenDates
module.exports = getDaysDiffBetweenDates;

View File

@ -2,4 +2,4 @@ const getMeridiemSuffixOfInteger = num =>
num === 0 || num === 24
? 12 + 'am'
: num === 12 ? 12 + 'pm' : num < 12 ? num % 12 + 'am' : num % 12 + 'pm';
module.exports = getMeridiemSuffixOfInteger
module.exports = getMeridiemSuffixOfInteger;

View File

@ -2,4 +2,4 @@ const getScrollPosition = (el = window) => ({
x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,
y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop
});
module.exports = getScrollPosition
module.exports = getScrollPosition;

View File

@ -1,2 +1,2 @@
const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
module.exports = getStyle
module.exports = getStyle;

View File

@ -1,3 +1,3 @@
const getType = v =>
v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();
module.exports = getType
module.exports = getType;

View File

@ -3,4 +3,4 @@ const getURLParameters = url =>
(a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a),
{}
);
module.exports = getURLParameters
module.exports = getURLParameters;

View File

@ -3,4 +3,4 @@ arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) =>
acc[val] = (acc[val] || []).concat(arr[i]);
return acc;
}, {});
module.exports = groupBy
module.exports = groupBy;

Some files were not shown because too many files have changed in this diff Show More