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

Function stackOf

packages/effect/src/ui/kit/Toast.ts:808–833  ·  view source on GitHub ↗
(toasts: ReadonlyArray<Entry>, limit: number)

Source from the content-addressed store, hash-verified

806// of the toasts in front of it, its own height, and whether it's past the
807// limit. A closing toast keeps its place in the list but leaves the count.
808const stackOf = (toasts: ReadonlyArray<Entry>, limit: number) => {
809 const stack = new Map<
810 string,
811 {
812 readonly index: number
813 readonly offset: number
814 readonly height: number
815 readonly limited: boolean
816 }
817 >()
818 let visible = 0
819 let offset = 0
820 toasts.forEach((toast, index) => {
821 const ending = toast.transition === "ending"
822 const limited = !ending && visible >= limit
823 stack.set(toast.id, {
824 index: ending ? index : visible,
825 offset,
826 height: toast.height,
827 limited
828 })
829 offset += toast.height
830 if (!ending) visible += 1
831 })
832 return stack
833}
834
835// `$` in any handler of the provider's `update`: a tag's `$` fits the one
836// over the whole message type.

Callers 7

Dialog.tsFile · 0.90
trackDismissalFunction · 0.90
Toast.tsFile · 0.70
hideOthersFunction · 0.50
blockedFunction · 0.50
lockScrollFunction · 0.50
joinEscapeFunction · 0.50

Calls 2

forEachMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected