<commit_before>(function(window, factory) {
	var life = factory(window, window.document);
	window.rbLife = life;
	if(typeof module == 'object' && module.exports){
		module.exports = life;
	}
}(typeof window != 'undefined' ? window : this , function(window, document) {
	'use strict';

	var elements, useMutationEvents, timer;
	var docElem = document.documentElement;

	var life = {};
	var removeElements = [];
	var initClass = 'js-rb-life';
	var attachedClass = 'js-rb-attached';
	var rb = window.rb;
	var $ = rb.$;

	window.rb.life = life;

	life.init = function(options){
		if (elements) {throw('only once');}
		clearTimeout(timer);

		if (options) {
			initClass = options.initClass || initClass;
			attachedClass = options.attachedClass || attachedClass;
			useMutationEvents = options.useMutationEvents || false;
		}

		elements = document.getElementsByClassName(initClass);

		life.batch = life.createBatch();

		life.initObserver();
		life.throttledFindElements();
	};

	life.camelCase = (function() {
		var reg = /-([\da-z])/gi;
		var camelCase = function(all, found) {
			return found.toUpperCase();
		};

		return function(str) {
			return str.replace(reg, camelCase);
		};
	})();

	life.parseValue = (function() {
		var regNumber = /^\-*\+*\d+\.*\d*$/;
		var regObj = /^\[.*\]|\{.*\}$/;
		return function( attrVal ) {

			if(attrVal == 'true'){
				attrVal = true;
			}
			else if(attrVal == 'false'){
				attrVal = false;
			}
			else if(regNumber.test(attrVal)){
				attrVal = parseFloat(attrVal);
			}
			else if(regObj.test(attrVal)){
				try {
					attrVal = JSON.parse( attrVal );
				} catch(e){}
			}
			return attrVal;
		};
	})();

	life.createBatch = function(){
		var runs;
		var batch = [];
		var run = function() {
			while ( batch.length ) {
				batch.shift()();
			}
			runs = false;
		};
		return {
			run: run,
			add: function( fn ) {
				batch.push( fn );
			},
			timedRun: function() {
				if ( !runs ) {
					runs = true;
					setTimeout( run );
				}
			}
		};
	};

	life._failed = {};
	life._behaviors = {};
	life._attached = [];

	life.register = function(name, LifeClass, noCheck) {

		life._behaviors[ name ] = LifeClass;

		if ( !noCheck ) {
			if(!elements && !timer){
				timer = setTimeout(life.init);
			}
			life.throttledFindElements();
		}
	};

	life.create = function(element, LifeClass) {
		var instance, trigger;
		if ( !element._rbWidget ) {
			instance = new LifeClass( element );
			trigger = true;
		}

		rb.rAFQueue.add(function(){
			element.classList.add( attachedClass );
		});

		if (!element._rbCreated && instance && (instance.attached || instance.detached || instance.attachedOnce)) {
			life._attached.push(element);

			if(instance.attached){
				life.batch.add(function() {
					instance.attached();
				});
			}
			if(instance.onceAttached){
				life.batch.add(function() {
					instance.onceAttached();
				});
			}
			life.batch.timedRun();
		}
		element._rbCreated = true;

		if(trigger){
			life.batch.add(function() {
				$(element).trigger(LifeClass.prototype.name +'created');
			});
		}<commit_msg>add initWrite<commit_after>(function(window, factory) {
	var life = factory(window, window.document);
	window.rbLife = life;
	if(typeof module == 'object' && module.exports){
		module.exports = life;
	}
}(typeof window != 'undefined' ? window : this , function(window, document) {
	'use strict';

	var elements, useMutationEvents, timer;
	var docElem = document.documentElement;

	var life = {};
	var removeElements = [];
	var initClass = 'js-rb-life';
	var attachedClass = 'js-rb-attached';
	var rb = window.rb;
	var $ = rb.$;

	window.rb.life = life;

	life.init = function(options){
		if (elements) {throw('only once');}
		clearTimeout(timer);

		if (options) {
			initClass = options.initClass || initClass;
			attachedClass = options.attachedClass || attachedClass;
			useMutationEvents = options.useMutationEvents || false;
		}

		elements = document.getElementsByClassName(initClass);

		life.batch = life.createBatch();

		life.initObserver();
		life.throttledFindElements();
	};

	life.camelCase = (function() {
		var reg = /-([\da-z])/gi;
		var camelCase = function(all, found) {
			return found.toUpperCase();
		};

		return function(str) {
			return str.replace(reg, camelCase);
		};
	})();

	life.parseValue = (function() {
		var regNumber = /^\-*\+*\d+\.*\d*$/;
		var regObj = /^\[.*\]|\{.*\}$/;
		return function( attrVal ) {

			if(attrVal == 'true'){
				attrVal = true;
			}
			else if(attrVal == 'false'){
				attrVal = false;
			}
			else if(regNumber.test(attrVal)){
				attrVal = parseFloat(attrVal);
			}
			else if(regObj.test(attrVal)){
				try {
					attrVal = JSON.parse( attrVal );
				} catch(e){}
			}
			return attrVal;
		};
	})();

	life.createBatch = function(){
		var runs;
		var batch = [];
		var run = function() {
			while ( batch.length ) {
				batch.shift()();
			}
			runs = false;
		};
		return {
			run: run,
			add: function( fn ) {
				batch.push( fn );
			},
			timedRun: function() {
				if ( !runs ) {
					runs = true;
					setTimeout( run );
				}
			}
		};
	};

	life._failed = {};
	life._behaviors = {};
	life._attached = [];

	life.register = function(name, LifeClass, noCheck) {

		life._behaviors[ name ] = LifeClass;

		if ( !noCheck ) {
			if(!elements && !timer){
				timer = setTimeout(life.init);
			}
			life.throttledFindElements();
		}
	};

	life.create = function(element, LifeClass) {
		var instance, trigger;
		if ( !element._rbWidget ) {
			instance = new LifeClass( element );
			trigger = true;
		}

		rb.rAFQueue.add(function(){
			element.classList.add( attachedClass );

			if(trigger && instance.initWrite){
				instance.initWrite();
			}
		});

		if (!element._rbCreated && instance && (instance.attached || instance.detached || instance.attachedOnce)) {
			life._attached.push(element);

			if(instance.attached){
				life.batch.add(function() {
					instance.attached();
				});
			}
			if(instance.onceAttached){
				life.batch.add(function() {
					instance.onceAttached();
				});
			}
			life.batch.timedRun();
		}
		element._rbCreated = true;

		if(trigger){
			life.batch.add(function() {
				$(element).trigger(LifeClass.prototype.name +'created');
			});
		}
{'fraction_non_alphanumeric': 0.17176432710882164, 'fraction_numerical': 0.0, 'mean_word_length': 3.109126984126984, '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': '5418880', 'n_tokens_mistral': 2526, 'n_tokens_neox': 2118, 'n_words': 410}