Hyperlinkv0.8.0-beta.28

Trie

Trie.forEachconsteffect/Trie.ts:851
<V>(f: (value: V, key: string) => void): (self: Trie<V>) => void
<V>(self: Trie<V>, f: (value: V, key: string) => void): void

Applies the specified function to the entries of the Trie.

Example (Iterating over entries)

import { Trie } from "effect"
import * as assert from "node:assert"

let value = 0

Trie.empty<number>().pipe(
  Trie.insert("shells", 0),
  Trie.insert("sells", 1),
  Trie.insert("she", 2),
  Trie.forEach((n, key) => {
    value += n + key.length
  })
)

assert.equal(value, 17)
traversing
Source effect/Trie.ts:8514 lines
export const forEach: {
  <V>(f: (value: V, key: string) => void): (self: Trie<V>) => void
  <V>(self: Trie<V>, f: (value: V, key: string) => void): void
} = TR.forEach