
@solana/functional
This package contains generalized functional helpers and functional helpers specific to Solana application components. It can be used standalone, but it is also exported as part of Kit @solana/kit
.
Functions
pipe()
A pipeline is a solution that allows you to perform successive transforms of a value using functions. This is useful when building up a transaction message.
Until the pipeline operator becomes part of JavaScript you can use this utility to create pipelines.
const add = (a, b) => a + b;
const add10 = x => add(x, 10);
const add100 = x => add(x, 100);
const sum = pipe(1, add10, add100);
sum === 111;
const transferTransactionMessage = pipe(
createTransactionMessage({ version: 0 }),
tx => setTransactionMessageFeePayer(myAddress, tx),
tx => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
tx => appendTransactionMessageInstruction(getTransferSolInstruction({ source, destination, amount }), tx),
);