MCPcopy
hub / github.com/Effect-TS/effect / text

Function text

packages/platform-browser/src/internal/httpClient.ts:172–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

170
171 _textEffect: Effect.Effect<string, E> | undefined
172 get text(): Effect.Effect<string, E> {
173 if (this._textEffect) {
174 return this._textEffect
175 }
176 return this._textEffect = Effect.async<string, E>((resume) => {
177 if (this.source.readyState === 4) {
178 resume(Effect.succeed(this.source.responseText))
179 return
180 }
181
182 const onReadyStateChange = () => {
183 if (this.source.readyState === 4) {
184 resume(Effect.succeed(this.source.responseText))
185 }
186 }
187 const onError = () => {
188 resume(Effect.fail(this.onError(this.source.statusText)))
189 }
190 this.source.addEventListener("readystatechange", onReadyStateChange)
191 this.source.addEventListener("error", onError)
192 return Effect.sync(() => {
193 this.source.removeEventListener("readystatechange", onReadyStateChange)
194 this.source.removeEventListener("error", onError)
195 })
196 }).pipe(
197 Effect.cached,
198 Effect.runSync
199 )
200 }
201
202 get json(): Effect.Effect<unknown, E> {
203 return Effect.tryMap(this.text, {

Callers

nothing calls this directly

Calls 5

addEventListenerMethod · 0.80
syncMethod · 0.80
removeEventListenerMethod · 0.80
pipeMethod · 0.65
resumeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…