A curry-function which returns width and height for a fixed-format child-element you want to cover a dynamic-format parent-element.
Similar to the css-rule background-size: cover.
yarn add cover-box
import coverBox from 'cover-box'
coverBox(16,9)(1,1)
// > [1.7777777777777777, 1]
const cover169 = coverBox(16,9)
cover169(1280,720)
// > [1280, 720]
cover169(200,100)
// > [200, 112.5]
cover169(100,200)
// > [355.55555555555554, 200]
const mybox = document.querySelector('.my-box');
const setSize = () => {
const size = coverBox(16,9)(window.innerWidth,window.innerHeight);
mybox.style.width = `${size[0]}px`;
mybox.style.height = `${size[1]}px`;
};
window.addEventListener('resize', setSize);
setSize();