move loop to function

This commit is contained in:
AJ ONeal 2014-06-17 20:11:50 -06:00
parent 3cad559617
commit 6539f8a153
1 changed files with 8 additions and 5 deletions

View File

@ -74,18 +74,17 @@ function parseBody(current, lines) {
function parseCertData(lines) {
var certs = []
, line
, current
, skipped = 0
, match
, finished
;
while (lines.length > 0) {
line = lines.shift();
function parseLine(line) {
// nuke whitespace and comments
if (line.match(/^#|^\s*$/)) continue;
if (line.match(/^#|^\s*$/)) {
return;
}
if (line.match(/^CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE/)) {
current = new Certificate();
@ -110,6 +109,10 @@ function parseCertData(lines) {
}
}
while (lines.length > 0) {
parseLine(lines.shift());
}
console.info("Skipped %s untrusted certificates.", skipped);
console.info("Processed %s certificates.", certs.length);