Skip to content

Commit d6a0e0e

Browse files
committed
feat: 🎸 introduce FnValue
1 parent 0b6c77f commit d6a0e0e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/value/FnValue.ts

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

0 commit comments

Comments
 (0)