Skip to content

Commit d9a9e55

Browse files
authored
Merge pull request #62 from bjornstar/1.0.0-beta.5
1.0.0-beta.5 - 2017-02-07
2 parents d8788b1 + 6f99dfc commit d9a9e55

File tree

6 files changed

+76
-3
lines changed

6 files changed

+76
-3
lines changed

.jshintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"proto": true
3+
}

HISTORY.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#Tomes Release Notes
22

3+
##1.0.0-beta.5
4+
* Tomes now have a destroy method
5+
* Add .jshintrc and run on tests
6+
37
##1.0.0-beta.4
48
* Update `README.md` to fix first link
59

610
##1.0.0-beta.3
7-
* Update `README.md` to point to this fork.
11+
* Update `README.md` to point to this fork
812

913
##1.0.0-beta.2
1014
* Tomes now have an unTome method

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ Get all change operations from the Tome
102102
###merge( *diff* )
103103
Applies a change operation or an array of change operations to a Tome.
104104

105+
###destroy( )
106+
Makes the tome and all of it's sub-tomes emit destroy. Does not delete anything.
107+
105108
###unTome( )
106109
Returns a regular javascript version of your Tome.
107110

index.js

+4
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ Tome.prototype.unTome = function () {
630630
return Tome.unTome(this);
631631
};
632632

633+
Tome.prototype.destroy = function () {
634+
return Tome.destroy(this);
635+
};
636+
633637
Tome.prototype.set = function (key, val) {
634638

635639
// We use this to set a property on a Tome to the specified value. This can

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "@bjornstar/tomes",
33
"description": "Evented Storage Agnostic Data API",
4-
"version": "1.0.0-beta.4",
4+
"version": "1.0.0-beta.5",
55
"author": "Bjorn Stromberg <[email protected]>",
66
"maintainers": [
77
{ "name": "Bjorn Stromberg", "email": "[email protected]" }
88
],
99
"scripts": {
10-
"test": "node test"
10+
"test": "jshint index.js && node test"
1111
},
1212
"main": "index.js",
1313
"devDependencies": {

test/modules/destroy.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var Tome = require('../..');
2+
3+
exports.testSelfDestroy = function (test) {
4+
test.expect(5);
5+
6+
var a = { b: { c: 1 }, d: { e: 1} };
7+
var b = Tome.conjure(a);
8+
9+
function fail() {
10+
test.ok();
11+
}
12+
13+
function ok() {
14+
test.ok(true);
15+
}
16+
17+
b.on('readable', fail);
18+
19+
b.on('destroy', ok);
20+
b.b.on('destroy', ok);
21+
b.b.c.on('destroy', ok);
22+
b.d.on('destroy', ok);
23+
b.d.e.on('destroy', ok);
24+
25+
b.destroy();
26+
// Calling a 2nd time shouldn't have any effect.
27+
b.destroy();
28+
29+
test.done();
30+
};
31+
32+
exports.testTomeDestroy = function (test) {
33+
test.expect(5);
34+
35+
var a = { b: { c: 1 }, d: { e: 1} };
36+
var b = Tome.conjure(a);
37+
38+
function fail() {
39+
test.ok();
40+
}
41+
42+
function ok() {
43+
test.ok(true);
44+
}
45+
46+
b.on('readable', fail);
47+
48+
b.on('destroy', ok);
49+
b.b.on('destroy', ok);
50+
b.b.c.on('destroy', ok);
51+
b.d.on('destroy', ok);
52+
b.d.e.on('destroy', ok);
53+
54+
Tome.destroy(b);
55+
// Calling a 2nd time shouldn't have any effect.
56+
Tome.destroy(b);
57+
58+
test.done();
59+
};

0 commit comments

Comments
 (0)