Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distance function: multiple arguments #244

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
better expressed
brontolosone committed Oct 29, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 6661f8fe4080eb224c9e1ec7a0d427617db883fd
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ export class InvalidArgumentError extends Error {
}
}

export type ParameterArityType = 'optional' | 'required' | 'variadic' | 'variadic+';
export type ParameterArityType = 'optional' | 'required' | 'variadic';

export type ParameterTypeHint =
// | 'lazy' // TODO: it might be good to *explicitly* mark certain parameters
@@ -127,12 +127,6 @@ export class FunctionImplementation<Length extends number> {
max: Infinity,
};

case 'variadic+':
return {
min: acc.min + 1,
max: Infinity,
};

default:
throw new UnreachableError(arityType);
}
2 changes: 1 addition & 1 deletion packages/xpath/src/functions/xforms/geo.ts
Original file line number Diff line number Diff line change
@@ -204,7 +204,7 @@ const sum = (values: readonly number[]) => {

export const distance = new NumberFunction(
'distance',
[{ arityType: 'variadic+' }],
[{ arityType: 'required' }, { arityType: 'variadic' }],
(context, args) => {
const lines = evaluateLines(context, args);

Loading