/**
* @license Apache-2.0
*
* Copyright (c) 2021 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var uppercase = require( '@stdlib/string/base/uppercase' );
var replace = require( '@stdlib/string/base/replace' );
var format = require( '@stdlib/string/format' );
var trim = require( '@stdlib/string/base/trim' );


// VARIABLES //

var RE_WHITESPACE = /\s+/g;
var RE_SPECIAL = /[!"'(),–.:;<>?`{}|~\/\\\[\]_#$*&^@%]+/g; // eslint-disable-line no-useless-escape
var RE_CAMEL = /([a-z0-9])([A-Z])/g;


// MAIN //

/**
* Converts a string to constant case.
*
* @param {string} str - string to convert
* @throws {TypeError} must provide a string primitive
* @returns {string} constant-cased string
*
* @example
* var str = constantcase( 'beep' );
* // returns 'BEEP'
*
* @example
* var str = constantcase( 'beep boop' );
* // returns 'BEEP_BOOP'
*
* @example
* var str = constantcase( 'isMobile' );
* // returns 'IS_MOBILE'
*
* @example
* var str = constantcase( 'Hello World!' );
* // returns 'HELLO_WORLD'
*/
function constantcase( str ) {
	if ( !isString( str ) ) {
		throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', str ) );
	}
	str = replace( str, RE_SPECIAL, ' ' );
	str = replace( str, RE_CAMEL, '$1 $2' );
	str = trim( str );
	str = replace( str, RE_WHITESPACE, '_' );
	return uppercase( str );
}


// EXPORTS //

module.exports = constantcase;

@@ -711,124 +711,8 @@
 ve;%0A
-var uppercase = require( '@stdlib/string/base/uppercase' );%0Avar replace = require( '@stdlib/string/base/replace' );%0A
 var 
@@ -760,20 +760,20 @@
  );%0Avar 
-trim
+base
  = requi
@@ -801,199 +801,23 @@
 ase/
-trim' );%0A%0A%0A// VARIABLES //%0A%0Avar RE_WHITESPACE = /%5Cs+/g;%0Avar RE_SPECIAL = /%5B!%22'(),%E2%80%93.:;%3C%3E?%60%7B%7D%7C~%5C/%5C%5C%5C%5B%5C%5D_#$*&%5E@%25%5D+/g; // eslint-disable-line no-useless-escape%0Avar RE_CAMEL = /(%5Ba-z0-9%5D)(%5BA-Z%5D)/g
+constantcase' )
 ;%0A%0A%0A
@@ -1485,161 +1485,16 @@
 %0A%09%7D%0A
-%09str = replace( str, RE_SPECIAL, ' ' );%0A%09str = replace( str, RE_CAMEL, '$1 $2' );%0A%09str = trim( str );%0A%09str = replace( str, RE_WHITESPACE, '_' );%0A
 %09return 
 uppe
@@ -1493,14 +1493,9 @@
 urn 
-upperc
+b
 ase(

Use base package