format/css.js
function injectFields(string, values) {
	const fieldsModel = parseFields(string);
	const fieldsAmount = fieldsModel.fields.length;

	if (fieldsAmount) {
		values = values.slice();
		if (values.length > fieldsAmount) {
			// More values that output fields: collapse rest values into
			// a single token
			values = values.slice(0, fieldsAmount - 1)
				.concat(values.slice(fieldsAmount - 1).join(', '));
		}

		while (values.length) {
			const value = values.shift();
			const field = fieldsModel.fields.shift();
			const delta = value.length - field.length;

			fieldsModel.string = fieldsModel.string.slice(0, field.location)
				+ value
				+ fieldsModel.string.slice(field.location + field.length);

			// Update location of the rest fields in string
			for (let i = 0, il = fieldsModel.fields.length; i < il; i++) {
				fieldsModel.fields[i].location += delta;
			}
		}
	}

	return fieldsModel;
}
function injectFields(string, values) {
	const fieldsModel = parseFields(string);
	const fieldsAmount = fieldsModel.fields.length;

	if (fieldsAmount) {
		values = values.slice();
		if (values.length > fieldsAmount) {
			// More values that output fields: collapse rest values into
			// a single token
			values = values.slice(0, fieldsAmount - 1)
				.concat(values.slice(fieldsAmount - 1).join(', '));
		}

		while (values.length) {
			const value = values.shift();
			const field = fieldsModel.fields.shift();
			const delta = value.length - field.length;

			fieldsModel.string = fieldsModel.string.slice(0, field.location)
				+ value
				+ fieldsModel.string.slice(field.location + field.length);

			// Update location of the rest fields in string
			for (let i = 0, il = fieldsModel.fields.length; i < il; i++) {
				fieldsModel.fields[i].location += delta;
			}
		}
	}

	return fieldsModel;
}
function injectFields ( string , values ) { const fieldsModel = parseFields ( string ) ; const fieldsAmount = fieldsModel . fields . length ; if ( fieldsAmount ) { values = values . slice ( ) ; if ( values . length > fieldsAmount ) { // More values that output fields: collapse rest values into // a single token values = values . slice ( 0 , fieldsAmount - 1 ) . concat ( values . slice ( fieldsAmount - 1 ) . join ( ', ' ) ) ; } while ( values . length ) { const value = values . shift ( ) ; const field = fieldsModel . fields . shift ( ) ; const delta = value . length - field . length ; fieldsModel . string = fieldsModel . string . slice ( 0 , field . location ) + value + fieldsModel . string . slice ( field . location + field . length ) ; // Update location of the rest fields in string for ( let i = 0 , il = fieldsModel . fields . length ; i < il ; i ++ ) { fieldsModel . fields [ i ] . location += delta ; } } } return fieldsModel ; }
Injects given field values at each field of given string
@param  {String}   string
@param  {String[]} attributes
@return {FieldString}
Injects given field values at each field of given string