All files / json-type/src/value FnValue.ts

83.33% Statements 5/6
100% Branches 0/0
50% Functions 1/2
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1636x       36x   1x 1x 1x              
import {Value} from './Value';
import type {Printable} from 'tree-dump/lib/types';
import type * as classes from '../type';
 
export class FnValue<T extends classes.FnType<any, any, any>> extends Value<T> implements Printable {
  public async exec(input: classes.ResolveType<T['req']>, ctx?: unknown): Promise<Value<T['res']>> {
    const fn = this.data as any;
    const output = await fn(input, ctx);
    return new Value(output, this.type!.res);
  }
 
  public name(): string {
    return 'FnValue';
  }
}