Skip to content

Help with vectors/compile and optional parameters #492

Answered by postspectacular
nonphoto asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @nonphoto - apologies that the code generation parts of that package are not really documented, so far they were really mainly intended for internal use only and therefore also don't have the nicest API. You could use this like so:

import type { MultiVecOp, ReadonlyVec, Vec } from "./api";
import { defHofOp } from "./compile/emit";

function $deltaFrom(start?: number, end?: number, delta?: number) {
    return delta ?? (start ?? 0) - (end ?? 1);
}

type DeltaFrom = (
    out?: Vec,
    start?: ReadonlyVec,
    end?: ReadonlyVec,
    delta?: number
) => Vec;

export const [deltaFrom, deltaFrom2, deltaFrom3, deltaFrom4] = defHofOp<
    MultiVecOp<DeltaFrom>,
    DeltaFrom
>(
    // your …

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by nonphoto
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@nonphoto
Comment options

@postspectacular
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants