<commit_before>'use strict';

// MODULES //

var debug = require( 'debug' )( 'rug:set:color' );
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var isFunction = require( '@stdlib/assert/is-function' );


// MAIN //

/**
* Sets the color.
*
* @private
* @param {(string|Function)} color - color
* @throws {TypeError} must be a string primitive or function
*/
function set( color ) {
	/* eslint-disable no-invalid-this */
	if ( !isString( color ) && !isFunction( color ) ) {
		throw new TypeError( 'invalid value. `color` must be a string primitive or a function. Value: `' + color + '.`' );
	}
	debug( 'Current value: %d.', this._color );

	this._color = color;
	debug( 'New Value: %d.', this._color );

	this.emit( 'change' );
} // end FUNCTION set()


// EXPORTS //

module.exports = set;<commit_msg>Only fire a `change` event when provided a new value<commit_after>'use strict';

// MODULES //

var debug = require( 'debug' )( 'rug:set:color' );
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var isFunction = require( '@stdlib/assert/is-function' );


// MAIN //

/**
* Sets the color.
*
* @private
* @param {(string|Function)} color - color
* @throws {TypeError} must be a string primitive or function
*/
function set( color ) {
	/* eslint-disable no-invalid-this */
	if ( !isString( color ) && !isFunction( color ) ) {
		throw new TypeError( 'invalid value. `color` must be a string primitive or a function. Value: `' + color + '.`' );
	}
	if ( color !== this._color ) {
		debug( 'Current value: %d.', this._color );

		this._color = color;
		debug( 'New Value: %d.', this._color );

		this.emit( 'change' );
	}
} // end FUNCTION set()


// EXPORTS //

module.exports = set;
{'fraction_non_alphanumeric': 0.1794871794871795, 'fraction_numerical': 0.0, 'mean_word_length': 3.4138817480719794, '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': '4941562', 'n_tokens_mistral': 586, 'n_tokens_neox': 570, 'n_words': 173}