@effect/platform-node
Advanced tools
Comparing version 0.27.7 to 0.27.8
{ | ||
"name": "@effect/platform-node", | ||
"version": "0.27.7", | ||
"version": "0.27.8", | ||
"description": "Unified interfaces for common platform-specific services", | ||
@@ -49,3 +49,3 @@ "main": "dist/effect-platform-node.cjs.js", | ||
"mime": "^3.0.0", | ||
"@effect/platform": "^0.26.5" | ||
"@effect/platform": "^0.26.6" | ||
}, | ||
@@ -52,0 +52,0 @@ "files": [ |
import * as Worker from "@effect/platform/Worker" | ||
import { WorkerError } from "@effect/platform/WorkerError" | ||
import * as Effect from "effect/Effect" | ||
import * as Fiber from "effect/Fiber" | ||
import * as Layer from "effect/Layer" | ||
@@ -26,23 +25,19 @@ import * as Queue from "effect/Queue" | ||
yield* _(Effect.addFinalizer(() => Queue.shutdown(queue))) | ||
const fiber = yield* _( | ||
Effect.async<never, WorkerError, never>((resume) => { | ||
worker.on("message", (message: Worker.BackingWorker.Message<O>) => { | ||
queue.unsafeOffer(message) | ||
}) | ||
worker.on("messageerror", (error) => { | ||
resume(Effect.fail(WorkerError("decode", error))) | ||
}) | ||
worker.on("error", (error) => { | ||
resume(Effect.fail(WorkerError("unknown", error))) | ||
}) | ||
worker.on("exit", (code) => { | ||
resume(Effect.fail(WorkerError("unknown", new Error(`exited with code ${code}`)))) | ||
}) | ||
}), | ||
Effect.forkScoped | ||
) | ||
const join = Fiber.join(fiber) | ||
const run = Effect.async<never, WorkerError, never>((resume) => { | ||
worker.on("message", (message: Worker.BackingWorker.Message<O>) => { | ||
queue.unsafeOffer(message) | ||
}) | ||
worker.on("messageerror", (error) => { | ||
resume(Effect.fail(WorkerError("decode", error))) | ||
}) | ||
worker.on("error", (error) => { | ||
resume(Effect.fail(WorkerError("unknown", error))) | ||
}) | ||
worker.on("exit", (code) => { | ||
resume(Effect.fail(WorkerError("unknown", new Error(`exited with code ${code}`)))) | ||
}) | ||
}) | ||
const send = (message: I, transfers?: ReadonlyArray<unknown>) => | ||
Effect.sync(() => worker.postMessage([0, message], transfers as any)) | ||
return { join, queue, send } | ||
return { run, queue, send } | ||
}) | ||
@@ -49,0 +44,0 @@ } |
@@ -8,3 +8,2 @@ 'use strict'; | ||
var Effect = require('effect/Effect'); | ||
var Fiber = require('effect/Fiber'); | ||
var Layer = require('effect/Layer'); | ||
@@ -33,3 +32,2 @@ var Queue = require('effect/Queue'); | ||
var Effect__namespace = /*#__PURE__*/_interopNamespace(Effect); | ||
var Fiber__namespace = /*#__PURE__*/_interopNamespace(Fiber); | ||
var Layer__namespace = /*#__PURE__*/_interopNamespace(Layer); | ||
@@ -53,3 +51,3 @@ var Queue__namespace = /*#__PURE__*/_interopNamespace(Queue); | ||
yield* _(Effect__namespace.addFinalizer(() => Queue__namespace.shutdown(queue))); | ||
const fiber = yield* _(Effect__namespace.async(resume => { | ||
const run = Effect__namespace.async(resume => { | ||
worker.on("message", message => { | ||
@@ -67,7 +65,6 @@ queue.unsafeOffer(message); | ||
}); | ||
}), Effect__namespace.forkScoped); | ||
const join = Fiber__namespace.join(fiber); | ||
}); | ||
const send = (message, transfers) => Effect__namespace.sync(() => worker.postMessage([0, message], transfers)); | ||
return { | ||
join, | ||
run, | ||
queue, | ||
@@ -74,0 +71,0 @@ send |
@@ -8,3 +8,2 @@ 'use strict'; | ||
var Effect = require('effect/Effect'); | ||
var Fiber = require('effect/Fiber'); | ||
var Layer = require('effect/Layer'); | ||
@@ -33,3 +32,2 @@ var Queue = require('effect/Queue'); | ||
var Effect__namespace = /*#__PURE__*/_interopNamespace(Effect); | ||
var Fiber__namespace = /*#__PURE__*/_interopNamespace(Fiber); | ||
var Layer__namespace = /*#__PURE__*/_interopNamespace(Layer); | ||
@@ -53,3 +51,3 @@ var Queue__namespace = /*#__PURE__*/_interopNamespace(Queue); | ||
yield* _(Effect__namespace.addFinalizer(() => Queue__namespace.shutdown(queue))); | ||
const fiber = yield* _(Effect__namespace.async(resume => { | ||
const run = Effect__namespace.async(resume => { | ||
worker.on("message", message => { | ||
@@ -67,7 +65,6 @@ queue.unsafeOffer(message); | ||
}); | ||
}), Effect__namespace.forkScoped); | ||
const join = Fiber__namespace.join(fiber); | ||
}); | ||
const send = (message, transfers) => Effect__namespace.sync(() => worker.postMessage([0, message], transfers)); | ||
return { | ||
join, | ||
run, | ||
queue, | ||
@@ -74,0 +71,0 @@ send |
@@ -5,3 +5,2 @@ import * as Worker from '@effect/platform/Worker'; | ||
import * as Effect from 'effect/Effect'; | ||
import * as Fiber from 'effect/Fiber'; | ||
import * as Layer from 'effect/Layer'; | ||
@@ -25,3 +24,3 @@ import * as Queue from 'effect/Queue'; | ||
yield* _(Effect.addFinalizer(() => Queue.shutdown(queue))); | ||
const fiber = yield* _(Effect.async(resume => { | ||
const run = Effect.async(resume => { | ||
worker.on("message", message => { | ||
@@ -39,7 +38,6 @@ queue.unsafeOffer(message); | ||
}); | ||
}), Effect.forkScoped); | ||
const join = Fiber.join(fiber); | ||
}); | ||
const send = (message, transfers) => Effect.sync(() => worker.postMessage([0, message], transfers)); | ||
return { | ||
join, | ||
run, | ||
queue, | ||
@@ -46,0 +44,0 @@ send |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
486626
12766
Updated@effect/platform@^0.26.6