@effect/io
Advanced tools
Comparing version 0.31.3 to 0.31.4
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
export type Concurrency = number | "unbounded"; | ||
export type Concurrency = number | "unbounded" | "inherit"; | ||
//# sourceMappingURL=Concurrency.d.ts.map |
@@ -56,3 +56,3 @@ "use strict"; | ||
const processOrPerformanceNow = /*#__PURE__*/function () { | ||
const processHrtime = typeof process === "object" && "hrtime" in process ? process.hrtime : undefined; | ||
const processHrtime = typeof process === "object" && "hrtime" in process && typeof process.hrtime.bigint === "function" ? process.hrtime : undefined; | ||
if (!processHrtime) { | ||
@@ -59,0 +59,0 @@ return performanceNowNanos; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.matchWithBatchedSimple = exports.matchWithBatched = void 0; | ||
exports.matchSimple = exports.match = void 0; | ||
var core = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/core")); | ||
@@ -12,3 +12,3 @@ 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); } | ||
/** @internal */ | ||
const matchWithBatched = (options, sequential, unbounded, withLimit, batched) => { | ||
const match = (options, sequential, unbounded, withLimit) => { | ||
let effect; | ||
@@ -26,5 +26,5 @@ switch (options?.concurrency) { | ||
} | ||
case 1: | ||
case "inherit": | ||
{ | ||
effect = options.batched ? batched() : sequential(); | ||
effect = core.fiberRefGetWith(core.currentConcurrency, concurrency => concurrency._tag === "None" ? unbounded() : concurrency.value > 1 ? withLimit(concurrency.value) : sequential()); | ||
break; | ||
@@ -38,19 +38,33 @@ } | ||
} | ||
return options?.batched !== undefined ? core.fiberRefLocally(effect, core.currentRequestBatchingEnabled, options.batched) : effect; | ||
return options?.batchRequests !== undefined && options.batchRequests !== "inherit" ? core.fiberRefLocally(effect, core.currentRequestBatchingEnabled, options.batchRequests) : effect; | ||
}; | ||
/** @internal */ | ||
exports.matchWithBatched = matchWithBatched; | ||
const matchWithBatchedSimple = (options, sequential, parallel) => { | ||
exports.match = match; | ||
const matchSimple = (options, sequential, parallel) => { | ||
let effect; | ||
switch (options?.concurrency) { | ||
case undefined: | ||
return sequential(); | ||
{ | ||
effect = sequential(); | ||
break; | ||
} | ||
case "unbounded": | ||
return parallel(); | ||
case 1: | ||
return options.batched ? parallel() : sequential(); | ||
{ | ||
effect = parallel(); | ||
break; | ||
} | ||
case "inherit": | ||
{ | ||
effect = core.fiberRefGetWith(core.currentConcurrency, concurrency => concurrency._tag === "None" ? parallel() : concurrency.value > 1 ? parallel() : sequential()); | ||
break; | ||
} | ||
default: | ||
return options.concurrency > 1 ? parallel() : sequential(); | ||
{ | ||
effect = options.concurrency > 1 ? parallel() : sequential(); | ||
break; | ||
} | ||
} | ||
return options?.batchRequests !== undefined && options.batchRequests !== "inherit" ? core.fiberRefLocally(effect, core.currentRequestBatchingEnabled, options.batchRequests) : effect; | ||
}; | ||
exports.matchWithBatchedSimple = matchWithBatchedSimple; | ||
exports.matchSimple = matchSimple; | ||
//# sourceMappingURL=concurrency.js.map |
@@ -6,5 +6,5 @@ "use strict"; | ||
}); | ||
exports.fail = exports.exitZipWith = exports.exitZipRight = exports.exitZipParRight = exports.exitZipParLeft = exports.exitZipPar = exports.exitZipLeft = exports.exitZip = exports.exitUnit = exports.exitUnannotate = exports.exitSucceed = exports.exitMatchEffect = exports.exitMatch = exports.exitMapErrorCause = exports.exitMapError = exports.exitMapBoth = exports.exitMap = exports.exitIsSuccess = exports.exitIsInterrupted = exports.exitIsFailure = exports.exitIsExit = exports.exitInterrupt = exports.exitGetOrElse = exports.exitFromOption = exports.exitFromEither = exports.exitForEachEffect = exports.exitFlatten = exports.exitFlatMapEffect = exports.exitFlatMap = exports.exitFailCause = exports.exitFail = exports.exitExists = exports.exitDie = exports.exitCollectAll = exports.exitCauseOption = exports.exitAsUnit = exports.exitAs = exports.exit = exports.either = exports.dieSync = exports.dieMessage = exports.die = exports.deferredUnsafeMake = exports.deferredUnsafeDone = exports.deferredSync = exports.deferredSucceed = exports.deferredPoll = exports.deferredMakeAs = exports.deferredMake = exports.deferredIsDone = exports.deferredInterruptWith = exports.deferredInterrupt = exports.deferredFailSync = exports.deferredFailCauseSync = exports.deferredFailCause = exports.deferredFail = exports.deferredDone = exports.deferredDieSync = exports.deferredDie = exports.deferredCompleteWith = exports.deferredComplete = exports.deferredAwait = exports.currentUnhandledErrorLogLevel = exports.currentTracerSpanAnnotations = exports.currentTracerSpan = exports.currentSchedulingPriority = exports.currentScheduler = exports.currentRequestBatchingEnabled = exports.currentMetricLabels = exports.currentMaxFiberOps = exports.currentLogSpan = exports.currentLogLevel = exports.currentLogAnnotations = exports.currentInterruptedCause = exports.currentForkScopeOverride = exports.currentContext = exports.contramapContext = exports.contextWithEffect = exports.context = exports.checkInterruptible = exports.catchSome = exports.catchAllCause = exports.catchAll = exports.blocked = exports.attemptOrElse = exports.asyncInterruptEither = exports.asyncInterrupt = exports.async = exports.asUnit = exports.as = exports.allLogLevels = exports.acquireUseRelease = exports.ScopeTypeId = exports.RevertFlags = exports.RequestResolverTypeId = exports.RequestResolverImpl = exports.FiberRefTypeId = exports.EffectTypeId = exports.EffectErrorTypeId = exports.CloseableScopeTypeId = void 0; | ||
exports.withRuntimeFlags = exports.withMaxFiberOps = exports.withFiberRuntime = exports.whileLoop = exports.whenEffect = exports.updateRuntimeFlags = exports.unit = exports.uninterruptibleMask = exports.uninterruptible = exports.unified = exports.transplant = exports.tap = exports.sync = exports.suspend = exports.succeed = exports.step = exports.scopeFork = exports.scopeClose = exports.scopeAddFinalizerExit = exports.scopeAddFinalizer = exports.runtimeFlags = exports.runRequestBlock = exports.resolverLocally = exports.requestBlockLocally = exports.releaseMapReplace = exports.releaseMapRemove = exports.releaseMapRelease = exports.releaseMapMake = exports.releaseMapGet = exports.releaseMapAddIfOpen = exports.releaseMapAdd = exports.provideSomeContext = exports.provideContext = exports.partitionMap = exports.orElse = exports.orDieWith = exports.orDie = exports.onInterrupt = exports.onExit = exports.onError = exports.never = exports.metricLabels = exports.matchEffect = exports.matchCauseEffect = exports.matchCause = exports.mapError = exports.mapBoth = exports.map = exports.makeEffectError = exports.logLevelWarning = exports.logLevelTrace = exports.logLevelNone = exports.logLevelInfo = exports.logLevelFatal = exports.logLevelError = exports.logLevelDebug = exports.logLevelAll = exports.isRequestResolver = exports.isEffectError = exports.isEffect = exports.intoDeferred = exports.interruptibleMask = exports.interruptible = exports.interruptWith = exports.interruptFiber = exports.interruptAsFiber = exports.interrupt = exports.if_ = exports.forEachDiscard = exports.forEach = exports.flip = exports.flatten = exports.flatMapStep = exports.flatMap = exports.fiberRefUpdateSomeAndGet = exports.fiberRefUpdateSome = exports.fiberRefUpdateAndGet = exports.fiberRefUpdate = exports.fiberRefUnsafeMakeRuntimeFlags = exports.fiberRefUnsafeMakePatch = exports.fiberRefUnsafeMakeHashSet = exports.fiberRefUnsafeMakeContext = exports.fiberRefUnsafeMake = exports.fiberRefSet = exports.fiberRefReset = exports.fiberRefModifySome = exports.fiberRefModify = exports.fiberRefLocallyWith = exports.fiberRefLocally = exports.fiberRefGetWith = exports.fiberRefGetAndUpdateSome = exports.fiberRefGetAndUpdate = exports.fiberRefGetAndSet = exports.fiberRefGet = exports.fiberRefDelete = exports.fiberIdWith = exports.fiberId = exports.failSync = exports.failCauseSync = exports.failCause = void 0; | ||
exports.zipWith = exports.zipRight = exports.zipLeft = exports.zipFlatten = exports.zip = exports.yieldNow = exports.withUnhandledErrorLogLevel = exports.withSchedulingPriority = exports.withScheduler = void 0; | ||
exports.exitZipWith = exports.exitZipRight = exports.exitZipParRight = exports.exitZipParLeft = exports.exitZipPar = exports.exitZipLeft = exports.exitZip = exports.exitUnit = exports.exitUnannotate = exports.exitSucceed = exports.exitMatchEffect = exports.exitMatch = exports.exitMapErrorCause = exports.exitMapError = exports.exitMapBoth = exports.exitMap = exports.exitIsSuccess = exports.exitIsInterrupted = exports.exitIsFailure = exports.exitIsExit = exports.exitInterrupt = exports.exitGetOrElse = exports.exitFromOption = exports.exitFromEither = exports.exitForEachEffect = exports.exitFlatten = exports.exitFlatMapEffect = exports.exitFlatMap = exports.exitFailCause = exports.exitFail = exports.exitExists = exports.exitDie = exports.exitCollectAll = exports.exitCauseOption = exports.exitAsUnit = exports.exitAs = exports.exit = exports.either = exports.dieSync = exports.dieMessage = exports.die = exports.deferredUnsafeMake = exports.deferredUnsafeDone = exports.deferredSync = exports.deferredSucceed = exports.deferredPoll = exports.deferredMakeAs = exports.deferredMake = exports.deferredIsDone = exports.deferredInterruptWith = exports.deferredInterrupt = exports.deferredFailSync = exports.deferredFailCauseSync = exports.deferredFailCause = exports.deferredFail = exports.deferredDone = exports.deferredDieSync = exports.deferredDie = exports.deferredCompleteWith = exports.deferredComplete = exports.deferredAwait = exports.currentUnhandledErrorLogLevel = exports.currentTracerSpanAnnotations = exports.currentTracerSpan = exports.currentSchedulingPriority = exports.currentScheduler = exports.currentRequestBatchingEnabled = exports.currentMetricLabels = exports.currentMaxFiberOps = exports.currentLogSpan = exports.currentLogLevel = exports.currentLogAnnotations = exports.currentInterruptedCause = exports.currentForkScopeOverride = exports.currentContext = exports.currentConcurrency = exports.contramapContext = exports.contextWithEffect = exports.context = exports.checkInterruptible = exports.catchSome = exports.catchAllCause = exports.catchAll = exports.blocked = exports.attemptOrElse = exports.asyncInterruptEither = exports.asyncInterrupt = exports.async = exports.asUnit = exports.as = exports.allLogLevels = exports.acquireUseRelease = exports.ScopeTypeId = exports.RevertFlags = exports.RequestResolverTypeId = exports.RequestResolverImpl = exports.FiberRefTypeId = exports.EffectTypeId = exports.EffectErrorTypeId = exports.CloseableScopeTypeId = void 0; | ||
exports.withInheritedConcurrency = exports.withFiberRuntime = exports.whileLoop = exports.whenEffect = exports.updateRuntimeFlags = exports.unit = exports.uninterruptibleMask = exports.uninterruptible = exports.unified = exports.transplant = exports.tap = exports.sync = exports.suspend = exports.succeed = exports.step = exports.scopeFork = exports.scopeClose = exports.scopeAddFinalizerExit = exports.scopeAddFinalizer = exports.runtimeFlags = exports.runRequestBlock = exports.resolverLocally = exports.requestBlockLocally = exports.releaseMapReplace = exports.releaseMapRemove = exports.releaseMapRelease = exports.releaseMapMake = exports.releaseMapGet = exports.releaseMapAddIfOpen = exports.releaseMapAdd = exports.provideSomeContext = exports.provideContext = exports.partitionMap = exports.orElse = exports.orDieWith = exports.orDie = exports.onInterrupt = exports.onExit = exports.onError = exports.never = exports.metricLabels = exports.matchEffect = exports.matchCauseEffect = exports.matchCause = exports.mapError = exports.mapBoth = exports.map = exports.makeEffectError = exports.logLevelWarning = exports.logLevelTrace = exports.logLevelNone = exports.logLevelInfo = exports.logLevelFatal = exports.logLevelError = exports.logLevelDebug = exports.logLevelAll = exports.isRequestResolver = exports.isEffectError = exports.isEffect = exports.intoDeferred = exports.interruptibleMask = exports.interruptible = exports.interruptWith = exports.interruptFiber = exports.interruptAsFiber = exports.interrupt = exports.if_ = exports.forEachDiscard = exports.forEach = exports.flip = exports.flatten = exports.flatMapStep = exports.flatMap = exports.fiberRefUpdateSomeAndGet = exports.fiberRefUpdateSome = exports.fiberRefUpdateAndGet = exports.fiberRefUpdate = exports.fiberRefUnsafeMakeRuntimeFlags = exports.fiberRefUnsafeMakePatch = exports.fiberRefUnsafeMakeHashSet = exports.fiberRefUnsafeMakeContext = exports.fiberRefUnsafeMake = exports.fiberRefSet = exports.fiberRefReset = exports.fiberRefModifySome = exports.fiberRefModify = exports.fiberRefLocallyWith = exports.fiberRefLocally = exports.fiberRefGetWith = exports.fiberRefGetAndUpdateSome = exports.fiberRefGetAndUpdate = exports.fiberRefGetAndSet = exports.fiberRefGet = exports.fiberRefDelete = exports.fiberIdWith = exports.fiberId = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = void 0; | ||
exports.zipWith = exports.zipRight = exports.zipLeft = exports.zipFlatten = exports.zip = exports.yieldNow = exports.withUnhandledErrorLogLevel = exports.withSchedulingPriority = exports.withScheduler = exports.withRuntimeFlags = exports.withMaxFiberOps = void 0; | ||
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk")); | ||
@@ -646,2 +646,5 @@ var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Context")); | ||
exports.whileLoop = whileLoop; | ||
const withInheritedConcurrency = /*#__PURE__*/(0, _Function.dual)(2, (self, concurrency) => fiberRefLocally(self, currentConcurrency, concurrency === "unbounded" ? Option.none() : Option.some(concurrency))); | ||
/* @internal */ | ||
exports.withInheritedConcurrency = withInheritedConcurrency; | ||
const withRuntimeFlags = /*#__PURE__*/(0, _Function.dual)(2, (self, update) => { | ||
@@ -980,6 +983,9 @@ const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS); | ||
const withMaxFiberOps = /*#__PURE__*/(0, _Function.dual)(2, (self, ops) => fiberRefLocally(self, currentMaxFiberOps, ops)); | ||
/** @internal */ | ||
exports.withMaxFiberOps = withMaxFiberOps; | ||
const currentConcurrency = /*#__PURE__*/(0, _Global.globalValue)( /*#__PURE__*/Symbol.for("@effect/io/FiberRef/currentConcurrency"), () => fiberRefUnsafeMake(Option.none())); | ||
/** | ||
* @internal | ||
*/ | ||
exports.withMaxFiberOps = withMaxFiberOps; | ||
exports.currentConcurrency = currentConcurrency; | ||
const currentRequestBatchingEnabled = /*#__PURE__*/(0, _Global.globalValue)( /*#__PURE__*/Symbol.for("@effect/io/FiberRef/currentRequestBatchingEnabled"), () => fiberRefUnsafeMake(true)); | ||
@@ -986,0 +992,0 @@ /** @internal */ |
@@ -6,4 +6,4 @@ "use strict"; | ||
}); | ||
exports.try_ = exports.tryPromiseInterrupt = exports.tryPromise = exports.tryMap = exports.tracerWith = exports.tracer = exports.timedWith = exports.timed = exports.tapErrorCause = exports.tapError = exports.tapDefect = exports.tapBoth = exports.takeWhile = exports.takeUntil = exports.tagMetrics = exports.summarized = exports.succeedSome = exports.succeedNone = exports.spanAnnotations = exports.some = exports.sleep = exports.setFiberRefs = exports.serviceFunctionEffect = exports.serviceFunction = exports.sandbox = exports.repeatN = exports.reduceWhile = exports.reduceRight = exports.reduce = exports.random = exports.provideServiceEffect = exports.provideService = exports.promiseInterrupt = exports.promise = exports.patchFiberRefs = exports.parallelErrors = exports.orElseSucceed = exports.orElseFail = exports.option = exports.once = exports.none = exports.negate = exports.merge = exports.memoize = exports.match = exports.mapErrorCause = exports.mapAccum = exports.loop = exports.logCause = exports.logAnnotations = exports.log = exports.labelMetricsSet = exports.labelMetrics = exports.iterate = exports.isSuccess = exports.isFailure = exports.inheritFiberRefs = exports.ignoreLogged = exports.ignore = exports.head = exports.getFiberRefs = exports.gen = exports.forever = exports.flipWith = exports.firstSuccessOf = exports.findFirst = exports.filterOrFail = exports.filterOrElse = exports.filterOrDieMessage = exports.filterOrDie = exports.filterMap = exports.every = exports.eventually = exports.dropWhile = exports.dropUntil = exports.diffFiberRefs = exports.descriptorWith = exports.descriptor = exports.delay = exports.currentSpan = exports.contextWith = exports.clockWith = exports.clock = exports.cause = exports.catchTags = exports.catchTag = exports.catchSomeDefect = exports.catchSomeCause = exports.catchAllDefect = exports.bindValue = exports.bindTo = exports.bind = exports.asyncOption = exports.asSomeError = exports.asSome = exports.annotateSpans = exports.annotateLogs = exports.allowInterrupt = exports._catch = exports.Do = void 0; | ||
exports.withSpan = exports.withMetric = exports.withLogSpan = exports.withLogCause = exports.withLog = exports.whenRef = exports.whenFiberRef = exports.when = exports.useSpan = exports.updateService = exports.updateFiberRefs = exports.unsandbox = exports.unlessEffect = exports.unless = void 0; | ||
exports.tryPromise = exports.tryMapPromiseInterrupt = exports.tryMapPromise = exports.tryMap = exports.tracerWith = exports.tracer = exports.timedWith = exports.timed = exports.tapErrorCause = exports.tapError = exports.tapDefect = exports.tapBoth = exports.takeWhile = exports.takeUntil = exports.tagMetrics = exports.summarized = exports.succeedSome = exports.succeedNone = exports.spanAnnotations = exports.some = exports.sleep = exports.setFiberRefs = exports.serviceFunctionEffect = exports.serviceFunction = exports.sandbox = exports.repeatN = exports.reduceWhile = exports.reduceRight = exports.reduce = exports.random = exports.provideServiceEffect = exports.provideService = exports.promiseInterrupt = exports.promise = exports.patchFiberRefs = exports.parallelErrors = exports.orElseSucceed = exports.orElseFail = exports.option = exports.once = exports.none = exports.negate = exports.merge = exports.memoize = exports.match = exports.mapErrorCause = exports.mapAccum = exports.loop = exports.logCause = exports.logAnnotations = exports.log = exports.labelMetricsSet = exports.labelMetrics = exports.iterate = exports.isSuccess = exports.isFailure = exports.inheritFiberRefs = exports.ignoreLogged = exports.ignore = exports.head = exports.getFiberRefs = exports.gen = exports.forever = exports.flipWith = exports.firstSuccessOf = exports.findFirst = exports.filterOrFail = exports.filterOrElse = exports.filterOrDieMessage = exports.filterOrDie = exports.filterMap = exports.every = exports.eventually = exports.dropWhile = exports.dropUntil = exports.diffFiberRefs = exports.descriptorWith = exports.descriptor = exports.delay = exports.currentSpan = exports.contextWith = exports.clockWith = exports.clock = exports.cause = exports.catchTags = exports.catchTag = exports.catchSomeDefect = exports.catchSomeCause = exports.catchAllDefect = exports.bindValue = exports.bindTo = exports.bind = exports.asyncOption = exports.asSomeError = exports.asSome = exports.annotateSpans = exports.annotateLogs = exports.allowInterrupt = exports._catch = exports.Do = void 0; | ||
exports.withSpan = exports.withMetric = exports.withLogSpan = exports.withLogCause = exports.withLog = exports.whenRef = exports.whenFiberRef = exports.when = exports.useSpan = exports.updateService = exports.updateFiberRefs = exports.unsandbox = exports.unlessEffect = exports.unless = exports.try_ = exports.tryPromiseInterrupt = void 0; | ||
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk")); | ||
@@ -736,2 +736,14 @@ var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Context")); | ||
exports.tryMap = tryMap; | ||
const tryMapPromise = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => core.flatMap(self, a => tryPromise({ | ||
try: () => options.try(a), | ||
catch: options.catch | ||
}))); | ||
/* @internal */ | ||
exports.tryMapPromise = tryMapPromise; | ||
const tryMapPromiseInterrupt = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => core.flatMap(self, a => tryPromiseInterrupt({ | ||
try: signal => options.try(a, signal), | ||
catch: options.catch | ||
}))); | ||
/* @internal */ | ||
exports.tryMapPromiseInterrupt = tryMapPromiseInterrupt; | ||
const unless = /*#__PURE__*/(0, _Function.dual)(2, (self, predicate) => core.suspend(() => predicate() ? succeedNone : asSome(self))); | ||
@@ -738,0 +750,0 @@ /* @internal */ |
@@ -7,3 +7,3 @@ import type { Concurrency } from "@effect/io/Concurrency"; | ||
readonly concurrency?: Concurrency; | ||
readonly batched?: boolean; | ||
readonly batchRequests?: boolean | "inherit"; | ||
readonly discard?: false; | ||
@@ -13,3 +13,3 @@ }): (self: Iterable<A>) => Effect.Effect<R, E, B[]>; | ||
readonly concurrency?: Concurrency; | ||
readonly batched?: boolean; | ||
readonly batchRequests?: boolean | "inherit"; | ||
readonly discard: true; | ||
@@ -20,3 +20,3 @@ }): (self: Iterable<A_1>) => Effect.Effect<R_1, E_1, void>; | ||
readonly concurrency?: Concurrency; | ||
readonly batched?: boolean; | ||
readonly batchRequests?: boolean | "inherit"; | ||
readonly discard?: false; | ||
@@ -26,3 +26,3 @@ }): Effect.Effect<R_2, E_2, B_2[]>; | ||
readonly concurrency?: Concurrency; | ||
readonly batched?: boolean; | ||
readonly batchRequests?: boolean | "inherit"; | ||
readonly discard: true; | ||
@@ -29,0 +29,0 @@ }): Effect.Effect<R_3, E_3, void>; |
{ | ||
"name": "@effect/io", | ||
"version": "0.31.3", | ||
"version": "0.31.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -11,2 +11,2 @@ /** | ||
*/ | ||
export type Concurrency = number | "unbounded" | ||
export type Concurrency = number | "unbounded" | "inherit" |
@@ -56,3 +56,6 @@ import * as Context from "@effect/data/Context" | ||
const processOrPerformanceNow = (function() { | ||
const processHrtime = typeof process === "object" && "hrtime" in process ? process.hrtime : undefined | ||
const processHrtime = | ||
typeof process === "object" && "hrtime" in process && typeof process.hrtime.bigint === "function" ? | ||
process.hrtime : | ||
undefined | ||
if (!processHrtime) { | ||
@@ -59,0 +62,0 @@ return performanceNowNanos |
@@ -6,11 +6,10 @@ import type { Concurrency } from "@effect/io/Concurrency" | ||
/** @internal */ | ||
export const matchWithBatched = <R, E, A>( | ||
export const match = <R, E, A>( | ||
options: { | ||
readonly concurrency?: Concurrency | ||
readonly batched?: boolean | ||
readonly batchRequests?: boolean | "inherit" | ||
} | undefined, | ||
sequential: () => Effect<R, E, A>, | ||
unbounded: () => Effect<R, E, A>, | ||
withLimit: (limit: number) => Effect<R, E, A>, | ||
batched: () => Effect<R, E, A> | ||
withLimit: (limit: number) => Effect<R, E, A> | ||
) => { | ||
@@ -27,4 +26,12 @@ let effect: Effect<R, E, A> | ||
} | ||
case 1: { | ||
effect = options.batched ? batched() : sequential() | ||
case "inherit": { | ||
effect = core.fiberRefGetWith( | ||
core.currentConcurrency, | ||
(concurrency) => | ||
concurrency._tag === "None" ? | ||
unbounded() : | ||
concurrency.value > 1 ? | ||
withLimit(concurrency.value) : | ||
sequential() | ||
) | ||
break | ||
@@ -39,4 +46,4 @@ } | ||
} | ||
return options?.batched !== undefined ? | ||
core.fiberRefLocally(effect, core.currentRequestBatchingEnabled, options.batched) : | ||
return options?.batchRequests !== undefined && options.batchRequests !== "inherit" ? | ||
core.fiberRefLocally(effect, core.currentRequestBatchingEnabled, options.batchRequests) : | ||
effect | ||
@@ -46,6 +53,6 @@ } | ||
/** @internal */ | ||
export const matchWithBatchedSimple = <R, E, A>( | ||
export const matchSimple = <R, E, A>( | ||
options: { | ||
readonly concurrency?: Concurrency | ||
readonly batched?: boolean | ||
readonly batchRequests?: boolean | "inherit" | ||
} | undefined, | ||
@@ -55,12 +62,33 @@ sequential: () => Effect<R, E, A>, | ||
) => { | ||
let effect: Effect<R, E, A> | ||
switch (options?.concurrency) { | ||
case undefined: | ||
return sequential() | ||
case "unbounded": | ||
return parallel() | ||
case 1: | ||
return options.batched ? parallel() : sequential() | ||
default: | ||
return options!.concurrency > 1 ? parallel() : sequential() | ||
case undefined: { | ||
effect = sequential() | ||
break | ||
} | ||
case "unbounded": { | ||
effect = parallel() | ||
break | ||
} | ||
case "inherit": { | ||
effect = core.fiberRefGetWith( | ||
core.currentConcurrency, | ||
(concurrency) => | ||
concurrency._tag === "None" ? | ||
parallel() : | ||
concurrency.value > 1 ? | ||
parallel() : | ||
sequential() | ||
) | ||
break | ||
} | ||
default: { | ||
effect = options!.concurrency > 1 ? parallel() : sequential() | ||
break | ||
} | ||
} | ||
return options?.batchRequests !== undefined && options.batchRequests !== "inherit" ? | ||
core.fiberRefLocally(effect, core.currentRequestBatchingEnabled, options.batchRequests) : | ||
effect | ||
} |
@@ -1685,2 +1685,46 @@ import * as Chunk from "@effect/data/Chunk" | ||
/* @internal */ | ||
export const tryMapPromise = dual< | ||
<A, B, E1>( | ||
options: { | ||
readonly try: (a: A) => Promise<B> | ||
readonly catch: (error: unknown) => E1 | ||
} | ||
) => <R, E>(self: Effect.Effect<R, E, A>) => Effect.Effect<R, E | E1, B>, | ||
<R, E, A, B, E1>( | ||
self: Effect.Effect<R, E, A>, | ||
options: { | ||
readonly try: (a: A) => Promise<B> | ||
readonly catch: (error: unknown) => E1 | ||
} | ||
) => Effect.Effect<R, E | E1, B> | ||
>(2, (self, options) => | ||
core.flatMap(self, (a) => | ||
tryPromise({ | ||
try: () => options.try(a), | ||
catch: options.catch | ||
}))) | ||
/* @internal */ | ||
export const tryMapPromiseInterrupt = dual< | ||
<A, B, E1>( | ||
options: { | ||
readonly try: (a: A, signal: AbortSignal) => Promise<B> | ||
readonly catch: (error: unknown) => E1 | ||
} | ||
) => <R, E>(self: Effect.Effect<R, E, A>) => Effect.Effect<R, E | E1, B>, | ||
<R, E, A, B, E1>( | ||
self: Effect.Effect<R, E, A>, | ||
options: { | ||
readonly try: (a: A, signal: AbortSignal) => Promise<B> | ||
readonly catch: (error: unknown) => E1 | ||
} | ||
) => Effect.Effect<R, E | E1, B> | ||
>(2, (self, options) => | ||
core.flatMap(self, (a) => | ||
tryPromiseInterrupt({ | ||
try: (signal) => options.try(a, signal), | ||
catch: options.catch | ||
}))) | ||
/* @internal */ | ||
export const unless = dual< | ||
@@ -1687,0 +1731,0 @@ (predicate: LazyArg<boolean>) => <R, E, A>(self: Effect.Effect<R, E, A>) => Effect.Effect<R, E, Option.Option<A>>, |
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 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
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
6382424
113809