Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/util-actor

Package Overview
Dependencies
Maintainers
16
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/util-actor - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0-alpha.0

6

CHANGELOG.md
# @onflow/util-actor
## 1.1.0-alpha.0
### Minor Changes
- [#1243](https://github.com/onflow/fcl-js/pull/1243) [`4ec2bdc9`](https://github.com/onflow/fcl-js/commit/4ec2bdc9805ac081bdc8003b6e1ea52e02d3909d) Thanks [@jribbink](https://github.com/jribbink)! - Add error handling to actors. Second argument of callback is now an error object and fatal errors can be thrown with ctx.fatalError(e).
## 1.0.1

@@ -4,0 +10,0 @@

23

dist/actor.js

@@ -434,3 +434,4 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

subs: new Set(),
kvs: {}
kvs: {},
error: null
};

@@ -514,2 +515,11 @@ var ctx = {

});
},
fatalError: function fatalError(error) {
root.FCL_REGISTRY[addr].error = error;
for (var _iterator2 = _createForOfIteratorHelperLoose(root.FCL_REGISTRY[addr].subs), _step2; !(_step2 = _iterator2()).done;) {
var to = _step2.value;
_send(to, UPDATED);
}
}

@@ -549,2 +559,4 @@ };

return Promise.resolve(ctx.receive()).then(function (letter) {
var error = root.FCL_REGISTRY[address].error;
if (letter.tag === EXIT) {

@@ -556,3 +568,10 @@ ctx.send(address, UNSUBSCRIBE);

callback(letter.data);
if (error) {
callback(null, error);
ctx.send(address, UNSUBSCRIBE);
_exit2 = 1;
return;
}
callback(letter.data, null);
});

@@ -559,0 +578,0 @@ }));

@@ -98,3 +98,4 @@ import queueMicrotask from 'queue-microtask';

subs: new Set(),
kvs: {}
kvs: {},
error: null
};

@@ -148,2 +149,7 @@ const ctx = {

Object.keys(data).forEach(key => root.FCL_REGISTRY[addr].kvs[key] = data[key]);
},
fatalError: error => {
root.FCL_REGISTRY[addr].error = error;
for (let to of root.FCL_REGISTRY[addr].subs) send(to, UPDATED);
}

@@ -174,2 +180,3 @@ };

const letter = await ctx.receive();
const error = root.FCL_REGISTRY[address].error;

@@ -181,3 +188,9 @@ if (letter.tag === EXIT) {

callback(letter.data);
if (error) {
callback(null, error);
ctx.send(address, UNSUBSCRIBE);
return;
}
callback(letter.data, null);
}

@@ -184,0 +197,0 @@ });

@@ -432,3 +432,4 @@ import queueMicrotask from 'queue-microtask';

subs: new Set(),
kvs: {}
kvs: {},
error: null
};

@@ -512,2 +513,11 @@ var ctx = {

});
},
fatalError: function fatalError(error) {
root.FCL_REGISTRY[addr].error = error;
for (var _iterator2 = _createForOfIteratorHelperLoose(root.FCL_REGISTRY[addr].subs), _step2; !(_step2 = _iterator2()).done;) {
var to = _step2.value;
_send(to, UPDATED);
}
}

@@ -547,2 +557,4 @@ };

return Promise.resolve(ctx.receive()).then(function (letter) {
var error = root.FCL_REGISTRY[address].error;
if (letter.tag === EXIT) {

@@ -554,3 +566,10 @@ ctx.send(address, UNSUBSCRIBE);

callback(letter.data);
if (error) {
callback(null, error);
ctx.send(address, UNSUBSCRIBE);
_exit2 = 1;
return;
}
callback(letter.data, null);
});

@@ -557,0 +576,0 @@ }));

@@ -437,3 +437,4 @@ (function (global, factory) {

subs: new Set(),
kvs: {}
kvs: {},
error: null
};

@@ -517,2 +518,11 @@ var ctx = {

});
},
fatalError: function fatalError(error) {
root.FCL_REGISTRY[addr].error = error;
for (var _iterator2 = _createForOfIteratorHelperLoose(root.FCL_REGISTRY[addr].subs), _step2; !(_step2 = _iterator2()).done;) {
var to = _step2.value;
_send(to, UPDATED);
}
}

@@ -552,2 +562,4 @@ };

return Promise.resolve(ctx.receive()).then(function (letter) {
var error = root.FCL_REGISTRY[address].error;
if (letter.tag === EXIT) {

@@ -559,3 +571,10 @@ ctx.send(address, UNSUBSCRIBE);

callback(letter.data);
if (error) {
callback(null, error);
ctx.send(address, UNSUBSCRIBE);
_exit2 = 1;
return;
}
callback(letter.data, null);
});

@@ -562,0 +581,0 @@ }));

2

package.json
{
"name": "@onflow/util-actor",
"version": "1.0.1",
"version": "1.1.0-alpha.0",
"description": "A mechanism for forcing order/transitions of scoped async state",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -63,21 +63,23 @@ import {mailbox as createMailbox} from "./mailbox"

const fromHandlers = (handlers = {}) => async ctx => {
if (typeof handlers[INIT] === "function") await handlers[INIT](ctx)
__loop: while (1) {
const letter = await ctx.receive()
try {
if (letter.tag === EXIT) {
if (typeof handlers[TERMINATE] === "function") {
await handlers[TERMINATE](ctx, letter, letter.data || {})
const fromHandlers =
(handlers = {}) =>
async ctx => {
if (typeof handlers[INIT] === "function") await handlers[INIT](ctx)
__loop: while (1) {
const letter = await ctx.receive()
try {
if (letter.tag === EXIT) {
if (typeof handlers[TERMINATE] === "function") {
await handlers[TERMINATE](ctx, letter, letter.data || {})
}
break __loop
}
break __loop
await handlers[letter.tag](ctx, letter, letter.data || {})
} catch (error) {
console.error(`${ctx.self()} Error`, letter, error)
} finally {
continue __loop
}
await handlers[letter.tag](ctx, letter, letter.data || {})
} catch (error) {
console.error(`${ctx.self()} Error`, letter, error)
} finally {
continue __loop
}
}
}

@@ -93,2 +95,3 @@ export const spawn = (fn, addr = null) => {

kvs: {},
error: null,
}

@@ -146,2 +149,6 @@

},
fatalError: error => {
root.FCL_REGISTRY[addr].error = error
for (let to of root.FCL_REGISTRY[addr].subs) send(to, UPDATED)
},
}

@@ -174,2 +181,3 @@

const letter = await ctx.receive()
const error = root.FCL_REGISTRY[address].error
if (letter.tag === EXIT) {

@@ -179,3 +187,9 @@ ctx.send(address, UNSUBSCRIBE)

}
callback(letter.data)
if (error) {
callback(null, error)
ctx.send(address, UNSUBSCRIBE)
return
}
callback(letter.data, null)
}

@@ -182,0 +196,0 @@ })

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

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