This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// quick idea to reduce an array by automatically merging result of iteratee(current, i, src) onto acc | |
const reduceMerge = (arr, iteratee) => | |
arr.reduce((acc, cur, i, src) => { | |
const val = iteratee(cur, i, src) | |
// allow falsy returns to result in noop for this iteration | |
if (!val) { | |
return acc | |
} else if (val.constructor === Object) { | |
return Object.assign(acc, val) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { configureCacheGroups } = require('./webpack.utils') | |
const cacheGroups = configureCacheGroups({ | |
'react': ['react', 'react-dom'], | |
'lodash': ['lodash'], | |
'redux': ['redux', 'react-redux'], | |
'semantic-ui': ['semantic-ui-react'], | |
'core-js': ['core-js'], | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Round up to nearest base, in base 10. Works for both negative/positive numbers and numbers -1 < n < 1. | |
// Useful for calculating a sensible/readible graph domain max if you input the max value of your data. | |
export const roundUpBaseInRange = (n, bases = [1, 2, 4, 5, 6, 8, 10]) => { | |
// Store the sign, so we can restore it for the result lateron | |
const sign = Math.sign(n) | |
// Get modulus (remove sign) for next steps in calculation | |
const modulus = Math.abs(n) | |
// Calculate base10 exponent (i.e. amount of digits as float instead of integer) |
NewerOlder