MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeListDef

Function makeListDef

packages/effect/src/ui/Query.ts:2816–2830  ·  view source on GitHub ↗
(options: {
  readonly items: (page: any) => ReadonlyArray<any>
  readonly key: (item: any) => string
  readonly next: (lastPage: any, allPages: any) => Option.Option<any>
  readonly cursor: Schema.Top
})

Source from the content-addressed store, hash-verified

2814}
2815
2816const makeListDef = (options: {
2817 readonly items: (page: any) => ReadonlyArray<any>
2818 readonly key: (item: any) => string
2819 readonly next: (lastPage: any, allPages: any) => Option.Option<any>
2820 readonly cursor: Schema.Top
2821}): ListDef => {
2822 let encode: ((cursor: unknown) => unknown) | undefined
2823 return {
2824 items: options.items,
2825 key: options.key,
2826 next: options.next,
2827 encodeCursor: (cursor) => (encode ??= Schema.encodeUnknownSync(jsonCodec(options.cursor)))(cursor),
2828 ops: listOps
2829 }
2830}
2831
2832/** @internal */
2833export const defOf = (query: { readonly [TypeId]: unknown }): QueryDef => query[TypeId] as QueryDef

Callers 1

InfiniteServiceFunction · 0.85

Calls 1

jsonCodecFunction · 0.85

Tested by

no test coverage detected