UNPKG

postcss-calc

Version:
22 lines (18 loc) 542 B
import { num, dim, call } from '../node.js'; import { foldConstArgs } from './fold.js'; /** @typedef {import('../node.js').Node} Node */ /** * @param {string} name * @param {Node[]} args * @return {Node} */ function simplifyMinMax(name, args) { const fold = foldConstArgs(args); if (fold !== null) { const fn = name.toLowerCase() === 'min' ? Math.min : Math.max; const value = fn(...fold.values); return fold.unit === '' ? num(value) : dim(value, fold.unit); } return call(name, args); } export { simplifyMinMax };