Skip to content

Commit

Permalink
Merge pull request #61 from bjornstar/untome-self
Browse files Browse the repository at this point in the history
v1.0.0-beta.2
  • Loading branch information
bjornstar authored Nov 9, 2016
2 parents 0a10084 + 056513a commit 3bc6e29
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
11 changes: 11 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#Tomes Release Notes

##1.0.0-beta.2
* Tomes now have an unTome method
* Fix a few lint errors in tests

##1.0.0-beta.1
* Remove component.json
* Always use node events library
* Now available as @bjornstar/tomes
* Export Tome directly
* Put types on Tome itself

##0.1.0
* Removed the hide method, it was useless and only increased code complexity.
* Added nodei.co badge.
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@ Tome.prototype.getParent = function () {
return this.__parent__;
};

Tome.prototype.unTome = function () {
return Tome.unTome(this);
};

Tome.prototype.set = function (key, val) {

// We use this to set a property on a Tome to the specified value. This can
Expand Down Expand Up @@ -1337,7 +1341,7 @@ ArrayTome.prototype.rename = function () {
for (oldKey in rO) {
newKey = rO[oldKey];
if (!this.hasOwnProperty(oldKey)) {
throw new ReferenceError('ObjectTome.rename - Key is not defined: ' + oldKey);
throw new ReferenceError('ArrayTome.rename - Key is not defined: ' + oldKey);
}

this._arr[oldKey].__key__ = newKey;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@bjornstar/tomes",
"description": "Evented Storage Agnostic Data API",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"author": "Bjorn Stromberg <bjornstar@gmail.com>",
"maintainers": [
{ "name": "Bjorn Stromberg", "email": "bjornstar@gmail.com" }
Expand Down
4 changes: 2 additions & 2 deletions test/modules/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -1161,11 +1161,11 @@ exports.testCircularEntries = function (test) {
var circRefs = new CircularReference();

test.throws(function () {
var b = Tome.conjure(circRefs);
Tome.conjure(circRefs);
}, TypeError);

test.throws(function () {
var b = Tome.conjure([ circRefs ]);
Tome.conjure([ circRefs ]);
}, TypeError);

var a = [ null, null, null, null ];
Expand Down
4 changes: 2 additions & 2 deletions test/modules/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ exports.testCircularReferences = function (test) {
var circRefs = new CircularReferences();

test.throws(function () {
var b = Tome.conjure(circRefs);
Tome.conjure(circRefs);
}, TypeError, 'expected a TypeError');

test.throws(function () {
var b = Tome.conjure({ a: circRefs });
Tome.conjure({ a: circRefs });
}, TypeError, 'expected a TypeError');

var a = { b: 1 };
Expand Down
18 changes: 16 additions & 2 deletions test/modules/untome.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ exports.unTomeComplex = function (test) {

exports.unTomeRepeated = function (test) {
test.expect(1);

var a = [ undefined, undefined, undefined, undefined ];

test.doesNotThrow(function () {
var b = Tome.unTome(a);
Tome.unTome(a);
});

test.done();
};

Expand All @@ -86,8 +89,19 @@ exports.unTomeCircularReference = function (test) {
var circRefs = new CircularReference();

test.throws(function () {
var b = Tome.unTome(circRefs);
Tome.unTome(circRefs);
}, TypeError, 'expected a TypeError');

test.done();
};

exports.unTomeSelf = function (test) {
test.expect(1);

var a = { a: '1', b: false, c: null, d: 1234.5667 };
var b = Tome.conjure(a);

test.strictEqual(trueName(a), trueName(b.unTome()));

test.done();
};

0 comments on commit 3bc6e29

Please sign in to comment.