<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var logger = require( 'debug' );
var indexOf = require( '@stdlib/utils/index-of' );
var VIEWERS = require( './viewers.json' );


// VARIABLES //

var debug = logger( 'plot:set:viewer' );


// MAIN //

/**
* Sets the viewer.
*
* @private
* @param {string} viewer - viewer
* @throws {TypeError} must be a recognized viewer
* @returns {void}
*/
function set( viewer ) {
	/* eslint-disable no-invalid-this */
	if ( indexOf( VIEWERS, viewer ) === -1 ) {
		throw new TypeError( 'invalid value. Unrecognized/unsupported `viewer`. Value: `' + viewer + '.`' );
	}
	debug( 'Current value: %s.', this._viewer );

	this._viewer = viewer;
	debug( 'New value: %s.', this._viewer );

	this.emit( 'change' );
}


// EXPORTS //
<commit_msg>Only emit a `change` event if set to a new value<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var logger = require( 'debug' );
var indexOf = require( '@stdlib/utils/index-of' );
var VIEWERS = require( './viewers.json' );


// VARIABLES //

var debug = logger( 'plot:set:viewer' );


// MAIN //

/**
* Sets the viewer.
*
* @private
* @param {string} viewer - viewer
* @throws {TypeError} must be a recognized viewer
*/
function set( viewer ) {
	/* eslint-disable no-invalid-this */
	if ( indexOf( VIEWERS, viewer ) === -1 ) {
		throw new TypeError( 'invalid value. Unrecognized/unsupported `viewer`. Value: `' + viewer + '.`' );
	}
	if ( viewer !== this._viewer ) {
		debug( 'Current value: %s.', this._viewer );

		this._viewer = viewer;
		debug( 'New value: %s.', this._viewer );

		this.emit( 'change' );
	}
}


// EXPORTS //

{'fraction_non_alphanumeric': 0.1413427561837456, 'fraction_numerical': 0.0077738515901060075, 'mean_word_length': 3.4865293185419968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5104897', 'n_tokens_mistral': 928, 'n_tokens_neox': 884, 'n_words': 329}