<commit_before>var registry = require('./registry');
var manifest = require('./manifest');

var exports = {};

// Recently updated packages //////////////////////////////////////////////////

function UpdatedPackage(name, version, previous) {
	this.name = name;
	this.version = version;
	this.previous = previous;
}

var recentlyUpdatedPackages = [];

registry.on('change', function (change) {
	console.log(change);
	var versions = Object.keys(change.doc.versions);

	if (versions.length < 2) {
		return;
	}

	var pkg = new UpdatedPackage(change.doc.name, versions[versions.length - 1], versions[versions.length - 2]);

	for (var i = 0; i < recentlyUpdatedPackages.length; i++) {
		if (recentlyUpdatedPackages[i].name === pkg.name) {
			recentlyUpdatedPackages.splice(i, 1);
			break;
		}
	}

	recentlyUpdatedPackages.unshift(pkg);
<commit_msg>Guard against doc with no versions field due to registry delete<commit_after>var registry = require('./registry');
var manifest = require('./manifest');

var exports = {};

// Recently updated packages //////////////////////////////////////////////////

function UpdatedPackage(name, version, previous) {
	this.name = name;
	this.version = version;
	this.previous = previous;
}

var recentlyUpdatedPackages = [];

registry.on('change', function (change) {
	if (!change.doc.versions) {
		return;
	}

	var versions = Object.keys(change.doc.versions);

	if (versions.length < 2) {
		return;
	}

	var pkg = new UpdatedPackage(change.doc.name, versions[versions.length - 1], versions[versions.length - 2]);

	for (var i = 0; i < recentlyUpdatedPackages.length; i++) {
		if (recentlyUpdatedPackages[i].name === pkg.name) {
			recentlyUpdatedPackages.splice(i, 1);
			break;
		}
	}

	recentlyUpdatedPackages.unshift(pkg);

{'fraction_non_alphanumeric': 0.1932916429789653, 'fraction_numerical': 0.005685048322910745, 'mean_word_length': 3.3564356435643563, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2153804', 'n_tokens_mistral': 563, 'n_tokens_neox': 516, 'n_words': 124}