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

Function stream

packages/platform/browser/src/IndexedDbQueryBuilder.ts:1769–1793  ·  view source on GitHub ↗
(this: IndexedDbQuery.Select<any, never>, options?: {
    readonly chunkSize?: number | undefined
  })

Source from the content-addressed store, hash-verified

1767 })
1768 },
1769 stream(this: IndexedDbQuery.Select<any, never>, options?: {
1770 readonly chunkSize?: number | undefined
1771 }) {
1772 const limit = this.limitValue
1773 const chunkSize = Math.min(options?.chunkSize ?? 100, limit ?? Number.MAX_SAFE_INTEGER)
1774 const initialOffset = this.offsetValue ?? 0
1775 return Stream.suspend(() => {
1776 let total = 0
1777 const initial = this.limit(chunkSize)
1778 return Stream.paginate(initial, (select) =>
1779 Effect.map(
1780 applySelect(select as any),
1781 (data) => {
1782 total += data.length
1783 const reachedLimit = limit && total >= limit
1784 const isPartial = data.length < chunkSize
1785 const next = makeSelect({
1786 ...select,
1787 offsetValue: initialOffset + total
1788 })
1789 return [data, isPartial || reachedLimit ? Option.none() : Option.some(next)] as const
1790 }
1791 ))
1792 })
1793 },
1794 reactive(
1795 this: IndexedDbQuery.Select<any, never>,
1796 keys?: ReadonlyArray<unknown> | Record.ReadonlyRecord<string, ReadonlyArray<unknown>> | undefined

Callers

nothing calls this directly

Calls 3

makeSelectFunction · 0.85
someMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected