const foo = {
bar: {
baz: true
}
}
dotObj('foo.bar.baz', foo); // true
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
export const encodeQueryString = (params) => { | |
const keys = Object.keys(params); | |
const encode = (param) => { | |
const value = params[param]; | |
const pair = [param]; | |
if (value) { | |
pair.push(value); | |
} |
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
module.exports = (data, size = 10) => { | |
let chunk = []; | |
return data.reduce((chunks, item, index) => { | |
chunk.push(item); | |
if (chunk.length >= size || index === data.length - 1) { | |
chunks.push(chunk); | |
chunk = []; | |
} |
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
module.exports = (value) => { | |
return value && typeof value.then === 'function' && typeof value.catch === 'function'; | |
}; |
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 PERMISSION_WRITE = 'clipboard-write'; | |
const canUseAsyncAPI = () => { | |
return ( | |
navigator.clipboard && | |
navigator.clipboard.writeText && | |
navigator.permissions && | |
navigator.permissions.request | |
); | |
}; |
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
module.exports = (foreground, background) => { | |
const l1 = Math.max(foreground, background); | |
const l2 = Math.min(foreground, background); | |
return (l1 + 0.05) / (l2 + 0.05); | |
}; |
NewerOlder