UNPKG

ratio-lock

Version:

A TypeScript library for managing n numbers with locked ratios. When the ratio is locked, changing one value automatically adjusts all other values to maintain their proportional relationships.

20 lines 619 B
import { parseNumber } from './parse-number.js'; /** * Creates the fields object with props for each field */ export function createFieldsObject(names, watchedValues, createOnChange) { const result = {}; for (let i = 0; i < names.length; i++) { const name = names[i]; const watchedValue = watchedValues[i]; if (name !== undefined) { result[name] = { name, value: parseNumber(watchedValue, name), onChange: createOnChange(i), }; } } return result; } //# sourceMappingURL=create-fields-object.js.map