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

Function text

packages/platform/browser/src/BrowserHttpClient.ts:259–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

257
258 _textEffect: Effect.Effect<string, E> | undefined
259 get text(): Effect.Effect<string, E> {
260 if (this._textEffect) {
261 return this._textEffect
262 }
263 return this._textEffect = Effect.callback<string, E>((resume) => {
264 if (this.source.readyState === 4) {
265 resume(Effect.succeed(this.source.responseText))
266 return
267 }
268
269 const onReadyStateChange = () => {
270 if (this.source.readyState === 4) {
271 resume(Effect.succeed(this.source.responseText))
272 }
273 }
274 const onError = () => {
275 resume(Effect.fail(this.onError(this.source.statusText)))
276 }
277 this.source.addEventListener("readystatechange", onReadyStateChange)
278 this.source.addEventListener("error", onError)
279 return Effect.sync(() => {
280 this.source.removeEventListener("readystatechange", onReadyStateChange)
281 this.source.removeEventListener("error", onError)
282 })
283 }).pipe(
284 Effect.cached,
285 Effect.runSync
286 )
287 }
288
289 get json(): Effect.Effect<Schema.Json, E> {
290 return Effect.flatMap(this.text, (text) =>

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected