Comparing version 0.3.3 to 0.4.0
@@ -10,3 +10,2 @@ // Copyright 2012 The Obvious Corporation. | ||
var iterate = require("./iterate"); | ||
var type = require("./type"); | ||
var serial = require("./serial"); | ||
@@ -26,4 +25,3 @@ | ||
serialize: serial.serialize, | ||
serializeNoHead: serial.serializeNoHead, | ||
type: type | ||
serializeNoHead: serial.serializeNoHead | ||
}; |
@@ -13,3 +13,3 @@ // Copyright 2012 The Obvious Corporation. | ||
var type = require("./type"); | ||
var typ = require("typ"); | ||
@@ -86,7 +86,7 @@ | ||
function write(buf, offset, length) { | ||
type.assertBuffer(buf); | ||
offset = type.isDefined(offset) ? offset : 0; | ||
length = type.isDefined(length) ? length : buf.length; | ||
type.assertUint(offset); | ||
type.assertUint(length); | ||
typ.assertBuffer(buf); | ||
offset = typ.isDefined(offset) ? offset : 0; | ||
length = typ.isDefined(length) ? length : buf.length; | ||
typ.assertUint(offset); | ||
typ.assertUint(length); | ||
@@ -147,5 +147,5 @@ var bufLength = buf.length; | ||
function createReader(input, at) { | ||
type.assertBuffer(input); | ||
at = type.isDefined(at) ? at : 0; | ||
type.assertUint(at); | ||
typ.assertBuffer(input); | ||
at = typ.isDefined(at) ? at : 0; | ||
typ.assertUint(at); | ||
@@ -164,7 +164,7 @@ var origAt = at; | ||
function read(buf, offset, length) { | ||
type.assertBuffer(buf); | ||
offset = type.isDefined(offset) ? offset : 0; | ||
length = type.isDefined(length) ? length : buf.length; | ||
type.assertUint(offset); | ||
type.assertUint(length); | ||
typ.assertBuffer(buf); | ||
offset = typ.isDefined(offset) ? offset : 0; | ||
length = typ.isDefined(length) ? length : buf.length; | ||
typ.assertUint(offset); | ||
typ.assertUint(length); | ||
@@ -171,0 +171,0 @@ var bufLength = buf.length; |
@@ -13,3 +13,3 @@ // Copyright 2012 The Obvious Corporation. | ||
var type = require("./type"); | ||
var typ = require("typ"); | ||
@@ -64,8 +64,8 @@ | ||
switch (typeof x) { | ||
case type.BOOLEAN: visitor.visitBoolean(x); break; | ||
case type.NUMBER: visitor.visitNumber(x); break; | ||
case type.UNDEFINED: visitor.visitUndefined(); break; | ||
case type.STRING: visitor.visitString(x); break; | ||
case type.FUNCTION: visitFunction(x); break; | ||
case type.OBJECT: visitObject(x); break; | ||
case typ.BOOLEAN: visitor.visitBoolean(x); break; | ||
case typ.NUMBER: visitor.visitNumber(x); break; | ||
case typ.UNDEFINED: visitor.visitUndefined(); break; | ||
case typ.STRING: visitor.visitString(x); break; | ||
case typ.FUNCTION: visitFunction(x); break; | ||
case typ.OBJECT: visitObject(x); break; | ||
default: { | ||
@@ -78,3 +78,3 @@ throw new Error("Unknown value type: " + (typeof x)); | ||
function visitFunction(x) { | ||
if (Object.getPrototypeOf(x) !== type.FUNCTION_PROTOTYPE) { | ||
if (Object.getPrototypeOf(x) !== typ.FUNCTION_PROTOTYPE) { | ||
throw new Error("Invalid function prototype."); | ||
@@ -110,3 +110,3 @@ } | ||
if (proto === type.OBJECT_PROTOTYPE) { | ||
if (proto === typ.OBJECT_PROTOTYPE) { | ||
visitObjectBindings(x); | ||
@@ -122,3 +122,3 @@ } else { | ||
function visitArray(x) { | ||
if (Object.getPrototypeOf(x) !== type.ARRAY_PROTOTYPE) { | ||
if (Object.getPrototypeOf(x) !== typ.ARRAY_PROTOTYPE) { | ||
throw new Error("Invalid array prototype."); | ||
@@ -161,3 +161,3 @@ } | ||
var missing = | ||
type.isUndefined(innerValue) && !type.hasOwnProperty(x, i); | ||
typ.isUndefined(innerValue) && !typ.hasOwnProperty(x, i); | ||
@@ -164,0 +164,0 @@ visitor.visitArrayElement(x, i, innerValue, innerVisitor, |
@@ -15,6 +15,6 @@ // Copyright 2012 The Obvious Corporation. | ||
var oid = require("oid"); | ||
var typ = require("typ"); | ||
var bufutil = require("./bufutil"); | ||
var iterate = require("./iterate"); | ||
var type = require("./type"); | ||
@@ -113,5 +113,5 @@ | ||
if (type.hasOwnProperty(replacement, "data")) { | ||
if (typ.hasOwnProperty(replacement, "data")) { | ||
result = { style: HOLE_DATA, obj: replacement.data }; | ||
} else if (type.hasOwnProperty(replacement, "value")) { | ||
} else if (typ.hasOwnProperty(replacement, "value")) { | ||
result = { style: HOLE_VALUE, obj: replacement.value }; | ||
@@ -136,3 +136,3 @@ } else { | ||
function findBackRefsAndHoles(root, holeFilter) { | ||
var allowHoles = type.isDefined(holeFilter); | ||
var allowHoles = typ.isDefined(holeFilter); | ||
var allRefs = oid.createMap(); | ||
@@ -186,3 +186,3 @@ var holes = allowHoles ? oid.createMap() : undefined; | ||
} else { | ||
addRef(obj, innerVisitor, !type.isMap(obj)); | ||
addRef(obj, innerVisitor, !typ.isMap(obj)); | ||
} | ||
@@ -333,3 +333,3 @@ } | ||
if (type.isUndefined(index)) { | ||
if (typ.isUndefined(index)) { | ||
// First time this value has been encountered. Add a | ||
@@ -387,3 +387,3 @@ // backref definition type tag, and then return false | ||
if (type.hasDefaultPrototype(obj)) { | ||
if (typ.hasDefaultPrototype(obj)) { | ||
// Header: Type tag and total number of keys. | ||
@@ -749,3 +749,3 @@ writeType(MAP_TYPE); | ||
function readHole(defRef) { | ||
if (type.isUndefined(holeFiller)) { | ||
if (typ.isUndefined(holeFiller)) { | ||
throw new Error("Hole-ful graph, but no hole filler."); | ||
@@ -752,0 +752,0 @@ } |
{ | ||
"name": "bidar", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"keywords": | ||
@@ -33,3 +33,4 @@ ["object", "serialization", "data", "graph"], | ||
"dependencies": { | ||
"oid": "~0.4.5" | ||
"oid": "~0.4.5", | ||
"typ": "~0.5.1" | ||
}, | ||
@@ -36,0 +37,0 @@ |
@@ -300,10 +300,3 @@ Bidar: Binary Data Representation. | ||
### type | ||
This is a sub-module that contains convenient utilities for type | ||
determination and related assertions. The author does not particularly | ||
recommend the use of this module. It may drastically change over time, | ||
or may simply disappear. | ||
Building and Installing | ||
@@ -310,0 +303,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
95329
2
2293
372
+ Addedtyp@~0.5.1
+ Addedtyp@0.5.4(transitive)