Calculate the entropy of a password.
const passEnt = require('passEnt');
const H = passEnt('pswd'); // 18.801758872564367| module.exports = (red, green, blue) => { | |
| const rs = red / 255; | |
| const gs = green / 255; | |
| const bs = blue / 255; | |
| const rn = rs <= 0.03928 ? rs / 12.92 : Math.pow((rs + 0.055) / 1.055, 2.4); | |
| const gn = gs <= 0.03928 ? gs / 12.92 : Math.pow((gs + 0.055) / 1.055, 2.4); | |
| const bn = bs <= 0.03928 ? bs / 12.92 : Math.pow((bs + 0.055) / 1.055, 2.4); | |
| return (0.2126 * rn) + (0.7152 * gn) + (0.0722 * bn); |
| module.exports = (foreground, background) => { | |
| const l1 = Math.max(foreground, background); | |
| const l2 = Math.min(foreground, background); | |
| return (l1 + 0.05) / (l2 + 0.05); | |
| }; |
| const PERMISSION_WRITE = 'clipboard-write'; | |
| const canUseAsyncAPI = () => { | |
| return ( | |
| navigator.clipboard && | |
| navigator.clipboard.writeText && | |
| navigator.permissions && | |
| navigator.permissions.request | |
| ); | |
| }; |
| module.exports = (value) => { | |
| return value && typeof value.then === 'function' && typeof value.catch === 'function'; | |
| }; |
| 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 = []; | |
| } |
| export const encodeQueryString = (params) => { | |
| const keys = Object.keys(params); | |
| const encode = (param) => { | |
| const value = params[param]; | |
| const pair = [param]; | |
| if (value) { | |
| pair.push(value); | |
| } |