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
:root { | |
--space-unit: 1rem; | |
--space-xxs: calc(0.25 * var(--space-unit)); | |
--space-xs: calc(0.5 * var(--space-unit)); | |
--space-sm: calc(0.75 * var(--space-unit)); | |
--space-md: calc(1.25 * var(--space-unit)); | |
--space-lg: calc(2 * var(--space-unit)); | |
--space-xl: calc(3.25 * var(--space-unit)); | |
--space-xxl: calc(5.25 * var(--space-unit)); | |
} |
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 function calculateIpv4Subnet(ipAddress, subnetMask) { | |
// helper functions | |
const numbersArrayFromString = v => v.split('.').map(v => parseInt(v)); | |
const numberBinaryAsString = v => (v >>> 0).toString(2).padStart(8, '0'); | |
const addressBinaryAsString = v => numbersArrayFromString(v).map(numberBinaryAsString).join(''); | |
const addressAsNumber = v => parseInt(addressBinaryAsString(v), 2); | |
const addressStringFromNumber = v => [24, 16, 8, 0].map(shift => (v >>> shift) & 255).join('.'); | |
ipAddressNumber = addressAsNumber(ipAddress); | |
subnetMaskNumber = addressAsNumber(subnetMask); |
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
^(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)){3}$ |