Function Name

Regular expression to capture a function name.

Usage

var RE_FUNCTION_NAME = require( '@stdlib/regexp/function-name' );

RE_FUNCTION_NAME

Regular expression to capture a function name.

function beep() {
    return 'boop';
}

var str = RE_FUNCTION_NAME.exec( beep.toString() )[ 1 ];
// returns 'beep'

Examples

var RE_FUNCTION_NAME = require( '@stdlib/regexp/function-name' );

function fname( fcn ) {
    return RE_FUNCTION_NAME.exec( fcn.toString() )[ 1 ];
}

var f = fname( Math.sqrt );
// returns 'sqrt'

f = fname( Int8Array );
// returns 'Int8Array'

f = fname( Object.prototype.toString );
// returns 'toString'

f = fname( function () {} );
// returns ''