Skip to content

Commit

Permalink
Made fixes to default de/encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
ncthbrt committed Mar 7, 2018
1 parent 146a40a commit a82fd4b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion .bsb.lock

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reason-nact",
"version": "2.0.0",
"version": "2.0.1",
"description": "let reason-nact = (node.js, reason, actors) ⇒ your µ services have never been so typed",
"repository": "https://github.com/ncthbrt/reason-nact",
"author": "Nick Cuthbert (https://github.com/ncthbrt)",
Expand Down
7 changes: 4 additions & 3 deletions src/Nact.re
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type systemMsg;
var WrappedVariant = '_wvariant';
var WrappedEvent = '_wevent';
function unsafeEncoder(obj) {
var serialized = JSON.stringify(obj, function (key, value) {
var data = JSON.stringify(obj, function (key, value) {
if (value && Array.isArray(value) && value.tag !== undefined) {
var r = {};
r.values = value.slice();
Expand All @@ -45,12 +45,13 @@ function unsafeEncoder(obj) {
return value;
}
});
return { serialized, type: WrappedEvent };
return { data: JSON.parse(data), type: WrappedEvent };
};
function unsafeDecoder(result) {
if(result && typeof(result) === 'object' && result.type === WrappedEvent) {
return JSON.parse(result.serialized, (key, value) => {
var serialized = result.serialized || JSON.stringify(result.data);
return JSON.parse(serialized, (key, value) => {
if (value && typeof (value) === 'object' && value.type === WrappedVariant) {
var values = value.values;
values.tag = value.tag;
Expand Down

0 comments on commit a82fd4b

Please sign in to comment.