Comparing version 0.3.1 to 0.3.3
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.10.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var AryaMemory, NO_ERROR, |
@@ -1,14 +0,14 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.10.0 | ||
(function() { | ||
var Arya, NO_ERROR, RANGLE, TIME_TAG_RE, TYPE_TAG, TYPE_TAG_RE, UUID_RE, UUID_TAG_RE, crypto; | ||
crypto = require('crypto'); | ||
crypto = require("crypto"); | ||
NO_ERROR = null; | ||
RANGLE = '»'; | ||
RANGLE = "»"; | ||
TIME_TAG_RE = /^»[0-9]+$/; | ||
TYPE_TAG = RANGLE + 'type'; | ||
TYPE_TAG = RANGLE + "type"; | ||
@@ -39,3 +39,3 @@ TYPE_TAG_RE = /^»type$/; | ||
var NEW_CONTEXT; | ||
if ((obj == null) || ((typeof obj) !== 'object') || (obj instanceof Array)) { | ||
if ((obj == null) || ((typeof obj) !== "object") || (obj instanceof Array)) { | ||
return next(new Error("cannot save " + obj)); | ||
@@ -57,3 +57,3 @@ } | ||
type = obj.constructor.name; | ||
if (type !== 'Object' && type.length > 0) { | ||
if (type !== "Object" && type.length > 0) { | ||
dObj[TYPE_TAG] = type; | ||
@@ -110,3 +110,3 @@ } | ||
return function(err, json) { | ||
var dObj, rObjCons; | ||
var dObj, error, parseException, rObjCons; | ||
if (err != null) { | ||
@@ -118,3 +118,8 @@ return next(err); | ||
} | ||
dObj = JSON.parse(json); | ||
try { | ||
dObj = JSON.parse(json); | ||
} catch (error) { | ||
parseException = error; | ||
return next(parseException); | ||
} | ||
dObj.uuid = uuid; | ||
@@ -126,6 +131,10 @@ if (dObj instanceof Array) { | ||
rObjCons = _this._constructors[dObj[TYPE_TAG]]; | ||
if (rObjCons.__proxy) { | ||
context[uuid] = rObjCons(dObj, json, uuid, context); | ||
if (rObjCons != null) { | ||
if (rObjCons.__proxy) { | ||
context[uuid] = rObjCons(dObj, json, uuid, context); | ||
} else { | ||
context[uuid] = new rObjCons(); | ||
} | ||
} else { | ||
context[uuid] = new rObjCons(); | ||
return next(new Error("Unregistered constructor " + dObj[TYPE_TAG])); | ||
} | ||
@@ -132,0 +141,0 @@ } else { |
{ | ||
"name": "sansa", | ||
"version": "0.3.1", | ||
"version": "0.3.3", | ||
"description": "Object graph serialization library.", | ||
@@ -31,7 +31,7 @@ "keywords": [ | ||
"devDependencies": { | ||
"coffee-script": "1.9.1", | ||
"istanbul": "0.3.13", | ||
"mocha": "2.2.1", | ||
"should": "5.2.0" | ||
"coffee-script": "1.10.0", | ||
"istanbul": "0.4.2", | ||
"mocha": "2.4.5", | ||
"should": "8.2.2" | ||
} | ||
} |
# sansa | ||
Object graph serialization library in CoffeeScript for Node.js | ||
Object graph serialization library for Node.js, written in CoffeeScript. | ||
@@ -57,2 +57,4 @@ ## Motivation | ||
Example: | ||
mem.input('a94beae2-881e-4e26-9fb4-de4f0f478abf', function(err, json) { | ||
@@ -73,2 +75,4 @@ if(err != null) { | ||
Example: | ||
mem.output('a94beae2-881e-4e26-9fb4-de4f0f478abf', '{}', function(err) { | ||
@@ -103,2 +107,4 @@ if(err != null) { | ||
Example: | ||
arya.load('a94beae2-881e-4e26-9fb4-de4f0f478abf', mem.input, function(err, obj) { | ||
@@ -123,2 +129,5 @@ if(err != null) { | ||
As of sansa v0.3.2, failure to register a constructor that is necessary for | ||
deserialization will be passed as an error. (Thanks to @qbradq) | ||
If there are no special conditions, and a simple no-argument call to new | ||
@@ -181,2 +190,4 @@ will suffice, then you can just pass the constructor itself to Arya. sansa | ||
Example: | ||
arya.save({ name: "Bob" }, mem.output, function(err, uuid) { | ||
@@ -279,3 +290,4 @@ if(err != null) { | ||
## License | ||
sansa is Copyright 2015 Patrick Meade. | ||
sansa | ||
Copyright 2015-2016 Patrick Meade. | ||
@@ -292,3 +304,4 @@ This program is free software: you can redistribute it and/or modify | ||
You should have received a copy of the [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.txt) | ||
You should have received a copy of the | ||
[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.txt) | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
54168
231
301