'use strict';

// MODULES //

var specificationClass = require( '@stdlib/utils/specification-class' );
var RE = require( '@stdlib/regex/function-name' );
var isBuffer = require( '@stdlib/utils/is-buffer' );


// CONSTRUCTOR NAME //

/**
* FUNCTION: constructorName( v )
*	Determines the name of a value's constructor.
*
* @param {*} v - input value
* @returns {String} name of a value's constructor
*/
function constructorName( v ) {
	var name;
	var ctor;
	name = specificationClass( v ).slice( 8, -1 );
	if ( (name === 'Object' || name === 'Error') && v.constructor ) {
		ctor = v.constructor;
		if ( typeof ctor.name === 'string' ) {
			return ctor.name;
		}
		return RE.exec( ctor.toString() )[ 1 ];
	}
	if ( isBuffer( v ) ) {
		return 'Buffer';
	}
	return name;
} // end FUNCTION constructorName()


// EXPORTS //

module.exports = constructorName;

'use strict';

// MODULES //

var nativeClass = require( '@stdlib/utils/native-class' );
var RE = require( '@stdlib/regex/function-name' );
var isBuffer = require( '@stdlib/utils/is-buffer' );


// CONSTRUCTOR NAME //

/**
* FUNCTION: constructorName( v )
*	Determines the name of a value's constructor.
*
* @param {*} v - input value
* @returns {String} name of a value's constructor
*/
function constructorName( v ) {
	var name;
	var ctor;
	name = nativeClass( v ).slice( 8, -1 );
	if ( (name === 'Object' || name === 'Error') && v.constructor ) {
		ctor = v.constructor;
		if ( typeof ctor.name === 'string' ) {
			return ctor.name;
		}
		return RE.exec( ctor.toString() )[ 1 ];
	}
	if ( isBuffer( v ) ) {
		return 'Buffer';
	}
	return name;
} // end FUNCTION constructorName()


// EXPORTS //

module.exports = constructorName;

Update fcn to get an object's native class
Update fcn to get an object's native class
