<commit_before>'use strict';

var copy        = require('es5-ext/lib/Array/prototype/copy')
  , remove      = require('es5-ext/lib/Array/prototype/remove')
  , callable    = require('es5-ext/lib/Object/valid-callable')
  , d           = require('es5-ext/lib/Object/descriptor')
  , extend      = require('es5-ext/lib/Object/extend')
  , memoize     = require('memoizee/lib/regular')
  , ObjectList  = require('../_proto/object-ordered-list')
  , relation    = require('./')

  , push = Array.prototype.push, sort = Array.prototype.sort
  , defineProperty = Object.defineProperty
  , defineProperties = Object.defineProperties
  , ItemsList, proto;

var byOrder = function (a, b) { return a.order - b.order; };
var toValue = function (item) { return item._subject_; };

ItemsList = function (set, compareFn) {
	var list = [];
	set.forEach(function (value, item, set, index, key) {
		list.push(item || set._getItem_(key, value));
	});
	list.__proto__ = proto;
	compareFn = compareFn.bind(set);
	sort.call(list, compareFn);
	defineProperties(list, {
		obj: d(set),
		compareFn: d(compareFn),
		_history: d('w', copy.call(list))
	});
	set.on('add', list._onAdd);
	set.on('delete', list._onDelete);
	return list;
};

ItemsList.prototype = proto = Object.create(ObjectList.prototype, extend({
	constructor: d(ItemsList),
}, d.binder({
	_onAdd: d(function (value, item, key) {
		push.call(this, item || this.set._getItem_(key, value));
		this._sort();
	}),
	_onDelete: d(function (value, item) {
		remove.call(this, item);
		this._sort();
	}),
})));

var itemsListMethod = function (compareFn) {
	return new ItemsList(this, callable(compareFn));
};

ObjectList.defineOn(relation);
defineProperties(relation, {<commit_msg>Define live filters on relation sets<commit_after>'use strict';

var copy        = require('es5-ext/lib/Array/prototype/copy')
  , remove      = require('es5-ext/lib/Array/prototype/remove')
  , callable    = require('es5-ext/lib/Object/valid-callable')
  , d           = require('es5-ext/lib/Object/descriptor')
  , extend      = require('es5-ext/lib/Object/extend')
  , memoize     = require('memoizee/lib/regular')
  , FilterSet   = require('../_proto/object-filter-set')
  , ObjectList  = require('../_proto/object-ordered-list')
  , relation    = require('./')

  , push = Array.prototype.push, sort = Array.prototype.sort
  , defineProperty = Object.defineProperty
  , defineProperties = Object.defineProperties
  , ItemsList, proto;

var byOrder = function (a, b) { return a.order - b.order; };
var toValue = function (item) { return item._subject_; };

ItemsList = function (set, compareFn) {
	var list = [];
	set.forEach(function (value, item, set, index, key) {
		list.push(item || set._getItem_(key, value));
	});
	list.__proto__ = proto;
	compareFn = compareFn.bind(set);
	sort.call(list, compareFn);
	defineProperties(list, {
		obj: d(set),
		compareFn: d(compareFn),
		_history: d('w', copy.call(list))
	});
	set.on('add', list._onAdd);
	set.on('delete', list._onDelete);
	return list;
};

ItemsList.prototype = proto = Object.create(ObjectList.prototype, extend({
	constructor: d(ItemsList),
}, d.binder({
	_onAdd: d(function (value, item, key) {
		push.call(this, item || this.set._getItem_(key, value));
		this._sort();
	}),
	_onDelete: d(function (value, item) {
		remove.call(this, item);
		this._sort();
	}),
})));

var itemsListMethod = function (compareFn) {
	return new ItemsList(this, callable(compareFn));
};

FilterSet.defineOn(relation);
ObjectList.defineOn(relation);
defineProperties(relation, {
{'fraction_non_alphanumeric': 0.17071791972866027, 'fraction_numerical': 0.002826455624646693, 'mean_word_length': 4.173976608187134, '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': '7188543', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1191, 'n_words': 232}