@stdlib/string-base-snakecase
v0.2.2
Published
Convert a string to snake case.
Downloads
53
Readme
snakecase
Convert a string to snake case.
Installation
npm install @stdlib/string-base-snakecase
Usage
var snakecase = require( '@stdlib/string-base-snakecase' );
snakecase( str )
Converts a string to snake case.
var str = snakecase( 'Foo Bar' );
// returns 'foo_bar'
str = snakecase( 'I am a tiny little house' );
// returns 'i_am_a_tiny_little_house'
str = snakecase( 'Hello World!' );
// returns 'hello_world'
Examples
var snakecase = require( '@stdlib/string-base-snakecase' );
var str = 'foo bar baz';
var out = snakecase( str );
// returns 'foo_bar_baz'
str = 'foo_baz';
out = snakecase( str );
// returns 'foo_baz'
str = 'foo_bar_baz!';
out = snakecase( str );
// returns 'foo_bar_baz'
str = 'beep boop!';
out = snakecase( str );
// returns 'beep_boop'
str = 'foo-baz';
out = snakecase( str );
// returns 'foo_baz'
str = 'Welcome! 😀';
out = snakecase( str );
// returns 'welcome_😀'
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.