@stdlib/string-constantcase
v0.2.2
Published
Convert a string to constant case.
Downloads
17
Readme
constantcase
Convert a string to constant case.
Installation
npm install @stdlib/string-constantcase
Usage
var constantcase = require( '@stdlib/string-constantcase' );
constantcase( str )
Converts a string to constant case.
var str = constantcase( 'foo bar' );
// returns 'FOO_BAR'
str = constantcase( 'foo bar baz' );
// returns 'FOO_BAR_BAZ'
str = constantcase( 'foo_bar' );
// returns 'FOO_BAR'
Examples
var constantcase = require( '@stdlib/string-constantcase' );
var str = 'Hello World!';
var out = constantcase( str );
// returns 'HELLO_WORLD'
str = 'I am a tiny little teapot';
out = constantcase( str );
// returns 'I_AM_A_TINY_LITTLE_TEAPOT'
str = 'with big problems';
out = constantcase( str );
// returns 'WITH_BIG_PROBLEMS'
str = 'To be, or not to be: that is the question.';
out = constantcase( str );
// returns 'TO_BE_OR_NOT_TO_BE_THAT_IS_THE_QUESTION'
str = 'isMobile';
out = constantcase( str );
// returns 'IS_MOBILE'
See Also
@stdlib/string-constantcase-cli
: CLI package for use as a command-line utility.@stdlib/string-camelcase
: convert a string to camel case.@stdlib/string-kebabcase
: convert a string to kebab case.@stdlib/string-pascalcase
: convert a string to Pascal case.@stdlib/string-snakecase
: convert a string to snake case.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.