Socket
Socket
Sign inDemoInstall

@effect/stm

Package Overview
Dependencies
Maintainers
3
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/stm - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

164

internal_effect_untraced/core.js

@@ -303,91 +303,121 @@ "use strict";

const current = curr;
if (current && Context.isGenericTag(current)) {
if (Context.isTag(current)) {
curr = effect((_, __, env) => Context.unsafeGet(env, current));
} else {
curr = current["i0"];
}
} else {
switch (current.i0) {
case OpCodes.OP_TRACED:
if (current) {
switch (current._tag) {
case "Tag":
{
this.pushStack(current);
curr = current.i1;
curr = effect((_, __, env) => Context.unsafeGet(env, current));
break;
}
case OpCodes.OP_DIE:
case "Traced":
{
const annotation = new Cause.StackAnnotation(this.stackToLines(), MRef.incrementAndGet(Cause.globalErrorSeq));
exit = TExit.die(current.i1(), annotation);
curr = current.i0;
break;
}
case OpCodes.OP_FAIL:
case "Left":
{
const annotation = new internalCause.StackAnnotation(this.stackToLines(), MRef.incrementAndGet(Cause.globalErrorSeq));
const cont = this.nextFailure();
if (cont === undefined) {
exit = TExit.fail(current.i1(), annotation);
} else {
curr = cont.i2(current.i1());
}
curr = fail(current["i0"]);
break;
}
case OpCodes.OP_RETRY:
case "None":
{
const cont = this.nextRetry();
if (cont === undefined) {
exit = TExit.retry;
} else {
curr = cont.i2();
}
curr = fail(Cause.NoSuchElementException());
break;
}
case OpCodes.OP_INTERRUPT:
case "Right":
{
const annotation = new Cause.StackAnnotation(this.stackToLines(), MRef.incrementAndGet(Cause.globalErrorSeq));
exit = TExit.interrupt(this.fiberId, annotation);
curr = succeed(current["i0"]);
break;
}
case OpCodes.OP_WITH_STM_RUNTIME:
case "Some":
{
curr = current.i1(this);
curr = succeed(current["i0"]);
break;
}
case OpCodes.OP_ON_SUCCESS:
case OpCodes.OP_ON_FAILURE:
case OpCodes.OP_ON_RETRY:
case "Commit":
{
this.pushStack(current);
curr = current.i1;
break;
}
case OpCodes.OP_PROVIDE:
{
const env = this.env;
this.env = current.i2(env);
curr = ensuring(sync(() => this.env = env))(current.i1);
break;
}
case OpCodes.OP_SUCCEED:
{
const value = current.i1;
const cont = this.nextSuccess();
if (cont === undefined) {
exit = TExit.succeed(value);
} else {
curr = cont.i2(value);
switch (current.i0) {
case OpCodes.OP_TRACED:
{
this.pushStack(current);
curr = current.i1;
break;
}
case OpCodes.OP_DIE:
{
const annotation = new Cause.StackAnnotation(this.stackToLines(), MRef.incrementAndGet(Cause.globalErrorSeq));
exit = TExit.die(current.i1(), annotation);
break;
}
case OpCodes.OP_FAIL:
{
const annotation = new internalCause.StackAnnotation(this.stackToLines(), MRef.incrementAndGet(Cause.globalErrorSeq));
const cont = this.nextFailure();
if (cont === undefined) {
exit = TExit.fail(current.i1(), annotation);
} else {
curr = cont.i2(current.i1());
}
break;
}
case OpCodes.OP_RETRY:
{
const cont = this.nextRetry();
if (cont === undefined) {
exit = TExit.retry;
} else {
curr = cont.i2();
}
break;
}
case OpCodes.OP_INTERRUPT:
{
const annotation = new Cause.StackAnnotation(this.stackToLines(), MRef.incrementAndGet(Cause.globalErrorSeq));
exit = TExit.interrupt(this.fiberId, annotation);
break;
}
case OpCodes.OP_WITH_STM_RUNTIME:
{
curr = current.i1(this);
break;
}
case OpCodes.OP_ON_SUCCESS:
case OpCodes.OP_ON_FAILURE:
case OpCodes.OP_ON_RETRY:
{
this.pushStack(current);
curr = current.i1;
break;
}
case OpCodes.OP_PROVIDE:
{
const env = this.env;
this.env = current.i2(env);
curr = ensuring(sync(() => this.env = env))(current.i1);
break;
}
case OpCodes.OP_SUCCEED:
{
const value = current.i1;
const cont = this.nextSuccess();
if (cont === undefined) {
exit = TExit.succeed(value);
} else {
curr = cont.i2(value);
}
break;
}
case OpCodes.OP_SYNC:
{
const value = current.i1();
const cont = this.nextSuccess();
if (cont === undefined) {
exit = TExit.succeed(value);
} else {
curr = cont.i2(value);
}
break;
}
}
break;
}
case OpCodes.OP_SYNC:
{
const value = current.i1();
const cont = this.nextSuccess();
if (cont === undefined) {
exit = TExit.succeed(value);
} else {
curr = cont.i2(value);
}
break;
}
}

@@ -394,0 +424,0 @@ }

@@ -226,2 +226,9 @@ "use strict";

}
const adapter = function () {
let x = arguments[0];
for (let i = 1; i < arguments.length; i++) {
x = arguments[i](x);
}
return new STMGen(x);
};
/**

@@ -232,3 +239,3 @@ * Inspired by https://github.com/tusharmath/qio/pull/22 (revised)

const gen = /*#__PURE__*/Debug.methodWithTrace((trace, restore) => f => suspend(() => {
const iterator = f(self => new STMGen(self));
const iterator = f(adapter);
const state = restore(() => iterator.next())();

@@ -235,0 +242,0 @@ const run = state => state.done ? core.succeed(state.value) : core.flatMap(state.value.value, val => run(restore(() => iterator.next(val))()));

{
"name": "@effect/stm",
"version": "0.8.1",
"version": "0.9.0",
"license": "MIT",

@@ -10,4 +10,4 @@ "repository": {

"dependencies": {
"@effect/data": "~0.9.1",
"@effect/io": "~0.16.1"
"@effect/data": "~0.10.3",
"@effect/io": "~0.18.0"
},

@@ -14,0 +14,0 @@ "publishConfig": {

@@ -10,2 +10,3 @@ import * as Chunk from "@effect/data/Chunk"

import * as MRef from "@effect/data/MutableRef"
import type * as Option from "@effect/data/Option"
import { tuple } from "@effect/data/ReadonlyArray"

@@ -522,3 +523,3 @@ import * as Cause from "@effect/io/Cause"

run(): TExit.TExit<E, A> {
let curr = this.self as Primitive | Context.GenericTag | undefined
let curr = this.self as Primitive | Context.GenericTag | Either.Either<any, any> | Option.Option<any> | undefined
let exit: TExit.TExit<unknown, unknown> | undefined = undefined

@@ -528,93 +529,116 @@ while (exit === undefined && curr !== undefined) {

const current = curr
if (current && Context.isGenericTag(current)) {
if (Context.isTag(current)) {
curr = effect((_, __, env) => Context.unsafeGet(env, current)) as Primitive
} else {
curr = current["i0"]
}
} else {
switch (current.i0) {
case OpCodes.OP_TRACED: {
this.pushStack(current)
curr = current.i1 as Primitive
if (current) {
switch (current._tag) {
case "Tag": {
curr = effect((_, __, env) => Context.unsafeGet(env, current)) as Primitive
break
}
case OpCodes.OP_DIE: {
const annotation = new Cause.StackAnnotation(
this.stackToLines(),
MRef.incrementAndGet(Cause.globalErrorSeq)
)
exit = TExit.die(current.i1(), annotation)
case "Traced": {
curr = current.i0
break
}
case OpCodes.OP_FAIL: {
const annotation = new internalCause.StackAnnotation(
this.stackToLines(),
MRef.incrementAndGet(Cause.globalErrorSeq)
)
const cont = this.nextFailure()
if (cont === undefined) {
exit = TExit.fail(current.i1(), annotation)
} else {
curr = cont.i2(current.i1()) as Primitive
}
case "Left": {
curr = fail((current as any)["i0"]) as Primitive
break
}
case OpCodes.OP_RETRY: {
const cont = this.nextRetry()
if (cont === undefined) {
exit = TExit.retry
} else {
curr = cont.i2() as Primitive
}
case "None": {
curr = fail(Cause.NoSuchElementException()) as Primitive
break
}
case OpCodes.OP_INTERRUPT: {
const annotation = new Cause.StackAnnotation(
this.stackToLines(),
MRef.incrementAndGet(Cause.globalErrorSeq)
)
exit = TExit.interrupt(this.fiberId, annotation)
case "Right": {
curr = succeed((current as any)["i0"]) as Primitive
break
}
case OpCodes.OP_WITH_STM_RUNTIME: {
curr = current.i1(this as STMDriver<unknown, unknown, unknown>) as Primitive
case "Some": {
curr = succeed((current as any)["i0"]) as Primitive
break
}
case OpCodes.OP_ON_SUCCESS:
case OpCodes.OP_ON_FAILURE:
case OpCodes.OP_ON_RETRY: {
this.pushStack(current)
curr = current.i1 as Primitive
break
}
case OpCodes.OP_PROVIDE: {
const env = this.env
this.env = current.i2(env)
curr = pipe(
current.i1,
ensuring(sync(() => (this.env = env)))
) as Primitive
break
}
case OpCodes.OP_SUCCEED: {
const value = current.i1
const cont = this.nextSuccess()
if (cont === undefined) {
exit = TExit.succeed(value)
} else {
curr = cont.i2(value) as Primitive
case "Commit": {
switch (current.i0) {
case OpCodes.OP_TRACED: {
this.pushStack(current)
curr = current.i1 as Primitive
break
}
case OpCodes.OP_DIE: {
const annotation = new Cause.StackAnnotation(
this.stackToLines(),
MRef.incrementAndGet(Cause.globalErrorSeq)
)
exit = TExit.die(current.i1(), annotation)
break
}
case OpCodes.OP_FAIL: {
const annotation = new internalCause.StackAnnotation(
this.stackToLines(),
MRef.incrementAndGet(Cause.globalErrorSeq)
)
const cont = this.nextFailure()
if (cont === undefined) {
exit = TExit.fail(current.i1(), annotation)
} else {
curr = cont.i2(current.i1()) as Primitive
}
break
}
case OpCodes.OP_RETRY: {
const cont = this.nextRetry()
if (cont === undefined) {
exit = TExit.retry
} else {
curr = cont.i2() as Primitive
}
break
}
case OpCodes.OP_INTERRUPT: {
const annotation = new Cause.StackAnnotation(
this.stackToLines(),
MRef.incrementAndGet(Cause.globalErrorSeq)
)
exit = TExit.interrupt(this.fiberId, annotation)
break
}
case OpCodes.OP_WITH_STM_RUNTIME: {
curr = current.i1(this as STMDriver<unknown, unknown, unknown>) as Primitive
break
}
case OpCodes.OP_ON_SUCCESS:
case OpCodes.OP_ON_FAILURE:
case OpCodes.OP_ON_RETRY: {
this.pushStack(current)
curr = current.i1 as Primitive
break
}
case OpCodes.OP_PROVIDE: {
const env = this.env
this.env = current.i2(env)
curr = pipe(
current.i1,
ensuring(sync(() => (this.env = env)))
) as Primitive
break
}
case OpCodes.OP_SUCCEED: {
const value = current.i1
const cont = this.nextSuccess()
if (cont === undefined) {
exit = TExit.succeed(value)
} else {
curr = cont.i2(value) as Primitive
}
break
}
case OpCodes.OP_SYNC: {
const value = current.i1()
const cont = this.nextSuccess()
if (cont === undefined) {
exit = TExit.succeed(value)
} else {
curr = cont.i2(value) as Primitive
}
break
}
}
break
}
case OpCodes.OP_SYNC: {
const value = current.i1()
const cont = this.nextSuccess()
if (cont === undefined) {
exit = TExit.succeed(value)
} else {
curr = cont.i2(value) as Primitive
}
break
}
}

@@ -621,0 +645,0 @@ }

@@ -555,2 +555,10 @@ import * as Chunk from "@effect/data/Chunk"

const adapter = function() {
let x = arguments[0]
for (let i = 1; i < arguments.length; i++) {
x = arguments[i](x)
}
return new STMGen(x) as any
}
/**

@@ -563,3 +571,3 @@ * Inspired by https://github.com/tusharmath/qio/pull/22 (revised)

suspend(() => {
const iterator = f((self) => new STMGen(self) as any)
const iterator = f(adapter)
const state = restore(() => iterator.next())()

@@ -566,0 +574,0 @@ const run = (

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 not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc