lib/packages/core-classes.js
function(start_index, values, names) {

		if (start_index >= this._count) Lava.t("Index is out of range");

		var i = 0,
			count = values.length,
			added_uids = [],
			added_names = [];

		if (names) {

			if (count != names.length) Lava.t("If names array is provided, it must be equal length with values array.");
			added_names = names;

		} else {

			for (; i < count; i++) {

				added_names.push(null);

			}

		}

		for (; i < count; i++) {

			added_uids.push(this._uid++);

		}

		if (start_index == 0) {

			// prepend to beginning
			this._data_uids = added_uids.concat(this._data_uids);
			this._data_values = values.concat(this._data_values);
			this._data_names = added_names.concat(this._data_names);

		} else if (start_index == this._count - 1) {

			// append to the end
			this._data_uids = this._data_uids.concat(added_uids);
			this._data_values = this._data_values.concat(values);
			this._data_names = this._data_names.concat(added_names);

		} else {

			this._data_uids = this._data_uids.slice(0, start_index).concat(added_uids).concat(this._data_uids.slice(start_index));
			this._data_values = this._data_values.slice(0, start_index).concat(values).concat(this._data_values.slice(start_index));
			this._data_names = this._data_names.slice(0, start_index).concat(added_names).concat(this._data_names.slice(start_index));

		}

		this._setLength(this._count + count);

		this._fire('items_added', {
			uids: added_uids,
			values: values,
			names: added_names
		});

		this._fire('collection_changed');

	}
function(start_index, values, names) {

		if (start_index >= this._count) Lava.t("Index is out of range");

		var i = 0,
			count = values.length,
			added_uids = [],
			added_names = [];

		if (names) {

			if (count != names.length) Lava.t("If names array is provided, it must be equal length with values array.");
			added_names = names;

		} else {

			for (; i < count; i++) {

				added_names.push(null);

			}

		}

		for (; i < count; i++) {

			added_uids.push(this._uid++);

		}

		if (start_index == 0) {

			// prepend to beginning
			this._data_uids = added_uids.concat(this._data_uids);
			this._data_values = values.concat(this._data_values);
			this._data_names = added_names.concat(this._data_names);

		} else if (start_index == this._count - 1) {

			// append to the end
			this._data_uids = this._data_uids.concat(added_uids);
			this._data_values = this._data_values.concat(values);
			this._data_names = this._data_names.concat(added_names);

		} else {

			this._data_uids = this._data_uids.slice(0, start_index).concat(added_uids).concat(this._data_uids.slice(start_index));
			this._data_values = this._data_values.slice(0, start_index).concat(values).concat(this._data_values.slice(start_index));
			this._data_names = this._data_names.slice(0, start_index).concat(added_names).concat(this._data_names.slice(start_index));

		}

		this._setLength(this._count + count);

		this._fire('items_added', {
			uids: added_uids,
			values: values,
			names: added_names
		});

		this._fire('collection_changed');

	}
function ( start_index , values , names ) { if ( start_index >= this . _count ) Lava . t ( "Index is out of range" ) ; var i = 0 , count = values . length , added_uids = [ ] , added_names = [ ] ; if ( names ) { if ( count != names . length ) Lava . t ( "If names array is provided, it must be equal length with values array." ) ; added_names = names ; } else { for ( ; i < count ; i ++ ) { added_names . push ( null ) ; } } for ( ; i < count ; i ++ ) { added_uids . push ( this . _uid ++ ) ; } if ( start_index == 0 ) { // prepend to beginning this . _data_uids = added_uids . concat ( this . _data_uids ) ; this . _data_values = values . concat ( this . _data_values ) ; this . _data_names = added_names . concat ( this . _data_names ) ; } else if ( start_index == this . _count - 1 ) { // append to the end this . _data_uids = this . _data_uids . concat ( added_uids ) ; this . _data_values = this . _data_values . concat ( values ) ; this . _data_names = this . _data_names . concat ( added_names ) ; } else { this . _data_uids = this . _data_uids . slice ( 0 , start_index ) . concat ( added_uids ) . concat ( this . _data_uids . slice ( start_index ) ) ; this . _data_values = this . _data_values . slice ( 0 , start_index ) . concat ( values ) . concat ( this . _data_values . slice ( start_index ) ) ; this . _data_names = this . _data_names . slice ( 0 , start_index ) . concat ( added_names ) . concat ( this . _data_names . slice ( start_index ) ) ; } this . _setLength ( this . _count + count ) ; this . _fire ( 'items_added' , { uids : added_uids , values : values , names : added_names } ) ; this . _fire ( 'collection_changed' ) ; }
Insert a sequence of values into collection
@param {number} start_index Index of the beginning of new values. Must be less or equal to collection's `_count`
@param {Array.<*>} values New values
@param [names] Names that correspond to each value
Insert a sequence of values into collection