@stdlib/string-base-stickycase v0.1.0
stickycase
Convert a string to sticky case.
Installation
npm install @stdlib/string-base-stickycase
Usage
var stickycase = require( '@stdlib/string-base-stickycase' );
stickycase( str[, p] )
Converts a string to sticky case, where each character in the input string is randomly converted to either uppercase or lowercase.
var str = 'hello world';
var out = stickycase( 'hello world' );
// returns <string>
By default, the probability for any character to be capitalized is 0.5
. To set a different probability, provide a p
argument.
var str = 'welcome!';
var out = stickycase( 'welcome!', 0.2 );
// returns <string>
str = 'good morning';
out = stickycase( 'good morning', 0.8 );
// returns <string>
Examples
var stickycase = require( '@stdlib/string-base-stickycase' );
var str = 'Hello World!';
var out = stickycase( str );
// returns <string>
// returns <string>
str = 'I am a tiny little teapot';
out = stickycase( str );
// returns <string>
str = 'with big problems';
out = stickycase( str, 0.1 );
// returns <string>
str = 'To be, or not to be: that is the question.';
out = stickycase( str, 0.9 );
// returns <string>
str = 'isMobile';
out = stickycase( str );
// returns <string>
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.
1 year ago