<commit_before>"use strict";

var CSLEDIT = CSLEDIT || {};

/* Uses CSLEDIT.storage to store current csl data object
 *
 * Supports the following actions:
 * - New style
 * - Load from CSL XML
 * - Add node
 * - Delete node
 * - Amend node
 */

CSLEDIT.Data = function (CSL_DATA, /*optional*/ _requiredNodes) {
	var viewControllers = [],
		callbacksEnabled = true,
		requiredNodes = _requiredNodes || [
			"style/info",
			"style/citation/layout",
			"style/bibliography/layout"
		];

	var get = function () {
		return CSLEDIT.storage.getItemJson(CSL_DATA);
	};

	var set = function (cslData) {
		// update 'style/info/updated'
		var updatedNode = getNodesFromPath('style/info/updated')[0],
			iter,
			index,
			node;

		if (typeof(updatedNode) === "undefined") {
			console.log("no style/info/updated node: resetting CSL code");<commit_msg>fix regression when calling CSLEDIT.data.set() for the first time with empty localStorage<commit_after>"use strict";

var CSLEDIT = CSLEDIT || {};

/* Uses CSLEDIT.storage to store current csl data object
 *
 * Supports the following actions:
 * - New style
 * - Load from CSL XML
 * - Add node
 * - Delete node
 * - Amend node
 */

CSLEDIT.Data = function (CSL_DATA, /*optional*/ _requiredNodes) {
	var viewControllers = [],
		callbacksEnabled = true,
		requiredNodes = _requiredNodes || [
			"style/info",
			"style/citation/layout",
			"style/bibliography/layout"
		];

	var get = function () {
		return CSLEDIT.storage.getItemJson(CSL_DATA);
	};

	var set = function (cslData) {
		// update 'style/info/updated'
		var updatedNode = getNodesFromPath('style/info/updated', cslData)[0],
			iter,
			index,
			node;

		if (typeof(updatedNode) === "undefined") {
			console.log("no style/info/updated node: resetting CSL code");
{'fraction_non_alphanumeric': 0.1362351611079706, 'fraction_numerical': 0.0011305822498586771, 'mean_word_length': 3.6214099216710185, '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': '3657319', 'n_tokens_mistral': 628, 'n_tokens_neox': 574, 'n_words': 149}