Comparing version 0.1.2 to 0.2.0
@@ -0,1 +1,11 @@ | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/cheminfo-js/mzMLjs/compare/v0.1.2...v0.2.0) (2017-07-03) | ||
### Features | ||
* **mzData:** handle empty data tag ([9f7b8d7](https://github.com/cheminfo-js/mzMLjs/commit/9f7b8d7)) | ||
<a name="0.1.1"></a> | ||
@@ -2,0 +12,0 @@ ## [0.1.1](https://github.com/cheminfo-js/mzMLjs/compare/v0.1.0...v0.1.1) (2017-07-03) |
@@ -28,3 +28,3 @@ 'use strict'; | ||
* @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data | ||
* @return {{times: Array<number>, series: { ms:Array<Array<number>>}}} | ||
* @return {{times: Array<number>, series: { ms: { data:Array<Array<number>>}}}} | ||
*/ | ||
@@ -66,8 +66,11 @@ function mzData(data) { | ||
case 'data': | ||
if (binaryData.serie === 'mz') { | ||
binaryData = node.attributes; | ||
binaryData.serie = 'mz'; | ||
} else if (binaryData.serie === 'int') { | ||
binaryData = node.attributes; | ||
binaryData.serie = 'int'; | ||
if (node.isSelfClosing) { | ||
if (binaryData.serie === 'mz') { | ||
mz.push([]); | ||
} else if (binaryData.serie === 'int') { | ||
int.push([]); | ||
} | ||
binaryData = {}; | ||
} else if (binaryData.serie) { | ||
binaryData.precision = node.attributes.precision; | ||
} | ||
@@ -96,3 +99,4 @@ break; | ||
result.series.ms = mergeSeries(mz, int); | ||
result.series.ms = {}; | ||
result.series.ms.data = mergeSeries(mz, int); | ||
return result; | ||
@@ -99,0 +103,0 @@ } |
{ | ||
"name": "mzmjs", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Read and explore mzML files", | ||
@@ -18,3 +18,3 @@ "main": "lib/index.js", | ||
"testonly": "jest", | ||
"build": "cheminfo build" | ||
"build": "rollup -c && cheminfo build" | ||
}, | ||
@@ -21,0 +21,0 @@ "repository": { |
import {mzData} from '..'; | ||
import {readFileSync} from 'fs'; | ||
const pathFiles = __dirname + '/../../testFiles/'; | ||
const pathFiles = __dirname + '/../../testFiles/mzData/'; | ||
@@ -10,6 +10,16 @@ describe('mzData', () => { | ||
expect(response.times).toEqual([5.8905, 5.944667]); | ||
expect(response.series.ms.length).toBe(2); | ||
expect(response.series.ms[0][0].length).toBe(1313); | ||
expect(response.series.ms[1][0].length).toBe(43); | ||
expect(response.series.ms.data.length).toBe(2); | ||
expect(response.series.ms.data[0][0].length).toBe(1313); | ||
expect(response.series.ms.data[1][0].length).toBe(43); | ||
}); | ||
it('read real file', () => { | ||
const data = readFileSync(pathFiles + '3-28-5.mzdata.xml'); | ||
var response = mzData(data); | ||
expect(response.times.length).toBe(3029); | ||
expect(response.series.ms.data.length).toBe(3029); | ||
expect(response.series.ms.data[0][0].length).toBe(62); | ||
expect(response.series.ms.data[1][0].length).toBe(1); | ||
expect(response.series.ms.data[2][0].length).toBe(0); | ||
}); | ||
}); |
@@ -7,3 +7,3 @@ import {parser} from 'sax'; | ||
* @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data | ||
* @return {{times: Array<number>, series: { ms:Array<Array<number>>}}} | ||
* @return {{times: Array<number>, series: { ms: { data:Array<Array<number>>}}}} | ||
*/ | ||
@@ -45,8 +45,11 @@ export function mzData(data) { | ||
case 'data': | ||
if (binaryData.serie === 'mz') { | ||
binaryData = node.attributes; | ||
binaryData.serie = 'mz'; | ||
} else if (binaryData.serie === 'int') { | ||
binaryData = node.attributes; | ||
binaryData.serie = 'int'; | ||
if (node.isSelfClosing) { | ||
if (binaryData.serie === 'mz') { | ||
mz.push([]); | ||
} else if (binaryData.serie === 'int') { | ||
int.push([]); | ||
} | ||
binaryData = {}; | ||
} else if (binaryData.serie) { | ||
binaryData.precision = node.attributes.precision; | ||
} | ||
@@ -75,4 +78,5 @@ break; | ||
result.series.ms = mergeSeries(mz, int); | ||
result.series.ms = {}; | ||
result.series.ms.data = mergeSeries(mz, int); | ||
return result; | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
10534
203
0