
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@strdr4605/mockingcase
Advanced tools
Convert a string to mOcKiNgCaSe.
Read more on wikipedia Studly caps.
Inspired by the meme Mocking Spongebob and http://dannypage.github.io/spongebob.html
npm install @strdr4605/mockingcase --save
const mockingcase = require('@strdr4605/mockingcase');
// es6 - import mockingcase from '@strdr4605/mockingcase';
// ts - import * as mockingcase from '@strdr4605/mockingcase';
// ts - import mockingcase = require('@strdr4605/mockingcase');
mockingcase('foo-bar');
//=> 'fOo-bAr'
mockingcase('aa', {random: false});
//=> 'aA'
mockingcase('aa', {random: true});
//=> 'aa'
//=> 'aA'
//=> 'Aa'
//=> 'AA'
mockingcase('42foo!bar');
//=> '42fOo!bAr'
mockingcase('aa123', {onlyLetters: true});
//=> 'aA'
mockingcase('a13%$a', {onlyLetters: true});
//=> 'aA'
mockingcase('foo bar', {firstUpper: true});
//=> 'FoO BaR'
mockingcase('foo', {firstUpper: true, random: true});
//=> 'Foo'
//=> 'FOo'
//=> 'FoO'
//=> 'FOO'
mockingcase('abcdef', {upper: /[bdf]/});
//=> 'aBcDeF'
mockingcase('ABCDEF', {lower: 'bcd'});
//=> 'abcdeF'
stringmockingcasestringmockingcasemockingcasestringConverts the input string(s) to mOcKiNgCaSe.
ObjectOptions for mockingcase
string :arrow_up:Converts the input string(s) to mOcKiNgCaSe.
Kind: global function
Returns: string - string in mOcKiNgCaSe
| Param | Type | Default | Description |
|---|---|---|---|
| input | string | Array.<string> | String(s) to be converted. | |
| [options] | Options | {random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''} | Conversion options. |
mockingcase('foo-bar');
//=> 'fOo-bAr'
mockingcase('aa', {random: false});
//=> 'aA'
mockingcase('aa', {random: true});
//=> 'aa'
//=> 'aA'
//=> 'Aa'
//=> 'AA'
mockingcase('42foo!bar');
//=> '42fOo!bAr'
mockingcase('aa123', {onlyLetters: true});
//=> 'aA'
mockingcase('a13%$a', {onlyLetters: true});
//=> 'aA'
mockingcase('foo bar', {firstUpper: true});
//=> 'FoO BaR'
mockingcase('foo bar', {firstUpper: true, lower: /[fb]/});
//=> 'foO baR'
mockingcase('foo bar', {firstUpper: true, upper: /[oa]/});
//=> 'FOO BAR'
mockingcase('foo', {firstUpper: true, random: true});
//=> 'Foo'
//=> 'FOo'
//=> 'FoO'
//=> 'FOO'
mockingcase(['foo','bar']);
//=> 'fOoBaR'
mockingcase(undefined);
//=> Error "An input is required"
mockingcase :arrow_up:Creates String.prototype.toMockingCase().
Kind: static method of mockingcase
Returns: mockingcase
mockingcase.overrideString();
'foo_bar'.toMockingCase();
//=> 'fOo_bAr'
'foo_bar'.toMockingCase({firstUpper: true});
//=> 'FoO_BaR'
string :arrow_up:Converts this string to mOcKiNgCaSe.
NOTE: this function is created by invoking mockingcase.overrideString().
Kind: prototype
Returns: string - local string in mOcKiNgCaSe
| Param | Type | Default | Description |
|---|---|---|---|
| input | string | Array.<string> | String(S) to be converted. | |
| [options] | Options | {random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''} | Conversion options. |
'foo_bar'.toMockingCase();
//=> 'fOo_bAr'
'foo_bar'.toMockingCase({firstUpper: true});
//=> 'FoO_BaR'
mockingcase :arrow_up:Outputs a mockingcase with default options.
Kind: static method of mockingcase
Returns: mockingcase with default options
| Param | Type | Default | Description |
|---|---|---|---|
| defaultOptions | Options | {random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''} | Conversion options. |
const mockingcase = require('@strdr4605/mockingcase').config({onlyLetters: true, firstUpper: true});
// const mOcKiNgCaSe = mOcKiNgCaSe.config({onlyLetters: true, firstUpper: true});
mockingcase('foo bar42');
//=> 'FoO BaR'
mockingcase('foo bar42', {onlyLetters: false, firstUpper: false});
//=> 'fOo bAr42'
Outputs a message to the console in mOcKiNgCaSe.
Kind: static method of mockingcase
| Param | Type | Default | Description |
|---|---|---|---|
| input | string | Array.<string> | String(S) to be converted. | |
| [options] | Options | {random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''} | Conversion options. |
mockingcase.log('foo bar');
// console.log('fOo bAr');
mockingcase :arrow_up:Overrides console.log input to print the input mOcKiNgCaSe.
Kind: static method of mockingcase
Returns: function - mockingcase function
See: mockingcase
| Param | Type | Default | Description |
|---|---|---|---|
| [options] | Options | {random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''} | Conversion options. |
const mockingcase = require('@strdr4605/mockingcase').overrideConsole();
console.log('foobar')
// => 'fOoBaR'
mockingcase('foobar');
// => 'fOoBaR'
Object :arrow_up:Options for mockingcase
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [random] | boolean | false | If case conversion should be randomized. |
| [onlyLetters] | boolean | false | If non letters characters should be removed. |
| [firstUpper] | boolean | false | If the first letter should be capitalized instead of the second when converting to mOcKiNgCaSe (e.g. MoCkInGcAsE). When combined with options.random, the first letter of the random string will be capitalized. |
| [upper] | string | RegExp | '' | Characters or substring set to change to uppercase, upper has higher priority that lower. |
| [lower] | string | RegExp | '' | Characters or substring set to change to lowercase. |
mOcKiNgCaSe can be used in a node environment, as well as in the browser. You can serve it yourself, or pull it from a CDN. For example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>mockingcase</title>
</head>
<body>
</body>
<script src="https://unpkg.com/@strdr4605/mockingcase@1.10.3/src/mockingcase.js"></script>
<script>
const output = mockingcase('foo-bar');
console.log(output);
const output2 = mockingcase('foo-bar');
console.log(output2);
</script>
</html>
To host mockingcase yourself simply put src/mockingcase.js wherever your static content (like CSS stylesheets) are kept. You can also download a minified file from one of the CDNs below.
Simply pull in one of the following JS files below.
| Name | Link |
|---|---|
| unpkg.com | https://unpkg.com/@strdr4605/mockingcase |
| JSDelivr.com | https://cdn.jsdelivr.net/npm/@strdr4605/mockingcase |
See also Mockingcase bindings for ReasonML
FAQs
Convert a string to mOcKiNgCaSe
We found that @strdr4605/mockingcase demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.