@effect/io
Advanced tools
Comparing version 0.37.1 to 0.38.0
@@ -8,3 +8,2 @@ "use strict"; | ||
var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/cause")); | ||
var _pretty = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/cause-pretty")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -520,3 +519,3 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
exports.isRuntimeException = isRuntimeException; | ||
const pretty = _pretty.pretty; | ||
const pretty = internal.pretty; | ||
/** | ||
@@ -523,0 +522,0 @@ * Removes any annotation from the cause |
@@ -67,6 +67,2 @@ /** | ||
} : never) | Config<A>; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
type Narrow<A> = (A extends [] ? [] : never) | A; | ||
} | ||
@@ -79,3 +75,3 @@ /** | ||
*/ | ||
export declare const all: <Arg extends Iterable<Config<any>> | Record<string, Config<any>>>(arg: Config.Narrow<Arg>) => Config<[ | ||
export declare const all: <const Arg extends Iterable<Config<any>> | Record<string, Config<any>>>(arg: Arg) => Config<[ | ||
Arg | ||
@@ -82,0 +78,0 @@ ] extends [ReadonlyArray<Config<any>>] ? { |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.unannotate = exports.stripSomeDefects = exports.stripFailures = exports.squashWith = exports.squash = exports.size = exports.sequential = exports.reduceWithContext = exports.reduce = exports.parallel = exports.match = exports.map = exports.makeSpanAnnotation = exports.linearize = exports.keepDefectsAndElectFailures = exports.keepDefects = exports.isSpanAnnotation = exports.isSequentialType = exports.isRuntimeException = exports.isParallelType = exports.isNoSuchElementException = exports.isInvalidCapacityError = exports.isInterruptedOnly = exports.isInterruptedException = exports.isInterrupted = exports.isInterruptType = exports.isIllegalArgumentException = exports.isFailure = exports.isFailType = exports.isEmptyType = exports.isEmpty = exports.isDieType = exports.isDie = exports.isCause = exports.isAnnotatedType = exports.interruptors = exports.interruptOption = exports.interrupt = exports.globalErrorSeq = exports.flipCauseOption = exports.flatten = exports.flatMap = exports.find = exports.filter = exports.failures = exports.failureOrCause = exports.failureOption = exports.fail = exports.empty = exports.electFailures = exports.dieOption = exports.die = exports.defects = exports.contains = exports.as = exports.annotated = exports.SpanAnnotationTypeId = exports.RuntimeExceptionTypeId = exports.RuntimeException = exports.NoSuchElementExceptionTypeId = exports.NoSuchElementException = exports.InvalidHubCapacityExceptionTypeId = exports.InvalidHubCapacityException = exports.InterruptedExceptionTypeId = exports.InterruptedException = exports.IllegalArgumentExceptionTypeId = exports.IllegalArgumentException = exports.CauseTypeId = void 0; | ||
exports.unannotate = exports.stripSomeDefects = exports.stripFailures = exports.squashWith = exports.squash = exports.size = exports.sequential = exports.reduceWithContext = exports.reduce = exports.prettyErrors = exports.pretty = exports.parallel = exports.match = exports.map = exports.makeSpanAnnotation = exports.linearize = exports.keepDefectsAndElectFailures = exports.keepDefects = exports.isSpanAnnotation = exports.isSequentialType = exports.isRuntimeException = exports.isParallelType = exports.isNoSuchElementException = exports.isInvalidCapacityError = exports.isInterruptedOnly = exports.isInterruptedException = exports.isInterrupted = exports.isInterruptType = exports.isIllegalArgumentException = exports.isFailure = exports.isFailType = exports.isEmptyType = exports.isEmpty = exports.isDieType = exports.isDie = exports.isCause = exports.isAnnotatedType = exports.interruptors = exports.interruptOption = exports.interrupt = exports.globalErrorSeq = exports.flipCauseOption = exports.flatten = exports.flatMap = exports.find = exports.filter = exports.failures = exports.failureOrCause = exports.failureOption = exports.fail = exports.empty = exports.electFailures = exports.dieOption = exports.die = exports.defects = exports.contains = exports.as = exports.annotated = exports.SpanAnnotationTypeId = exports.RuntimeExceptionTypeId = exports.RuntimeException = exports.NoSuchElementExceptionTypeId = exports.NoSuchElementException = exports.InvalidHubCapacityExceptionTypeId = exports.InvalidHubCapacityException = exports.InterruptedExceptionTypeId = exports.InterruptedException = exports.IllegalArgumentExceptionTypeId = exports.IllegalArgumentException = exports.CauseTypeId = void 0; | ||
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk")); | ||
@@ -45,2 +45,14 @@ var Either = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Either")); | ||
return (0, _Pipeable.pipeArguments)(this, arguments); | ||
}, | ||
toJSON() { | ||
return { | ||
_tag: "Cause", | ||
errors: prettyErrors(this) | ||
}; | ||
}, | ||
toString() { | ||
return pretty(this); | ||
}, | ||
[Symbol.for("nodejs.util.inspect.custom")]() { | ||
return this.toJSON(); | ||
} | ||
@@ -979,3 +991,109 @@ }; | ||
const unannotate = self => reduceWithContext(self, void 0, UnAnnotateCauseReducer()); | ||
// ----------------------------------------------------------------------------- | ||
// Pretty Printing | ||
// ----------------------------------------------------------------------------- | ||
/** @internal */ | ||
exports.unannotate = unannotate; | ||
const renderToString = u => { | ||
if (typeof u === "object" && u != null && "toString" in u && typeof u["toString"] === "function" && u["toString"] !== Object.prototype.toString) { | ||
return u["toString"](); | ||
} | ||
if (typeof u === "string") { | ||
return `Error: ${u}`; | ||
} | ||
if (typeof u === "object" && u !== null) { | ||
if ("message" in u && typeof u["message"] === "string") { | ||
const raw = JSON.parse(JSON.stringify(u)); | ||
const keys = new Set(Object.keys(raw)); | ||
keys.delete("name"); | ||
keys.delete("message"); | ||
keys.delete("_tag"); | ||
if (keys.size === 0) { | ||
return `${"name" in u && typeof u.name === "string" ? u.name : "Error"}${"_tag" in u && typeof u["_tag"] === "string" ? `(${u._tag})` : ``}: ${u.message}`; | ||
} | ||
} | ||
} | ||
return `Error: ${JSON.stringify(u)}`; | ||
}; | ||
/** @internal */ | ||
const defaultErrorToLines = error => { | ||
if (error instanceof Error) { | ||
return [renderToString(error), error.stack?.split("\n").filter(_ => !_.startsWith("Error")).join("\n")]; | ||
} | ||
return [renderToString(error), void 0]; | ||
}; | ||
class RenderError { | ||
constructor(message, stack, span) { | ||
this.message = message; | ||
this.stack = stack; | ||
this.span = span; | ||
} | ||
} | ||
const filterStack = stack => { | ||
const lines = stack.split("\n"); | ||
const out = []; | ||
for (let i = 0; i < lines.length; i++) { | ||
if (lines[i].includes("EffectPrimitive") || lines[i].includes("Generator.next") || lines[i].includes("FiberRuntime")) { | ||
return out.join("\n"); | ||
} else { | ||
out.push(lines[i]); | ||
} | ||
} | ||
return out.join("\n"); | ||
}; | ||
/** @internal */ | ||
const pretty = cause => { | ||
if (isInterruptedOnly(cause)) { | ||
return "All fibers interrupted without errors."; | ||
} | ||
const final = prettyErrors(cause).map(e => { | ||
let message = e.message; | ||
if (e.stack) { | ||
message += `\r\n${filterStack(e.stack)}`; | ||
} | ||
if (e.span) { | ||
let current = e.span; | ||
let i = 0; | ||
while (current && current._tag === "Span" && i < 10) { | ||
message += `\r\n at ${current.name}`; | ||
current = Option.getOrUndefined(current.parent); | ||
i++; | ||
} | ||
} | ||
return message; | ||
}).join("\r\n\r\n"); | ||
if (!final.includes("\r\n")) { | ||
return final; | ||
} | ||
return `\r\n${final}\r\n`; | ||
}; | ||
/** @internal */ | ||
exports.pretty = pretty; | ||
const prettyErrors = cause => reduceWithContext(cause, void 0, { | ||
emptyCase: () => [], | ||
dieCase: (_, err) => { | ||
const rendered = defaultErrorToLines(err); | ||
return [{ | ||
message: rendered[0], | ||
stack: rendered[1], | ||
span: undefined | ||
}]; | ||
}, | ||
failCase: (_, err) => { | ||
const rendered = defaultErrorToLines(err); | ||
return [{ | ||
message: rendered[0], | ||
stack: rendered[1], | ||
span: undefined | ||
}]; | ||
}, | ||
interruptCase: () => [], | ||
parallelCase: (_, l, r) => [...l, ...r], | ||
sequentialCase: (_, l, r) => [...l, ...r], | ||
annotatedCase: (_, v, annotation) => isSpanAnnotation(annotation) ? v.map(error => ({ | ||
...error, | ||
span: error.span ?? annotation.span | ||
})) : v | ||
}); | ||
exports.prettyErrors = prettyErrors; | ||
//# sourceMappingURL=cause.js.map |
import type * as Config from "@effect/io/Config"; | ||
export declare const all: <Arg extends Iterable<Config.Config<any>> | Record<string, Config.Config<any>>>(arg: Config.Config.Narrow<Arg>) => Config.Config<[Arg] extends [readonly Config.Config<any>[]] ? { -readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never; } : [Arg] extends [Iterable<Config.Config<infer A_1>>] ? A_1[] : [Arg] extends [Record<string, Config.Config<any>>] ? { -readonly [K_1 in keyof Arg]: [Arg[K_1]] extends [Config.Config<infer A_2>] ? A_2 : never; } : never>; | ||
export declare const all: <const Arg extends Iterable<Config.Config<any>> | Record<string, Config.Config<any>>>(arg: Arg) => Config.Config<[Arg] extends [readonly Config.Config<any>[]] ? { -readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never; } : [Arg] extends [Iterable<Config.Config<infer A_1>>] ? A_1[] : [Arg] extends [Record<string, Config.Config<any>>] ? { -readonly [K_1 in keyof Arg]: [Arg[K_1]] extends [Config.Config<infer A_2>] ? A_2 : never; } : never>; | ||
//# sourceMappingURL=config.d.ts.map |
@@ -24,2 +24,3 @@ "use strict"; | ||
var fiberRuntime = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/fiberRuntime")); | ||
var _fiberScope = /*#__PURE__*/require("@effect/io/internal/fiberScope"); | ||
var internalRef = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/ref")); | ||
@@ -182,3 +183,3 @@ var _schedule = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/schedule")); | ||
const timeout = /*#__PURE__*/(0, _Function.dual)(2, (self, duration) => timeoutTo(self, { | ||
onTimeout: Option.none(), | ||
onTimeout: Option.none, | ||
onSuccess: Option.some, | ||
@@ -193,3 +194,3 @@ duration | ||
}) => core.flatten(timeoutTo(self, { | ||
onTimeout: core.failSync(onTimeout), | ||
onTimeout: () => core.failSync(onTimeout), | ||
onSuccess: core.succeed, | ||
@@ -204,3 +205,3 @@ duration | ||
}) => core.flatten(timeoutTo(self, { | ||
onTimeout: core.failCauseSync(onTimeout), | ||
onTimeout: () => core.failCauseSync(onTimeout), | ||
onSuccess: core.succeed, | ||
@@ -215,3 +216,19 @@ duration | ||
onTimeout | ||
}) => raceFirst(core.map(self, onSuccess), core.interruptible(core.as(onTimeout)(effect.sleep(duration))))); | ||
}) => core.fiberIdWith(parentFiberId => fiberRuntime.raceFibersWith(self, core.interruptible(effect.sleep(duration)), { | ||
onSelfWin: (winner, loser) => core.flatMap(winner.await(), exit => { | ||
if (exit._tag === "Success") { | ||
return core.flatMap(winner.inheritAll(), () => core.as(core.interruptAsFiber(loser, parentFiberId), onSuccess(exit.value))); | ||
} else { | ||
return core.flatMap(core.interruptAsFiber(loser, parentFiberId), () => core.exitFailCause(exit.cause)); | ||
} | ||
}), | ||
onOtherWin: (winner, loser) => core.flatMap(winner.await(), exit => { | ||
if (exit._tag === "Success") { | ||
return core.flatMap(winner.inheritAll(), () => core.as(core.interruptAsFiber(loser, parentFiberId), onTimeout())); | ||
} else { | ||
return core.flatMap(core.interruptAsFiber(loser, parentFiberId), () => core.exitFailCause(exit.cause)); | ||
} | ||
}), | ||
otherScope: _fiberScope.globalScope | ||
}))); | ||
// circular with Synchronized | ||
@@ -218,0 +235,0 @@ /** @internal */ |
@@ -13,3 +13,2 @@ "use strict"; | ||
var Cause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/cause")); | ||
var Pretty = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/cause-pretty")); | ||
var _fiberId = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/fiberId")); | ||
@@ -109,3 +108,3 @@ var LogSpan = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Logger/Span")); | ||
output = output + " cause="; | ||
output = appendQuoted(Pretty.pretty(cause), output); | ||
output = appendQuoted(Cause.pretty(cause), output); | ||
} | ||
@@ -173,3 +172,3 @@ if (List.isCons(spans)) { | ||
output = output + " cause="; | ||
output = appendQuotedLogfmt(Pretty.pretty(cause), output); | ||
output = appendQuotedLogfmt(Cause.pretty(cause), output); | ||
} | ||
@@ -176,0 +175,0 @@ if (List.isCons(spans)) { |
@@ -14,4 +14,3 @@ "use strict"; | ||
var FiberRefs = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/FiberRefs")); | ||
var _cause = /*#__PURE__*/require("@effect/io/internal/cause"); | ||
var CausePretty = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/cause-pretty")); | ||
var CausePretty = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/cause")); | ||
var core = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/core")); | ||
@@ -170,3 +169,3 @@ var FiberRuntime = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/fiberRuntime")); | ||
// @ts-expect-error | ||
return core.exitFail((0, _cause.NoSuchElementException)()); | ||
return core.exitFail((0, CausePretty.NoSuchElementException)()); | ||
} | ||
@@ -173,0 +172,0 @@ } |
{ | ||
"name": "@effect/io", | ||
"version": "0.37.1", | ||
"version": "0.38.0", | ||
"description": "Functional programming in TypeScript", | ||
"license": "MIT", | ||
@@ -9,9 +10,5 @@ "repository": { | ||
}, | ||
"dependencies": { | ||
"@effect/data": "^0.17.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"sideEffects": [], | ||
"exports": { | ||
@@ -28,3 +25,8 @@ "./*": { | ||
} | ||
}, | ||
"sideEffects": [], | ||
"author": "Michael Arnaldi <michael.arnaldi@effectful.co>", | ||
"peerDependencies": { | ||
"@effect/data": "^0.17.1" | ||
} | ||
} |
@@ -33,3 +33,2 @@ /** | ||
import * as internal from "@effect/io/internal/cause" | ||
import * as _pretty from "@effect/io/internal/cause-pretty" | ||
import type { Span } from "@effect/io/Tracer" | ||
@@ -870,3 +869,3 @@ | ||
*/ | ||
export const pretty: <E>(cause: Cause<E>) => string = _pretty.pretty | ||
export const pretty: <E>(cause: Cause<E>) => string = internal.pretty | ||
@@ -873,0 +872,0 @@ /** |
@@ -72,11 +72,6 @@ /** | ||
| (A extends Record<string, any> ? { | ||
[K in keyof A]: Wrap<A[K]> | ||
} | ||
[K in keyof A]: Wrap<A[K]> | ||
} | ||
: never) | ||
| Config<A> | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export type Narrow<A> = (A extends [] ? [] : never) | A | ||
} | ||
@@ -90,12 +85,12 @@ | ||
*/ | ||
export const all: <Arg extends Iterable<Config<any>> | Record<string, Config<any>>>( | ||
arg: Config.Narrow<Arg> | ||
export const all: <const Arg extends Iterable<Config<any>> | Record<string, Config<any>>>( | ||
arg: Arg | ||
) => Config< | ||
[Arg] extends [ReadonlyArray<Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never | ||
} | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never | ||
} | ||
: [Arg] extends [Iterable<Config<infer A>>] ? Array<A> | ||
: [Arg] extends [Record<string, Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never | ||
} | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never | ||
} | ||
: never | ||
@@ -102,0 +97,0 @@ > = internal.all |
@@ -16,3 +16,3 @@ import * as Chunk from "@effect/data/Chunk" | ||
import { pipeArguments } from "@effect/data/Pipeable" | ||
import type { Span } from "@effect/io/Tracer" | ||
import type { ParentSpan, Span } from "@effect/io/Tracer" | ||
@@ -50,2 +50,14 @@ // ----------------------------------------------------------------------------- | ||
return pipeArguments(this, arguments) | ||
}, | ||
toJSON() { | ||
return { | ||
_tag: "Cause", | ||
errors: prettyErrors(this as any as Cause.Cause<any>) | ||
} | ||
}, | ||
toString() { | ||
return pretty(this as any as Cause.Cause<any>) | ||
}, | ||
[Symbol.for("nodejs.util.inspect.custom")]() { | ||
return this.toJSON() | ||
} | ||
@@ -1161,1 +1173,117 @@ } | ||
export const unannotate = <E>(self: Cause.Cause<E>) => reduceWithContext(self, void 0, UnAnnotateCauseReducer<E>()) | ||
// ----------------------------------------------------------------------------- | ||
// Pretty Printing | ||
// ----------------------------------------------------------------------------- | ||
/** @internal */ | ||
const renderToString = (u: unknown): string => { | ||
if ( | ||
typeof u === "object" && | ||
u != null && | ||
"toString" in u && | ||
typeof u["toString"] === "function" && | ||
u["toString"] !== Object.prototype.toString | ||
) { | ||
return u["toString"]() | ||
} | ||
if (typeof u === "string") { | ||
return `Error: ${u}` | ||
} | ||
if (typeof u === "object" && u !== null) { | ||
if ("message" in u && typeof u["message"] === "string") { | ||
const raw = JSON.parse(JSON.stringify(u)) | ||
const keys = new Set(Object.keys(raw)) | ||
keys.delete("name") | ||
keys.delete("message") | ||
keys.delete("_tag") | ||
if (keys.size === 0) { | ||
return `${"name" in u && typeof u.name === "string" ? u.name : "Error"}${ | ||
"_tag" in u && typeof u["_tag"] === "string" ? `(${u._tag})` : `` | ||
}: ${u.message}` | ||
} | ||
} | ||
} | ||
return `Error: ${JSON.stringify(u)}` | ||
} | ||
/** @internal */ | ||
const defaultErrorToLines = (error: unknown): [string, string | undefined] => { | ||
if (error instanceof Error) { | ||
return [renderToString(error), error.stack?.split("\n").filter((_) => !_.startsWith("Error")).join("\n")] | ||
} | ||
return [renderToString(error), void 0] | ||
} | ||
class RenderError { | ||
constructor( | ||
readonly message: string, | ||
readonly stack: string | undefined, | ||
readonly span: Span | undefined | ||
) {} | ||
} | ||
const filterStack = (stack: string) => { | ||
const lines = stack.split("\n") | ||
const out: Array<string> = [] | ||
for (let i = 0; i < lines.length; i++) { | ||
if ( | ||
lines[i].includes("EffectPrimitive") | ||
|| lines[i].includes("Generator.next") | ||
|| lines[i].includes("FiberRuntime") | ||
) { | ||
return out.join("\n") | ||
} else { | ||
out.push(lines[i]) | ||
} | ||
} | ||
return out.join("\n") | ||
} | ||
/** @internal */ | ||
export const pretty = <E>(cause: Cause.Cause<E>): string => { | ||
if (isInterruptedOnly(cause)) { | ||
return "All fibers interrupted without errors." | ||
} | ||
const final = prettyErrors<E>(cause).map((e) => { | ||
let message = e.message | ||
if (e.stack) { | ||
message += `\r\n${filterStack(e.stack)}` | ||
} | ||
if (e.span) { | ||
let current: Span | ParentSpan | undefined = e.span | ||
let i = 0 | ||
while (current && current._tag === "Span" && i < 10) { | ||
message += `\r\n at ${current.name}` | ||
current = Option.getOrUndefined(current.parent) | ||
i++ | ||
} | ||
} | ||
return message | ||
}).join("\r\n\r\n") | ||
if (!final.includes("\r\n")) { | ||
return final | ||
} | ||
return `\r\n${final}\r\n` | ||
} | ||
/** @internal */ | ||
export const prettyErrors = <E>(cause: Cause.Cause<E>) => | ||
reduceWithContext(cause, void 0, { | ||
emptyCase: (): ReadonlyArray<RenderError> => [], | ||
dieCase: (_, err) => { | ||
const rendered = defaultErrorToLines(err) | ||
return [{ message: rendered[0], stack: rendered[1], span: undefined }] | ||
}, | ||
failCase: (_, err) => { | ||
const rendered = defaultErrorToLines(err) | ||
return [{ message: rendered[0], stack: rendered[1], span: undefined }] | ||
}, | ||
interruptCase: () => [], | ||
parallelCase: (_, l, r) => [...l, ...r], | ||
sequentialCase: (_, l, r) => [...l, ...r], | ||
annotatedCase: (_, v, annotation) => | ||
isSpanAnnotation(annotation) ? | ||
v.map((error) => ({ ...error, span: error.span ?? annotation.span })) : | ||
v | ||
}) |
@@ -415,12 +415,12 @@ import * as Chunk from "@effect/data/Chunk" | ||
export const all = <Arg extends Iterable<Config.Config<any>> | Record<string, Config.Config<any>>>( | ||
arg: Config.Config.Narrow<Arg> | ||
export const all = <const Arg extends Iterable<Config.Config<any>> | Record<string, Config.Config<any>>>( | ||
arg: Arg | ||
): Config.Config< | ||
[Arg] extends [ReadonlyArray<Config.Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never | ||
} | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never | ||
} | ||
: [Arg] extends [Iterable<Config.Config<infer A>>] ? Array<A> | ||
: [Arg] extends [Record<string, Config.Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never | ||
} | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never | ||
} | ||
: never | ||
@@ -427,0 +427,0 @@ > => { |
@@ -428,4 +428,4 @@ import * as Context from "@effect/data/Context" | ||
const fromFlatLoopFail = (prefix: ReadonlyArray<string>, path: string) => | ||
(index: number): Either.Either<ConfigError.ConfigError, unknown> => | ||
const fromFlatLoopFail = | ||
(prefix: ReadonlyArray<string>, path: string) => (index: number): Either.Either<ConfigError.ConfigError, unknown> => | ||
Either.left( | ||
@@ -432,0 +432,0 @@ configError.MissingData( |
@@ -25,2 +25,3 @@ import * as Duration from "@effect/data/Duration" | ||
import * as fiberRuntime from "@effect/io/internal/fiberRuntime" | ||
import { globalScope } from "@effect/io/internal/fiberScope" | ||
import * as internalRef from "@effect/io/internal/ref" | ||
@@ -80,10 +81,9 @@ import * as _schedule from "@effect/io/internal/schedule" | ||
readonly withPermits = (n: number) => | ||
<R, E, A>(self: Effect.Effect<R, E, A>) => | ||
core.uninterruptibleMask((restore) => | ||
core.flatMap( | ||
restore(this.take(n)), | ||
(permits) => fiberRuntime.ensuring(restore(self), this.release(permits)) | ||
) | ||
readonly withPermits = (n: number) => <R, E, A>(self: Effect.Effect<R, E, A>) => | ||
core.uninterruptibleMask((restore) => | ||
core.flatMap( | ||
restore(this.take(n)), | ||
(permits) => fiberRuntime.ensuring(restore(self), this.release(permits)) | ||
) | ||
) | ||
} | ||
@@ -322,25 +322,24 @@ | ||
core.flatMap(makeSynchronized), | ||
core.map((ref) => | ||
(a: A) => | ||
pipe( | ||
ref.modifyEffect((map) => { | ||
const result = pipe(map, MutableHashMap.get(new Key(a, eq))) | ||
if (Option.isNone(result)) { | ||
return pipe( | ||
core.deferredMake<E, readonly [FiberRefsPatch.FiberRefsPatch, B]>(), | ||
core.tap((deferred) => | ||
pipe( | ||
effect.diffFiberRefs(f(a)), | ||
core.intoDeferred(deferred), | ||
fiberRuntime.fork | ||
) | ||
), | ||
core.map((deferred) => [deferred, pipe(map, MutableHashMap.set(new Key(a, eq), deferred))] as const) | ||
) | ||
} | ||
return core.succeed([result.value, map] as const) | ||
}), | ||
core.flatMap(core.deferredAwait), | ||
core.flatMap(([patch, b]) => pipe(effect.patchFiberRefs(patch), core.as(b))) | ||
) | ||
core.map((ref) => (a: A) => | ||
pipe( | ||
ref.modifyEffect((map) => { | ||
const result = pipe(map, MutableHashMap.get(new Key(a, eq))) | ||
if (Option.isNone(result)) { | ||
return pipe( | ||
core.deferredMake<E, readonly [FiberRefsPatch.FiberRefsPatch, B]>(), | ||
core.tap((deferred) => | ||
pipe( | ||
effect.diffFiberRefs(f(a)), | ||
core.intoDeferred(deferred), | ||
fiberRuntime.fork | ||
) | ||
), | ||
core.map((deferred) => [deferred, pipe(map, MutableHashMap.set(new Key(a, eq), deferred))] as const) | ||
) | ||
} | ||
return core.succeed([result.value, map] as const) | ||
}), | ||
core.flatMap(core.deferredAwait), | ||
core.flatMap(([patch, b]) => pipe(effect.patchFiberRefs(patch), core.as(b))) | ||
) | ||
) | ||
@@ -401,3 +400,3 @@ ) | ||
timeoutTo(self, { | ||
onTimeout: Option.none(), | ||
onTimeout: Option.none, | ||
onSuccess: Option.some, | ||
@@ -424,3 +423,3 @@ duration | ||
core.flatten(timeoutTo(self, { | ||
onTimeout: core.failSync(onTimeout), | ||
onTimeout: () => core.failSync(onTimeout), | ||
onSuccess: core.succeed, | ||
@@ -447,3 +446,3 @@ duration | ||
core.flatten(timeoutTo(self, { | ||
onTimeout: core.failCauseSync(onTimeout), | ||
onTimeout: () => core.failCauseSync(onTimeout), | ||
onSuccess: core.succeed, | ||
@@ -457,3 +456,3 @@ duration | ||
options: { | ||
readonly onTimeout: B1 | ||
readonly onTimeout: LazyArg<B1> | ||
readonly onSuccess: (a: A) => B | ||
@@ -466,3 +465,3 @@ readonly duration: Duration.DurationInput | ||
options: { | ||
readonly onTimeout: B1 | ||
readonly onTimeout: LazyArg<B1> | ||
readonly onSuccess: (a: A) => B | ||
@@ -473,8 +472,51 @@ readonly duration: Duration.DurationInput | ||
>(2, (self, { duration, onSuccess, onTimeout }) => | ||
raceFirst( | ||
core.map(self, onSuccess), | ||
pipe( | ||
effect.sleep(duration), | ||
core.as(onTimeout), | ||
core.interruptible | ||
core.fiberIdWith((parentFiberId) => | ||
fiberRuntime.raceFibersWith( | ||
self, | ||
core.interruptible(effect.sleep(duration)), | ||
{ | ||
onSelfWin: (winner, loser) => | ||
core.flatMap( | ||
winner.await(), | ||
(exit) => { | ||
if (exit._tag === "Success") { | ||
return core.flatMap( | ||
winner.inheritAll(), | ||
() => | ||
core.as( | ||
core.interruptAsFiber(loser, parentFiberId), | ||
onSuccess(exit.value) | ||
) | ||
) | ||
} else { | ||
return core.flatMap( | ||
core.interruptAsFiber(loser, parentFiberId), | ||
() => core.exitFailCause(exit.cause) | ||
) | ||
} | ||
} | ||
), | ||
onOtherWin: (winner, loser) => | ||
core.flatMap( | ||
winner.await(), | ||
(exit) => { | ||
if (exit._tag === "Success") { | ||
return core.flatMap( | ||
winner.inheritAll(), | ||
() => | ||
core.as( | ||
core.interruptAsFiber(loser, parentFiberId), | ||
onTimeout() | ||
) | ||
) | ||
} else { | ||
return core.flatMap( | ||
core.interruptAsFiber(loser, parentFiberId), | ||
() => core.exitFailCause(exit.cause) | ||
) | ||
} | ||
} | ||
), | ||
otherScope: globalScope | ||
} | ||
) | ||
@@ -481,0 +523,0 @@ )) |
@@ -216,3 +216,3 @@ import * as Either from "@effect/data/Either" | ||
/** @internal */ | ||
export const never: Fiber.Fiber<never, never> = ({ | ||
export const never: Fiber.Fiber<never, never> = { | ||
...fiberProto, | ||
@@ -225,3 +225,3 @@ id: () => FiberId.none, | ||
interruptAsFork: () => core.never | ||
}) | ||
} | ||
@@ -228,0 +228,0 @@ /** @internal */ |
@@ -48,9 +48,9 @@ import * as Chunk from "@effect/data/Chunk" | ||
) => | ||
(subscribers: Subscribers<A>) => { | ||
if (!subscribers.has(subscription)) { | ||
subscribers.set(subscription, new Set()) | ||
} | ||
const set = subscribers.get(subscription)! | ||
set.add(pollers) | ||
(subscribers: Subscribers<A>) => { | ||
if (!subscribers.has(subscription)) { | ||
subscribers.set(subscription, new Set()) | ||
} | ||
const set = subscribers.get(subscription)! | ||
set.add(pollers) | ||
} | ||
@@ -61,12 +61,12 @@ const removeSubscribers = <A>( | ||
) => | ||
(subscribers: Subscribers<A>) => { | ||
if (!subscribers.has(subscription)) { | ||
return | ||
} | ||
const set = subscribers.get(subscription)! | ||
set.delete(pollers) | ||
if (set.size === 0) { | ||
subscribers.delete(subscription) | ||
} | ||
(subscribers: Subscribers<A>) => { | ||
if (!subscribers.has(subscription)) { | ||
return | ||
} | ||
const set = subscribers.get(subscription)! | ||
set.delete(pollers) | ||
if (set.size === 0) { | ||
subscribers.delete(subscription) | ||
} | ||
} | ||
@@ -73,0 +73,0 @@ /** @internal */ |
@@ -335,19 +335,17 @@ import * as Context from "@effect/data/Context" | ||
case "ExtendScope": { | ||
return core.sync(() => | ||
(memoMap: MemoMap) => | ||
fiberRuntime.scopeWith( | ||
(scope) => memoMap.getOrElseMemoize(op.layer, scope) | ||
) as unknown as Effect.Effect<RIn, E, Context.Context<ROut>> | ||
return core.sync(() => (memoMap: MemoMap) => | ||
fiberRuntime.scopeWith( | ||
(scope) => memoMap.getOrElseMemoize(op.layer, scope) | ||
) as unknown as Effect.Effect<RIn, E, Context.Context<ROut>> | ||
) | ||
} | ||
case "Fold": { | ||
return core.sync(() => | ||
(memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.layer, scope), | ||
core.matchCauseEffect({ | ||
onFailure: (cause) => memoMap.getOrElseMemoize(op.failureK(cause), scope), | ||
onSuccess: (value) => memoMap.getOrElseMemoize(op.successK(value), scope) | ||
}) | ||
) | ||
return core.sync(() => (memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.layer, scope), | ||
core.matchCauseEffect({ | ||
onFailure: (cause) => memoMap.getOrElseMemoize(op.failureK(cause), scope), | ||
onSuccess: (value) => memoMap.getOrElseMemoize(op.successK(value), scope) | ||
}) | ||
) | ||
) | ||
@@ -362,56 +360,51 @@ } | ||
case "ProvideTo": { | ||
return core.sync(() => | ||
(memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.first, scope), | ||
core.flatMap((env) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.second, scope), | ||
core.provideContext(env) | ||
) | ||
return core.sync(() => (memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.first, scope), | ||
core.flatMap((env) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.second, scope), | ||
core.provideContext(env) | ||
) | ||
) | ||
) | ||
) | ||
} | ||
case "Scoped": { | ||
return core.sync(() => | ||
(_: MemoMap) => | ||
fiberRuntime.scopeExtend( | ||
op.effect as Effect.Effect<RIn, E, Context.Context<ROut>>, | ||
scope | ||
) | ||
return core.sync(() => (_: MemoMap) => | ||
fiberRuntime.scopeExtend( | ||
op.effect as Effect.Effect<RIn, E, Context.Context<ROut>>, | ||
scope | ||
) | ||
) | ||
} | ||
case "Suspend": { | ||
return core.sync(() => | ||
(memoMap: MemoMap) => | ||
memoMap.getOrElseMemoize( | ||
op.evaluate(), | ||
scope | ||
) | ||
return core.sync(() => (memoMap: MemoMap) => | ||
memoMap.getOrElseMemoize( | ||
op.evaluate(), | ||
scope | ||
) | ||
) | ||
} | ||
case "ZipWith": { | ||
return core.sync(() => | ||
(memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.first, scope), | ||
core.zipWith( | ||
memoMap.getOrElseMemoize(op.second, scope), | ||
op.zipK | ||
) | ||
return core.sync(() => (memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.first, scope), | ||
core.zipWith( | ||
memoMap.getOrElseMemoize(op.second, scope), | ||
op.zipK | ||
) | ||
) | ||
) | ||
} | ||
case "ZipWithPar": { | ||
return core.sync(() => | ||
(memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.first, scope), | ||
fiberRuntime.zipWithOptions( | ||
memoMap.getOrElseMemoize(op.second, scope), | ||
op.zipK, | ||
{ concurrent: true } | ||
) | ||
return core.sync(() => (memoMap: MemoMap) => | ||
pipe( | ||
memoMap.getOrElseMemoize(op.first, scope), | ||
fiberRuntime.zipWithOptions( | ||
memoMap.getOrElseMemoize(op.second, scope), | ||
op.zipK, | ||
{ concurrent: true } | ||
) | ||
) | ||
) | ||
@@ -533,3 +526,3 @@ } | ||
const tag = (tagFirst ? a : b) as Context.Tag<unknown, unknown> | ||
const effect = (tagFirst ? b : a) | ||
const effect = tagFirst ? b : a | ||
return fromEffectContext(core.map(effect, (service) => Context.make(tag, service))) | ||
@@ -886,3 +879,3 @@ }) | ||
const tag = (tagFirst ? a : b) as Context.Tag<unknown, unknown> | ||
const effect = (tagFirst ? b : a) | ||
const effect = tagFirst ? b : a | ||
return scopedContext(core.map(effect, (service) => Context.make(tag, service))) | ||
@@ -940,3 +933,3 @@ }) | ||
const tag = (tagFirst ? a : b) as Context.Tag<unknown, unknown> | ||
const resource = (tagFirst ? b : a) | ||
const resource = tagFirst ? b : a | ||
return fromEffectContext(core.succeed(Context.make(tag, resource))) | ||
@@ -976,3 +969,3 @@ }) | ||
const tag = (tagFirst ? a : b) as Context.Tag<unknown, unknown> | ||
const evaluate = (tagFirst ? b : a) | ||
const evaluate = tagFirst ? b : a | ||
return fromEffectContext(core.sync(() => Context.make(tag, evaluate()))) | ||
@@ -979,0 +972,0 @@ }) |
@@ -11,3 +11,2 @@ import type { LazyArg } from "@effect/data/Function" | ||
import * as Cause from "@effect/io/internal/cause" | ||
import * as Pretty from "@effect/io/internal/cause-pretty" | ||
import * as _fiberId from "@effect/io/internal/fiberId" | ||
@@ -183,3 +182,3 @@ import type * as Logger from "@effect/io/Logger" | ||
output = output + " cause=" | ||
output = appendQuoted(Pretty.pretty(cause), output) | ||
output = appendQuoted(Cause.pretty(cause), output) | ||
} | ||
@@ -259,3 +258,3 @@ | ||
output = output + " cause=" | ||
output = appendQuotedLogfmt(Pretty.pretty(cause), output) | ||
output = appendQuotedLogfmt(Cause.pretty(cause), output) | ||
} | ||
@@ -308,6 +307,5 @@ | ||
/** @internal */ | ||
const renderLogSpanLogfmt = (now: number) => | ||
(self: LogSpan.LogSpan): string => { | ||
const label = filterKeyName(self.label) | ||
return `${label}=${now - self.startTime}ms` | ||
} | ||
const renderLogSpanLogfmt = (now: number) => (self: LogSpan.LogSpan): string => { | ||
const label = filterKeyName(self.label) | ||
return `${label}=${now - self.startTime}ms` | ||
} |
@@ -288,14 +288,13 @@ import type * as Chunk from "@effect/data/Chunk" | ||
) => <R, E, A>(effect: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A> | ||
>(2, (self, input) => | ||
(effect) => | ||
core.matchCauseEffect(effect, { | ||
onFailure: (cause) => { | ||
self.unsafeUpdate(input, HashSet.empty()) | ||
return core.failCause(cause) | ||
}, | ||
onSuccess: (value) => { | ||
self.unsafeUpdate(input, HashSet.empty()) | ||
return core.succeed(value) | ||
} | ||
})) | ||
>(2, (self, input) => (effect) => | ||
core.matchCauseEffect(effect, { | ||
onFailure: (cause) => { | ||
self.unsafeUpdate(input, HashSet.empty()) | ||
return core.failCause(cause) | ||
}, | ||
onSuccess: (value) => { | ||
self.unsafeUpdate(input, HashSet.empty()) | ||
return core.succeed(value) | ||
} | ||
})) | ||
@@ -302,0 +301,0 @@ /* @internal */ |
@@ -27,9 +27,8 @@ import * as Data from "@effect/data/Data" | ||
/** @internal */ | ||
export const of = <R extends Request.Request<any, any>>(): Request.Request.Constructor<R> => | ||
(args) => | ||
// @ts-expect-error | ||
Data.struct({ | ||
[RequestTypeId]: requestVariance, | ||
...args | ||
}) | ||
export const of = <R extends Request.Request<any, any>>(): Request.Request.Constructor<R> => (args) => | ||
// @ts-expect-error | ||
Data.struct({ | ||
[RequestTypeId]: requestVariance, | ||
...args | ||
}) | ||
@@ -40,9 +39,9 @@ /** @internal */ | ||
): Request.Request.Constructor<R, "_tag"> => | ||
(args) => | ||
// @ts-expect-error | ||
Data.struct({ | ||
[RequestTypeId]: requestVariance, | ||
_tag: tag, | ||
...args | ||
}) | ||
(args) => | ||
// @ts-expect-error | ||
Data.struct({ | ||
[RequestTypeId]: requestVariance, | ||
_tag: tag, | ||
...args | ||
}) | ||
@@ -49,0 +48,0 @@ /** @internal */ |
@@ -14,3 +14,3 @@ import * as Context from "@effect/data/Context" | ||
import { NoSuchElementException } from "@effect/io/internal/cause" | ||
import * as CausePretty from "@effect/io/internal/cause-pretty" | ||
import * as CausePretty from "@effect/io/internal/cause" | ||
import * as core from "@effect/io/internal/core" | ||
@@ -27,81 +27,80 @@ import * as FiberRuntime from "@effect/io/internal/fiberRuntime" | ||
export const unsafeFork = <R>(runtime: Runtime.Runtime<R>) => | ||
<E, A>( | ||
self: Effect.Effect<R, E, A>, | ||
options?: Runtime.RunForkOptions | ||
): Fiber.RuntimeFiber<E, A> => { | ||
const fiberId = FiberId.unsafeMake() | ||
const effect = self | ||
<E, A>( | ||
self: Effect.Effect<R, E, A>, | ||
options?: Runtime.RunForkOptions | ||
): Fiber.RuntimeFiber<E, A> => { | ||
const fiberId = FiberId.unsafeMake() | ||
const effect = self | ||
let fiberRefs = FiberRefs.updatedAs(runtime.fiberRefs, { | ||
let fiberRefs = FiberRefs.updatedAs(runtime.fiberRefs, { | ||
fiberId, | ||
fiberRef: core.currentContext, | ||
value: runtime.context as Context.Context<never> | ||
}) | ||
if (options?.scheduler) { | ||
fiberRefs = FiberRefs.updatedAs(fiberRefs, { | ||
fiberId, | ||
fiberRef: core.currentContext, | ||
value: runtime.context as Context.Context<never> | ||
fiberRef: core.currentScheduler, | ||
value: options.scheduler | ||
}) | ||
} | ||
if (options?.scheduler) { | ||
fiberRefs = FiberRefs.updatedAs(fiberRefs, { | ||
fiberId, | ||
fiberRef: core.currentScheduler, | ||
value: options.scheduler | ||
}) | ||
} | ||
if (options?.updateRefs) { | ||
fiberRefs = options.updateRefs(fiberRefs, fiberId) | ||
} | ||
if (options?.updateRefs) { | ||
fiberRefs = options.updateRefs(fiberRefs, fiberId) | ||
} | ||
const fiberRuntime: FiberRuntime.FiberRuntime<E, A> = new FiberRuntime.FiberRuntime<E, A>( | ||
fiberId, | ||
FiberRefs.forkAs(fiberRefs, fiberId), | ||
runtime.runtimeFlags | ||
) | ||
const fiberRuntime: FiberRuntime.FiberRuntime<E, A> = new FiberRuntime.FiberRuntime<E, A>( | ||
fiberId, | ||
FiberRefs.forkAs(fiberRefs, fiberId), | ||
runtime.runtimeFlags | ||
) | ||
const supervisor = fiberRuntime._supervisor | ||
const supervisor = fiberRuntime._supervisor | ||
if (supervisor !== _supervisor.none) { | ||
supervisor.onStart(runtime.context, effect, Option.none(), fiberRuntime) | ||
if (supervisor !== _supervisor.none) { | ||
supervisor.onStart(runtime.context, effect, Option.none(), fiberRuntime) | ||
fiberRuntime.unsafeAddObserver((exit) => supervisor.onEnd(exit, fiberRuntime)) | ||
} | ||
fiberRuntime.unsafeAddObserver((exit) => supervisor.onEnd(exit, fiberRuntime)) | ||
} | ||
fiberScope.globalScope.add(runtime.runtimeFlags, fiberRuntime) | ||
fiberScope.globalScope.add(runtime.runtimeFlags, fiberRuntime) | ||
fiberRuntime.start(effect) | ||
fiberRuntime.start(effect) | ||
return fiberRuntime | ||
} | ||
return fiberRuntime | ||
} | ||
/** @internal */ | ||
export const unsafeRunCallback = <R>(runtime: Runtime.Runtime<R>) => | ||
<E, A>( | ||
effect: Effect.Effect<R, E, A>, | ||
onExit?: (exit: Exit.Exit<E, A>) => void | ||
): ((fiberId?: FiberId.FiberId, onExit?: (exit: Exit.Exit<E, A>) => void) => void) => { | ||
const fiberRuntime = unsafeFork(runtime)(effect) | ||
<E, A>( | ||
effect: Effect.Effect<R, E, A>, | ||
onExit?: (exit: Exit.Exit<E, A>) => void | ||
): (fiberId?: FiberId.FiberId, onExit?: (exit: Exit.Exit<E, A>) => void) => void => { | ||
const fiberRuntime = unsafeFork(runtime)(effect) | ||
if (onExit) { | ||
fiberRuntime.unsafeAddObserver((exit) => { | ||
onExit(exit) | ||
}) | ||
} | ||
return (id, onExitInterrupt) => | ||
unsafeRunCallback(runtime)( | ||
pipe(fiberRuntime, Fiber.interruptAs(id ?? FiberId.none)), | ||
onExitInterrupt ? | ||
(exit) => onExitInterrupt(Exit.flatten(exit)) : | ||
void 0 | ||
) | ||
if (onExit) { | ||
fiberRuntime.unsafeAddObserver((exit) => { | ||
onExit(exit) | ||
}) | ||
} | ||
return (id, onExitInterrupt) => | ||
unsafeRunCallback(runtime)( | ||
pipe(fiberRuntime, Fiber.interruptAs(id ?? FiberId.none)), | ||
onExitInterrupt ? | ||
(exit) => onExitInterrupt(Exit.flatten(exit)) : | ||
void 0 | ||
) | ||
} | ||
/** @internal */ | ||
export const unsafeRunSync = <R>(runtime: Runtime.Runtime<R>) => | ||
<E, A>(effect: Effect.Effect<R, E, A>): A => { | ||
const result = unsafeRunSyncExit(runtime)(effect) | ||
if (result._tag === "Failure") { | ||
throw fiberFailure(result.i0) | ||
} else { | ||
return result.i0 | ||
} | ||
export const unsafeRunSync = <R>(runtime: Runtime.Runtime<R>) => <E, A>(effect: Effect.Effect<R, E, A>): A => { | ||
const result = unsafeRunSyncExit(runtime)(effect) | ||
if (result._tag === "Failure") { | ||
throw fiberFailure(result.i0) | ||
} else { | ||
return result.i0 | ||
} | ||
} | ||
@@ -210,4 +209,4 @@ /** @internal */ | ||
/** @internal */ | ||
export const unsafeRunSyncExit = <R>(runtime: Runtime.Runtime<R>) => | ||
<E, A>(effect: Effect.Effect<R, E, A>): Exit.Exit<E, A> => { | ||
export const unsafeRunSyncExit = | ||
<R>(runtime: Runtime.Runtime<R>) => <E, A>(effect: Effect.Effect<R, E, A>): Exit.Exit<E, A> => { | ||
const op = fastPath(effect) | ||
@@ -228,4 +227,4 @@ if (op) { | ||
/** @internal */ | ||
export const unsafeRunPromise = <R>(runtime: Runtime.Runtime<R>) => | ||
<E, A>(effect: Effect.Effect<R, E, A>): Promise<A> => | ||
export const unsafeRunPromise = | ||
<R>(runtime: Runtime.Runtime<R>) => <E, A>(effect: Effect.Effect<R, E, A>): Promise<A> => | ||
unsafeRunPromiseExit(runtime)(effect).then((result) => { | ||
@@ -243,4 +242,4 @@ switch (result._tag) { | ||
/** @internal */ | ||
export const unsafeRunPromiseExit = <R>(runtime: Runtime.Runtime<R>) => | ||
<E, A>(effect: Effect.Effect<R, E, A>): Promise<Exit.Exit<E, A>> => | ||
export const unsafeRunPromiseExit = | ||
<R>(runtime: Runtime.Runtime<R>) => <E, A>(effect: Effect.Effect<R, E, A>): Promise<Exit.Exit<E, A>> => | ||
new Promise((resolve) => { | ||
@@ -247,0 +246,0 @@ const op = fastPath(effect) |
@@ -53,3 +53,3 @@ /** | ||
*/ | ||
export interface Queue<A> extends Enqueue<A>, Dequeue<A>, Pipeable { | ||
export interface Queue<A> extends Enqueue<A>, Dequeue<A>, Pipeable { | ||
/** @internal */ | ||
@@ -56,0 +56,0 @@ readonly queue: MutableQueue.MutableQueue<A> |
@@ -92,3 +92,4 @@ /** | ||
*/ | ||
export const contextFromServices = <Services extends Array<Context.Tag<any, any>>>(...services: Services) => | ||
export const contextFromServices = | ||
<Services extends Array<Context.Tag<any, any>>>(...services: Services) => | ||
<R, A extends Request.Request<any, any>>( | ||
@@ -95,0 +96,0 @@ self: RequestResolver<A, R> |
@@ -29,5 +29,3 @@ /** | ||
*/ | ||
export interface ScopedCache<Key, Error, Value> | ||
extends ScopedCache.Variance<Key, Error, Value>, Pipeable | ||
{ | ||
export interface ScopedCache<Key, Error, Value> extends ScopedCache.Variance<Key, Error, Value>, Pipeable { | ||
/** | ||
@@ -34,0 +32,0 @@ * Retrieves the value associated with the specified key if it exists. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
1
6429043
1016
114901
- Removed@effect/data@^0.17.0