import { Variable } from 'astal'; import { Binding } from 'astal/binding'; export const mergeBindings = ( array: (Value | Binding | Binding)[], ): Value[] | Binding => { const getValues = (args: Value[]) => { let i = 0; return array.map((value) => value instanceof Binding ? args[i++] : value); }; const bindings = array.filter((i) => i instanceof Binding); if (bindings.length === 0) { return array as Value[]; } if (bindings.length === 1) { return (bindings[0] as Binding).as(getValues); } return Variable.derive(bindings, getValues)(); };