Comparing version 0.1.6 to 0.1.7
@@ -116,2 +116,3 @@ // Copyright 2012 The Obvious Corporation. | ||
var holes = oid.createMap(); | ||
allowHoles = false; | ||
holeSet.forEach(function (obj) { | ||
@@ -167,2 +168,4 @@ var replacement = holeFilter(obj); | ||
function visitFunction(x) { | ||
holeCheck(); | ||
var count = allRefs.get(x, 0) + 1; | ||
@@ -203,2 +206,3 @@ | ||
} else { | ||
holeCheck(); | ||
addHole(x); | ||
@@ -230,4 +234,12 @@ } | ||
function addHole(x) { | ||
holeSet.add(x); | ||
} | ||
/** | ||
* Check to see if holes are currently being allowed. If not, | ||
* complain appropriateley. | ||
*/ | ||
function holeCheck() { | ||
if (allowHoles) { | ||
holeSet.add(x); | ||
return; | ||
} else if (type.isUndefined(holeFilter)) { | ||
@@ -234,0 +246,0 @@ throw new Error("Hole-ful graph, but no hole filter."); |
{ | ||
"name": "bidar", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"keywords": | ||
@@ -5,0 +5,0 @@ ["object", "serialization", "data", "graph"], |
@@ -318,2 +318,35 @@ // Copyright 2012 The Obvious Corporation. | ||
function test_fail_hole() { | ||
var obj = { a: hole }; | ||
function hole() { | ||
return "holy!"; | ||
} | ||
function f1() { | ||
bidar.serialize(obj); | ||
} | ||
assert.throws(f1, /Hole-ful graph, but no hole filter/); | ||
function f2() { | ||
bidar.serialize(obj, filter); | ||
function filter(x) { | ||
// An arbitrary-but-different hole. | ||
return filter; | ||
} | ||
} | ||
assert.throws(f2, /Holes not allowed in holes/); | ||
function f3() { | ||
bidar.serialize(obj, filter); | ||
function filter(x) { | ||
// The same hole. | ||
return x; | ||
} | ||
} | ||
assert.throws(f3, /Holes not allowed in holes/); | ||
} | ||
function testLargeString() { | ||
@@ -392,2 +425,3 @@ var string1 = "abcdefg1234567890---THIS IS YOUR CAPTAIN SPEAKING---" + | ||
testInnerHole(); | ||
test_fail_hole(); | ||
testLargeString(); | ||
@@ -394,0 +428,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64193
1450