Fixed some issues in test files
This commit is contained in:
1357
package-lock.json
generated
1357
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@ const URLJoin = (...args) =>
|
||||
args
|
||||
.join('/')
|
||||
.replace(/[\/]+/g, '/')
|
||||
.replace(/^(.+):\
|
||||
.replace(/^(.+):\//, '$1://')
|
||||
.replace(/^file:/, 'file:/')
|
||||
.replace(/\/(\?|&|#[^!])/g, '$1')
|
||||
.replace(/\?/g, '&')
|
||||
|
||||
@ -5,7 +5,7 @@ cleanObj(obj[key], keysToKeep, childIndicator);
|
||||
} else if (!keysToKeep.includes(key)) {
|
||||
delete obj[key];
|
||||
}
|
||||
|
||||
});
|
||||
return obj;
|
||||
};
|
||||
module.exports = cleanObj;
|
||||
@ -15,5 +15,5 @@ bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`,
|
||||
bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
|
||||
bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
|
||||
bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
|
||||
|
||||
});
|
||||
module.exports = colorize;
|
||||
@ -2,5 +2,5 @@ const countBy = (arr, fn) =>
|
||||
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {
|
||||
acc[val] = (acc[val] || 0) + 1;
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = countBy;
|
||||
@ -11,5 +11,5 @@ off(event, handler) {
|
||||
const i = (this.hub[event] || []).findIndex(h => h === handler);
|
||||
if (i > -1) this.hub[event].splice(i, 1);
|
||||
}
|
||||
|
||||
});
|
||||
module.exports = createEventHub;
|
||||
@ -4,5 +4,5 @@ const pre = prefix.length ? prefix + '.' : '';
|
||||
if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k));
|
||||
else acc[pre + k] = obj[k];
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = flattenObject;
|
||||
@ -1,5 +1,5 @@
|
||||
const getScrollPosition = (el = window) => ({
|
||||
x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,
|
||||
y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop
|
||||
|
||||
});
|
||||
module.exports = getScrollPosition;
|
||||
@ -2,5 +2,5 @@ const groupBy = (arr, fn) =>
|
||||
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;
|
||||
@ -5,5 +5,5 @@ view = new DataView(h);
|
||||
for (let i = 0; i < view.byteLength; i += 4)
|
||||
hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));
|
||||
return hexes.join('');
|
||||
|
||||
});
|
||||
module.exports = hashBrowser;
|
||||
@ -1,4 +1,4 @@
|
||||
const httpsRedirect = () => {
|
||||
if (location.protocol !== 'https:') location.replace('https:
|
||||
if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
||||
};
|
||||
module.exports = httpsRedirect;
|
||||
@ -4,5 +4,5 @@ const val = fn ? fn(obj[key]) : obj[key];
|
||||
acc[val] = acc[val] || [];
|
||||
acc[val].push(key);
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = invertKeyValues;
|
||||
@ -2,5 +2,5 @@ const lowercaseKeys = obj =>
|
||||
Object.keys(obj).reduce((acc, key) => {
|
||||
acc[key.toLowerCase()] = obj[key];
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = lowercaseKeys;
|
||||
@ -2,5 +2,5 @@ const mapKeys = (obj, fn) =>
|
||||
Object.keys(obj).reduce((acc, k) => {
|
||||
acc[fn(obj[k], k, obj)] = obj[k];
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = mapKeys;
|
||||
@ -2,5 +2,5 @@ const mapValues = (obj, fn) =>
|
||||
Object.keys(obj).reduce((acc, k) => {
|
||||
acc[k] = fn(obj[k], k, obj);
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = mapValues;
|
||||
@ -3,7 +3,7 @@ const times = fns.map(fn => {
|
||||
const before = performance.now();
|
||||
for (let i = 0; i < iterations; i++) fn();
|
||||
return performance.now() - before;
|
||||
|
||||
});
|
||||
return times.indexOf(Math.min(...times));
|
||||
};
|
||||
module.exports = mostPerformant;
|
||||
@ -1,2 +1,2 @@
|
||||
const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {
|
||||
const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
|
||||
module.exports = objectFromPairs;
|
||||
@ -1,5 +1,5 @@
|
||||
const omit = (obj, arr) =>
|
||||
Object.keys(obj)
|
||||
.filter(k => !arr.includes(k))
|
||||
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {
|
||||
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
||||
module.exports = omit;
|
||||
@ -1,5 +1,5 @@
|
||||
const omitBy = (obj, fn) =>
|
||||
Object.keys(obj)
|
||||
.filter(k => !fn(obj[k], k))
|
||||
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {
|
||||
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
||||
module.exports = omitBy;
|
||||
@ -10,6 +10,6 @@ lastTime = now;
|
||||
document.addEventListener('touchstart', () => {
|
||||
if (type === 'touch') return;
|
||||
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
||||
|
||||
});
|
||||
};
|
||||
module.exports = onUserInputChange;
|
||||
@ -5,5 +5,5 @@ str
|
||||
.reduce((acc, v) => {
|
||||
acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim());
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = parseCookie;
|
||||
@ -1,3 +1,3 @@
|
||||
const pick = (obj, arr) =>
|
||||
arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {
|
||||
arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});
|
||||
module.exports = pick;
|
||||
@ -1,5 +1,5 @@
|
||||
const pickBy = (obj, fn) =>
|
||||
Object.keys(obj)
|
||||
.filter(k => fn(obj[k], k))
|
||||
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {
|
||||
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
||||
module.exports = pickBy;
|
||||
@ -13,7 +13,7 @@ const run = () => {
|
||||
raf = requestAnimationFrame(() => {
|
||||
callback();
|
||||
if (running) run();
|
||||
|
||||
});
|
||||
};
|
||||
if (autoStart) start();
|
||||
return { start, stop };
|
||||
|
||||
@ -11,6 +11,6 @@ res(data), worker.terminate();
|
||||
worker.onerror = err => {
|
||||
rej(err), worker.terminate();
|
||||
};
|
||||
|
||||
});
|
||||
};
|
||||
module.exports = runAsync;
|
||||
@ -1,5 +1,5 @@
|
||||
const smoothScroll = element =>
|
||||
document.querySelector(element).scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
|
||||
});
|
||||
module.exports = smoothScroll;
|
||||
@ -22,7 +22,7 @@ stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a)));
|
||||
} else {
|
||||
throw `${symbol} is not a recognized symbol`;
|
||||
}
|
||||
|
||||
});
|
||||
if (stack.length === 1) return stack.pop();
|
||||
else throw `${rpn} is not a proper RPN. Please check it and try again`;
|
||||
};
|
||||
|
||||
2055
test/testlog
2055
test/testlog
File diff suppressed because it is too large
Load Diff
@ -13,5 +13,5 @@ obj[k] +
|
||||
);
|
||||
} else acc[k] = obj[k];
|
||||
return acc;
|
||||
}, {
|
||||
}, {});
|
||||
module.exports = unflattenObject;
|
||||
@ -2,6 +2,6 @@ const zip = (...arrays) => {
|
||||
const maxLength = Math.max(...arrays.map(x => x.length));
|
||||
return Array.from({ length: maxLength }).map((_, i) => {
|
||||
return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
|
||||
|
||||
});
|
||||
};
|
||||
module.exports = zip;
|
||||
@ -1,3 +1,3 @@
|
||||
const zipObject = (props, values) =>
|
||||
props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {
|
||||
props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {});
|
||||
module.exports = zipObject;
|
||||
Reference in New Issue
Block a user