andreashuber69/lightning-node-operator

View on GitHub
src/lightning/getArrayData.ts

Summary

Maintainability
A
0 mins
Test Coverage
// https://github.com/andreashuber69/lightning-node-operator/develop/README.md
import type { AuthenticatedLightningArgs, AuthenticatedLightningMethod } from "lightning";

export const getArrayData = async <Return extends Record<Prop, unknown[]>, Prop extends keyof Return>(
    func: AuthenticatedLightningMethod<AuthenticatedLightningArgs, Return>,
    args: AuthenticatedLightningArgs,
    prop: Prop,
) =>
    (await func(args))[prop];