<commit_before>var splitor = ',';
var chainMethods = 'select,from,where,orderBy,groupBy,having'.split(splitor);
var onceMethods = 'select,from,orderBy,groupBy,having'.split(splitor);

buildFunctionalSQLPrototype();

var query = createQuery;

// return void(0);

function FunctionalSQL() {
	this.sources = [];
	this.selector = null;
	this.filters = [];
	this.groupBys = [];
	this.result = [];
}

function buildFunctionalSQLPrototype() {
	var proto = FunctionalSQL.prototype;

	proto.select = select;
	proto.doSelect = doSelect;

	proto.from = from;

	proto.where = where;
	proto.doFilter = doFilter;

	proto.orderBy = orderBy;

	proto.groupBy = groupBy;
	proto.doGroup = doGroup;

	proto.having = having;

	proto.execute = execute;

	chainMethods.forEach(function(methodName) {
		chinify(proto, methodName);
	});

	onceMethods.forEach(function(methodName) {
		onceify(proto, methodName);
	});

	return void(0);

	function select(selector) {
		if(isFunction(selector)) {
			this.selector = selector;
		}
	}

	function doSelect() {
		if(this.selector) {
			this.result = this.result.map(this.selector);
		}
	}

	function from() {
		var sources = argumentsToArray(arguments);
		this.result =
			this.sources = (
				sources.length === 1 ?
				sources[0] :
				sources
			);
	}

	function where() {
		var filters = getMethodsFromArguments(arguments);

		filters.forEach(function(filter) {
			if(isFunction(filter)) {
				this.filters.push(filter);
			}
		}, this);
	}

	function doFilter() {
		this.filters.forEach(function(filter) {
			this.result = this.result.filter(filter);
		}, this);
	}

	function orderBy() {

	}

	function groupBy(groupBy) {
		var groupBys = getMethodsFromArguments(arguments);

		groupBys.forEach(function(groupBy) {
			if(isFunction(groupBy)) {
				this.groupBys.push(groupBy);
			}
		}, this);
	}

	function doGroup() {
		this.result = group(this.result, this.groupBys);
	}

	function having() {}

	function execute() {
		this.doFilter();
		this.doGroup();
		this.doSelect();

		return this.result;
	}

}

function getMethodsFromArguments(args) {
	return argumentsToArray(args);<commit_msg>add orderBy<commit_after>var splitor = ',';
var chainMethods = 'select,from,where,orderBy,groupBy,having'.split(splitor);
var onceMethods = 'select,from,orderBy,groupBy,having'.split(splitor);

buildFunctionalSQLPrototype();

var query = createQuery;

// return void(0);

function FunctionalSQL() {
	this.sources = [];
	this.selector = null;
	this.filters = [];
	this.groupBys = [];
	this.orderByor = null;
	this.result = [];
}

function buildFunctionalSQLPrototype() {
	var proto = FunctionalSQL.prototype;

	proto.select = select;
	proto.doSelect = doSelect;

	proto.from = from;

	proto.where = where;
	proto.doFilter = doFilter;

	proto.orderBy = orderBy;
	proto.doOrderBy = doOrderBy;

	proto.groupBy = groupBy;
	proto.doGroup = doGroup;

	proto.having = having;

	proto.execute = execute;

	chainMethods.forEach(function(methodName) {
		chinify(proto, methodName);
	});

	onceMethods.forEach(function(methodName) {
		onceify(proto, methodName);
	});

	return void(0);

	function select(selector) {
		if(isFunction(selector)) {
			this.selector = selector;
		}
	}

	function doSelect() {
		if(this.selector) {
			this.result = this.result.map(this.selector);
		}
	}

	function from() {
		var sources = argumentsToArray(arguments);
		this.result =
			this.sources = (
				sources.length === 1 ?
				sources[0] :
				sources
			);
	}

	function where() {
		var filters = getMethodsFromArguments(arguments);

		filters.forEach(function(filter) {
			if(isFunction(filter)) {
				this.filters.push(filter);
			}
		}, this);
	}

	function doFilter() {
		this.filters.forEach(function(filter) {
			this.result = this.result.filter(filter);
		}, this);
	}

	function orderBy(orderBy) {
		if(isFunction(orderBy)) {
			this.orderByor = orderBy;
		}
	}

	function doOrderBy() {
		if(this.orderByor) {
			this.result = this.result.sort(this.orderByor);
		}
	}

	function groupBy() {
		var groupBys = getMethodsFromArguments(arguments);

		groupBys.forEach(function(groupBy) {
			if(isFunction(groupBy)) {
				this.groupBys.push(groupBy);
			}
		}, this);
	}

	function doGroup() {
		this.result = group(this.result, this.groupBys);
	}

	function having() {}

	function execute() {
		this.doFilter();
		this.doGroup();
		this.doSelect();
		this.doOrderBy();

		return this.result;
	}

}

function getMethodsFromArguments(args) {
	return argumentsToArray(args);
{'fraction_non_alphanumeric': 0.1450962830273175, 'fraction_numerical': 0.0017913121361397223, 'mean_word_length': 4.0993150684931505, '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': '449561', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1516, 'n_words': 253}