Comparing version 0.2.0 to 0.2.1
13
nrrd.js
@@ -425,6 +425,6 @@ "use strict"; | ||
value.forEach(function (vec) { | ||
assert(vec.length === spaceDimension, "The elements of field " + prop + " should be lists with length equal to the space dimension!"); | ||
vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); }); | ||
assert(vec === null || (vec.length !== undefined && vec.length === spaceDimension), "The elements of field " + prop + " should be lists with length equal to the space dimension!"); | ||
if (vec !== null) vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); }); | ||
}); | ||
line = propNRRD + ": " + value.map(function(vec) { return "(" + vec.join(",") + ")"; }).join(" "); | ||
line = propNRRD + ": " + value.map(function(vec) { return vec === null ? "none" : ("(" + vec.join(",") + ")"); }).join(" "); | ||
break; | ||
@@ -435,6 +435,6 @@ // Lists of vectors (space dimension sized) | ||
value.forEach(function (vec) { | ||
assert(vec.length === spaceDimension, "The elements of field " + prop + " should be lists with length equal to the space dimension!"); | ||
vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); }); | ||
assert(vec === null || (vec.length !== undefined && vec.length === spaceDimension), "The elements of field " + prop + " should be lists with length equal to the space dimension!"); | ||
if (vec !== null) vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); }); | ||
}); | ||
line = propNRRD + ": " + value.map(function(vec) { return "(" + vec.join(",") + ")"; }).join(" "); | ||
line = propNRRD + ": " + value.map(function(vec) { return vec === null ? "none" : ("(" + vec.join(",") + ")"); }).join(" "); | ||
break; | ||
@@ -619,2 +619,3 @@ // One-of-a-kind fields | ||
function parseNRRDVector(str) { | ||
if (str == "none") return null; | ||
if (str.length<2 || str[0]!=="(" || str[str.length-1]!==")") throw new Error("Malformed NRRD vector: " + str); | ||
@@ -621,0 +622,0 @@ return str.slice(1, -1).split(",").map(parseNRRDFloat); |
{ | ||
"name": "nrrd-js", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Handling NRRD files in Javascript.", | ||
@@ -5,0 +5,0 @@ "main": "nrrd.js", |
14
test.js
@@ -59,15 +59,17 @@ var test = require('tape'); | ||
t.equal(file.type, 'uint8'); | ||
t.equal(file.dimension, 3); | ||
t.equal(file.sizes.length, 3); | ||
t.equal(file.dimension, 4); | ||
t.equal(file.sizes.length, 4); | ||
t.equal(file.sizes[0], 4); | ||
t.equal(file.sizes[1], 3); | ||
t.equal(file.sizes[2], 2); | ||
t.equal(file.sizes[3], 2); | ||
t.equal(file.space, "right-anterior-superior"); | ||
t.ok(arrayEqual(file.spaceOrigin, [1.0,2.0,3.0]), "spaceOrigin should be equal to [1.0,2.0,3.0]"); | ||
t.ok(arrayEqual(file.spaceDirections, [[1.0,0.0,0.0],[0,0.5,0],[0,0,0.3]]), "spaceDirections should be equal to [[1.0,0,0],...]"); | ||
t.equal(file.data.length, 4*3*2); | ||
t.equal(file.data.byteLength, 4*3*2); | ||
t.ok(arrayEqual(file.spaceDirections, [[1.0,0.0,0.0],[0,0.5,0],[0,0,0.3],null]), "spaceDirections should be equal to [[1.0,0,0],...]"); | ||
t.equal(file.data.length, 4*3*2*2); | ||
t.equal(file.data.byteLength, 4*3*2*2); | ||
for(i=0; i<list.length; i++) { | ||
t.equal(file.data[i], list[i]); | ||
t.equal(file.data[i+list.length], list[i]); | ||
} | ||
@@ -121,3 +123,3 @@ | ||
for(var i=0; i<a.length; i++) { | ||
if (a[i].length !== undefined) { | ||
if (a[i] instanceof Array) { | ||
if (!arrayEqual(a[i],b[i])) return false; | ||
@@ -124,0 +126,0 @@ } else { |
Sorry, the diff of this file is not supported yet
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
840029
1303