npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@strdr4605/mockingcase

v1.10.5

Published

Convert a string to mOcKiNgCaSe

Downloads

15

Readme

mockingcase Build Status

Convert a string to mOcKiNgCaSe.

Read more on wikipedia Studly caps.

Inspired by the meme Mocking Spongebob and http://dannypage.github.io/spongebob.html

Install

npm install @strdr4605/mockingcase --save

Usage

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'

API

Functions

Typedefs

mockingcase(input, [options]) ⇒ 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.overrideString() ⇒ 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.prototype.toMockingCase([options]) ⇒ 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.config(defaultOptions) ⇒ 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'

mockingcase.log(input, [options]) :arrow_up:

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.overrideConsole([options]) ⇒ 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'

Options : 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. |

Browser Usage :arrow_up:

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/[email protected]/src/mockingcase.js"></script>
<script>
  const output = mockingcase('foo-bar');
  console.log(output);
  const output2 = mockingcase('foo-bar');
  console.log(output2);
</script>
</html>

Self Hosting

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.

CDN Usage

Simply pull in one of the following JS files below.

|Name|Link| |-|-| |unpkg.com|https://unpkg.com/@strdr4605/[email protected]/src/mockingcase.js| |JSDelivr.com|https://cdn.jsdelivr.net/npm/@strdr4605/[email protected]/src/mockingcase.min.js|

See also Mockingcase bindings for ReasonML