1.9.1 • Published 5 years ago

mockingcase v1.9.1

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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 mockingcase --save

Usage

const mOcKiNgCaSe = require('mockingcase');
// es6 - import mOcKiNgCaSe from 'mockingcase';
//  ts - import * as mOcKiNgCaSe from 'mockingcase';
//  ts - import mOcKiNgCaSe = require('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(['foo','bar']);
//=> 'fOoBaR'

mOcKiNgCaSe(undefined);
//=> Error "An input is required"

mOcKiNgCaSe.log('foo bar');
// console.log('fOo bAr');

// Optionally create String.prototype.toMockingCase
mOcKiNgCaSe.overrideString();

'foo_bar'.toMockingCase();
//=> 'fOo_bAr'

'foo_bar'.toMockingCase({firstUpper: true});
//=> 'FoO_BaR'

// Optionally overrides console.log and returns a mOcKiNgCaSe object
mOcKiNgCaSe.overrideConsole();
console.log('Hello');
//=> 'hElLo'

const mOcKiNgCaSe = require('mockingcase').overrideConsole();
console.log('foobar')
// => 'fOoBaR'
mOcKiNgCaSe('foobar');
// => 'fOoBaR'

// Optionally create an initial config with default options
const mOcKiNgCaSe = require('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'

API

mOcKiNgCaSe(input, options) ⇒ string

Converts the input string(s) to mOcKiNgCaSe.

Kind: global function Returns: string - string in mOcKiNgCaSe

ParamTypeDefaultDescription
inputstring | string[]String(s) to be converted
optionsobject{random: false, onlyLetters: false, firstUpper: false}Conversion options
options.randombooleanfalseIf case conversion should be randomized
options.onlyLettersbooleanfalseIf non letters characters should be removed
options.firstUpperbooleanfalseIf 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

mOcKiNgCaSe.overrideString() ⇒ mOcKiNgCaSe

Creates String.prototype.toMockingCase().

Kind: global function Returns: mOcKiNgCaSe - The mOcKiNgCaSe module. See: toMockingCase

String.prototype.toMockingCase(options) ⇒ string

Converts this string to mOcKiNgCaSe.

NOTE: this function is created by invoking mOcKiNgCaSe.overrideString().

Kind: prototype Returns: string - local string in mOcKiNgCaSe

ParamTypeDefaultDescription
optionsobject{random: false, onlyLetters: false, firstUpper: false}Conversion options
options.randombooleanfalseIf case conversion should be randomized
options.onlyLettersbooleanfalseIf non letters characters should be removed
options.firstUpperbooleanfalseIf 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

mOcKiNgCaSe.config(defaultOptions) ⇒ mOcKiNgCaSe

Outputs a mOcKiNgCaSe with default options.

Kind: static method of mOcKiNgCaSe Returns: mOcKiNgCaSe with default options

ParamTypeDefaultDescription
defaultOptionsobjectOptions for converting
defaultOptions.randombooleanfalseIf case conversion should be randomized
defaultOptions.onlyLettersbooleanfalseIf non letters characters should be removed
defaultOptions.firstUpperbooleanfalseIf 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

mOcKiNgCaSe.log(input, options)

Outputs a message to the console in mOcKiNgCaSe.

Kind: static method of mOcKiNgCaSe

ParamTypeDefaultDescription
inputstring | string[]String(S) to be converted
optionsobject{random: false, onlyLetters: false, firstUpper: false}Conversion options
options.randombooleanfalseIf case conversion should be randomized
options.onlyLettersbooleanfalseIf non letters characters should be removed
options.firstUpperbooleanfalseIf 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

mOcKiNgCaSe.overrideConsole(options) ⇒ mOcKiNgCaSe

Overrides the console.log input annd prints it in the mOcKiNgCaSe.

ParamTypeDefaultDescription
optionsobject{random: false, onlyLetters: false, firstUpper: false}Conversion options
options.randombooleanfalseIf case conversion should be randomized
options.onlyLettersbooleanfalseIf non letters characters should be removed
options.firstUpperbooleanfalseIf 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

See also Mockingcase bindings for ReasonML

1.9.1

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago