<commit_before>"use strict";

var forge = require("node-forge");

var APNCertificate = require("./APNCertificate");

function apnCertificateFromPem(certData) {
	if (!certData) {
		return null;
	}

	var pemMessages;
	try {
		pemMessages = forge.pem.decode(certData);
	}
	catch (e) {
		if (e.message.match("Invalid PEM formatted message.")) {
			throw new Error("unable to parse certificate, not a valid PEM file");
		}
	}
	var certificates = [];

	for(var i in pemMessages) {
		var certMessage = pemMessages[i];
		if (!certMessage.type.match(new RegExp("CERTIFICATE$"))) {
			continue;
		}
		var certAsn1 = forge.asn1.fromDer(certMessage.body);
		var forgeCertificate = forge.pki.certificateFromAsn1(certAsn1);

		certificates.push(new APNCertificate(forgeCertificate));
	}
	return certificates;
}

module.exports = apnCertificateFromPem;<commit_msg>Simplify with forEach instead of for..in<commit_after>"use strict";

var forge = require("node-forge");

var APNCertificate = require("./APNCertificate");

function apnCertificateFromPem(certData) {
	if (!certData) {
		return null;
	}

	var pemMessages;
	try {
		pemMessages = forge.pem.decode(certData);
	}
	catch (e) {
		if (e.message.match("Invalid PEM formatted message.")) {
			throw new Error("unable to parse certificate, not a valid PEM file");
		}
	}
	var certificates = [];

	pemMessages.forEach(function(message) {
		if (!message.type.match(new RegExp("CERTIFICATE$"))) {
			return;
		}
		var certAsn1 = forge.asn1.fromDer(message.body);
		var forgeCertificate = forge.pki.certificateFromAsn1(certAsn1);

		certificates.push(new APNCertificate(forgeCertificate));
	});
	return certificates;
}

module.exports = apnCertificateFromPem;
{'fraction_non_alphanumeric': 0.132309509746013, 'fraction_numerical': 0.004725339633786178, 'mean_word_length': 4.841379310344828, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7234102', 'n_tokens_mistral': 639, 'n_tokens_neox': 588, 'n_words': 122}