Skip to content

Commit

Permalink
Change default value for upper, lower options (#87)
Browse files Browse the repository at this point in the history
* Change default value for upper, lower options

* Change default values for upper, lower options in @typedef and README
  • Loading branch information
Alhxor authored Feb 6, 2020
1 parent 7ec5682 commit 36f2b1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Converts the input string(s) to mOcKiNgCaSe.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| input | <code>string</code> \| <code>Array.&lt;string&gt;</code> | | String(s) to be converted. |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}</code> | Conversion options. |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}</code> | Conversion options. |

```js
mockingcase('foo-bar');
Expand Down Expand Up @@ -180,7 +180,7 @@ Converts `this` string to mOcKiNgCaSe.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| input | <code>string</code> \| <code>Array.&lt;string&gt;</code> | | String(S) to be converted. |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}</code> | Conversion options. |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}</code> | Conversion options. |

```js
'foo_bar'.toMockingCase();
Expand All @@ -201,7 +201,7 @@ Outputs a mockingcase with default options.

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| defaultOptions | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}</code> | Conversion options. |
| defaultOptions | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}</code> | Conversion options. |


```js
Expand All @@ -226,7 +226,7 @@ Outputs a message to the console in mOcKiNgCaSe.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| input | <code>string</code> \| <code>Array.&lt;string&gt;</code> | | String(S) to be converted. |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}</code> | Conversion options. |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}</code> | Conversion options. |

```js
mockingcase.log('foo bar');
Expand All @@ -248,7 +248,7 @@ Overrides console.log input to print the input mOcKiNgCaSe.

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}</code> | Conversion options. |
| [options] | [<code>Options</code>](#Options) | <code>{random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}</code> | Conversion options. |

```js
const mockingcase = require('@strdr4605/mockingcase').overrideConsole();
Expand All @@ -272,8 +272,8 @@ Options for mockingcase
| [random] | <code>boolean</code> | <code>false</code> | If case conversion should be randomized. |
| [onlyLetters] | <code>boolean</code> | <code>false</code> | If non letters characters should be removed. |
| [firstUpper] | <code>boolean</code> | <code>false</code> | 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] | <code>string</code> \| <code>RegExp</code> | <code>null</code> | Characters or substring set to change to uppercase, `upper` has higher priority that `lower`. |
| [lower] | <code>string</code> \| <code>RegExp</code> | <code>null</code> | Characters or substring set to change to lowercase. |
| [upper] | <code>string</code> \| <code>RegExp</code> | <code>''</code> | Characters or substring set to change to uppercase, `upper` has higher priority that `lower`. |
| [lower] | <code>string</code> \| <code>RegExp</code> | <code>''</code> | Characters or substring set to change to lowercase. |

<hr>

Expand Down
18 changes: 9 additions & 9 deletions src/mockingcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* @property {boolean} [firstUpper=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.
* @property {(string | RegExp)} [upper=null] - Characters or substring set to change to uppercase,
* @property {(string | RegExp)} [upper=''] - Characters or substring set to change to uppercase,
* `upper` has higher priority that `lower`.
* @property {(string | RegExp)} [lower=null] - Characters or substring set to change to lowercase.
* @property {(string | RegExp)} [lower=''] - Characters or substring set to change to lowercase.
*/

/**
* Converts the input string(s) to mOcKiNgCaSe.
* @param {(string | string[])} input - String(s) to be converted.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}] - Conversion options.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}] - Conversion options.
* @returns {string} string in mOcKiNgCaSe.
*/
function mockingcase(input = "", options) {
Expand All @@ -23,8 +23,8 @@ function mockingcase(input = "", options) {
random: false,
onlyLetters: false,
firstUpper: false,
upper: null,
lower: null,
upper: "",
lower: "",
},
options,
);
Expand Down Expand Up @@ -71,13 +71,13 @@ function mockingcase(input = "", options) {
/**
* Outputs a message to the console in mOcKiNgCaSe.
* @param {(string | string[])} input - String(S) to be converted.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}] - Conversion options.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}] - Conversion options.
*/
mockingcase.log = (input, options) => console.log(mockingcase(input, options));

/**
* Outputs a mockingcase with default options.
* @param {Options} [defaultOptions={random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}] - Conversion options.
* @param {Options} [defaultOptions={random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}] - Conversion options.
* @returns mockingcase with default options
*/
mockingcase.config = defaultOptions => (input = "", overridedDefaultOptions) => {
Expand All @@ -92,7 +92,7 @@ mockingcase.config = defaultOptions => (input = "", overridedDefaultOptions) =>
mockingcase.overrideString = () => {
/**
* Converts this string to mOcKiNgCaSe.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}] Conversion options.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}] Conversion options.
* @returns {string} The string in mOcKiNgCaSe
* @see mockingcase
*/
Expand All @@ -105,7 +105,7 @@ mockingcase.overrideString = () => {

/**
* Overrides console.log input to print the input mOcKiNgCaSe.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: null, lower: null}] Conversion options.
* @param {Options} [options={random: false, onlyLetters: false, firstUpper: false, upper: '', lower: ''}] Conversion options.
* @returns {function} mockingcase function
* @see mockingcase
*/
Expand Down

0 comments on commit 36f2b1b

Please sign in to comment.