function place( x, mask, values, mode ) {
	var xo;
	var mo;
	var vo;
	var M;

	M = values.length;
	if ( mode === 'strict' ) {
		if ( countTruthy( mask ) !== M ) {
			throw new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' );
		}
	} else if ( mode === 'broadcast' ) {
		if ( M !== 1 && countTruthy( mask ) > M ) {
			throw new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );
		}
	} else if ( mode === 'strict_broadcast' ) {
		if ( M !== 1 && countTruthy( mask ) !== M ) {
			throw new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' );
		}
	} else if ( mode === 'non_strict' ) {
		if ( countTruthy( mask ) > M ) {
			throw new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );
		}
	}
	xo = arraylike2object( x );
	mo = arraylike2object( mask );
	vo = arraylike2object( values );
	if (
		xo.accessorProtocol ||
		mo.accessorProtocol ||
		vo.accessorProtocol
	) {
		// Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...
		if ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) {
			complex( reinterpretComplex( x, 0 ), mo, reinterpretComplex( values, 0 ) ); // eslint-disable-line max-len
			return x;
		}
		if ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) {
			boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( values, 0 ) ); // eslint-disable-line max-len
			return x;
		}
		accessors( xo, mo, vo );
		return x;
	}
	indexed( x, mask, values );
	return x;
}
Replaces elements of an array with provided values according to a provided mask array.

@param {Collection} x - input array
@param {Collection} mask - mask array
@param {Collection} values - values to set
@param {string} mode - string specifying behavior when the number of values does not equal the number of truthy mask values
@throws {Error} insufficient values to satisfy mask array
@throws {Error} number of values does not equal the number of truthy mask values
@returns {Collection} input array

@example
var x = [ 1, 2, 3, 4 ];

var mask = [ 0, 1, 1, 0 ];
var values = [ 20, 30 ];

var out = place( x, mask, values, 'strict' );
// returns [ 1, 20, 30, 4 ]

var bool = ( out === x );
// returns true

@example
var x = [ 1, 2, 3, 4 ];

var mask = [ 0, 1, 1, 0 ];
var values = [ 30 ];

var out = place( x, mask, values, 'strict_broadcast' );
// returns [ 1, 30, 30, 4 ]

var bool = ( out === x );
// returns true

@example
var x = [ 1, 2, 3, 4 ];

var mask = [ 1, 1, 0, 1 ];
var values = [ 20, 30 ];

var out = place( x, mask, values, 'repeat' );
// returns [ 20, 30, 3, 20 ]

var bool = ( out === x );
// returns true