<commit_before>// Returns group fragment which contains all data fragments for objects found in provided
// collection

'use strict';

var includes            = require('es5-ext/array/#/contains')
  , ensureIterable      = require('es5-ext/iterable/validate-object')
  , ensureObservable    = require('observable-value/valid-observable')
  , Set                 = require('es6-set')
  , DataFragmentGroup   = require('data-fragment/group')
  , defaultGetFragments = require('./get-direct-object-fragments')

  , isArray = Array.isArray;

module.exports = function (collection, getFragment) {
	var fragment, current, isArrayMode = isArray(collection);

	ensureObservable(ensureIterable(collection));
	if (typeof getFragment !== 'function') getFragment = defaultGetFragments(getFragment);

	fragment = new DataFragmentGroup();
	current = new Set();
	if (collection.promise) fragment.promise = collection.promise;

	collection.forEach(function (id) {
		fragment.addFragment(getFragment(id));
		current.add(id);
	});
	collection.on('change', function (event) {
		current.forEach(function (id) {<commit_msg>Support injection of initial fragment<commit_after>// Returns group fragment which contains all data fragments for objects found in provided
// collection

'use strict';

var includes            = require('es5-ext/array/#/contains')
  , ensureIterable      = require('es5-ext/iterable/validate-object')
  , ensureObservable    = require('observable-value/valid-observable')
  , Set                 = require('es6-set')
  , DataFragmentGroup   = require('data-fragment/group')
  , defaultGetFragments = require('./get-direct-object-fragments')

  , isArray = Array.isArray;

module.exports = function (collection, getFragment/*, options*/) {
	var fragment, current, isArrayMode = isArray(collection), options = Object(arguments[2]);

	ensureObservable(ensureIterable(collection));
	if (typeof getFragment !== 'function') getFragment = defaultGetFragments(getFragment);

	fragment = options.fragment || new DataFragmentGroup();
	current = new Set();
	if (collection.promise) fragment.promise = collection.promise;

	collection.forEach(function (id) {
		fragment.addFragment(getFragment(id));
		current.add(id);
	});
	collection.on('change', function (event) {
		current.forEach(function (id) {
{'fraction_non_alphanumeric': 0.13083296990841692, 'fraction_numerical': 0.0030527692978630614, 'mean_word_length': 4.650246305418719, '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': '2884269', 'n_tokens_mistral': 651, 'n_tokens_neox': 638, 'n_words': 142}