This repository has been archived by the owner on Jan 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95304da
commit b80f712
Showing
10 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import _capitalize from 'lodash/capitalize' | ||
import { convert } from 'util/convert' | ||
|
||
/** | ||
* Converts the first character of string to upper case and the remaining to lower case. | ||
* @function | ||
* @memberof object | ||
* @param {Object} object The object to modify. | ||
* @param {Array|string} path The path of the property to set. | ||
* @return {Object} Returns the updated object. | ||
* @example capitalize({ nested: { a: "a string" } }, 'nested.a') // => { nested: { a: "A string" } } | ||
* @see {@link https://lodash.com/docs#capitalize|lodash.capitalize} for more information. | ||
* @since 0.3.0 | ||
*/ | ||
const capitalize = convert(_capitalize) | ||
export { capitalize, capitalize as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-env jest */ | ||
import { capitalize } from './capitalize' | ||
import { immutaTest } from 'test.utils' | ||
|
||
describe('Capitalize', () => { | ||
|
||
it('should convert the first character of string to upper case and the remaining to lower case', () => { | ||
immutaTest((input, path) => { | ||
const output = capitalize(input, path) | ||
expect(output).toEqual({ nested: { prop: 'A string' } }) | ||
return output | ||
}, { nested: { prop: 'a string' } }, 'nested.prop') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { capizalize } from './capizalize' | ||
import { replace } from './replace' | ||
import { toLower } from './toLower' | ||
import { toUpper } from './toUpper' | ||
|
||
/** | ||
* String functions. | ||
* @namespace string | ||
* @since 0.3.0 | ||
*/ | ||
export { | ||
capizalize, | ||
replace, | ||
toLower, | ||
toUpper, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import _replace from 'lodash/replace' | ||
import { convert } from 'util/convert' | ||
|
||
/** | ||
* Replaces matches for pattern in string with replacement. | ||
* @function | ||
* @memberof object | ||
* @param {Object} object The object to modify. | ||
* @param {Array|string} path The path of the property to set. | ||
* @param {RegExp|string} pattern The pattern to replace. | ||
* @param {Function|string} replacement The match replacement. | ||
* @return {Object} Returns the updated object. | ||
* @example replace({ nested: { a: "Hi Nico" } }, 'nested.a', 'Nico', 'Yvo') // => { nested: { a: "Hi Yvo" } } | ||
* @see {@link https://lodash.com/docs#replace|lodash.replace} for more information. | ||
* @since 0.3.0 | ||
*/ | ||
const replace = convert(_replace) | ||
export { replace, replace as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-env jest */ | ||
import { immutaTest } from 'test.utils' | ||
import { replace } from './replace' | ||
|
||
describe('Replace', () => { | ||
|
||
it('should replace matches for pattern in string with replacement', () => { | ||
immutaTest((input, path) => { | ||
const output = replace(input, path, 'Nico', 'Yvo') | ||
expect(output).toEqual({ nested: { prop: 'Hi Yvo' } }) | ||
return output | ||
}, { nested: { prop: 'Hi Nico' } }, 'nested.prop') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import _toLower from 'lodash/toLower' | ||
import { convert } from 'util/convert' | ||
|
||
/** | ||
* Converts string, as a whole, to lower case just like String#toLowerCase. | ||
* @function | ||
* @memberof object | ||
* @param {Object} object The object to modify. | ||
* @param {Array|string} path The path of the property to set. | ||
* @return {Object} Returns the updated object. | ||
* @example toLower({ nested: { a: "A STRING" } }, 'nested.a') // => { nested: { a: "a string" } } | ||
* @see {@link https://lodash.com/docs#toLower|lodash.toLower} for more information. | ||
* @see {@link https://mdn.io/String/toLowerCase|String.toLowerCase} for more information. | ||
* @since 0.3.0 | ||
*/ | ||
const toLower = convert(_toLower) | ||
export { toLower, toLower as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-env jest */ | ||
import { immutaTest } from 'test.utils' | ||
import { toLower } from './toLower' | ||
|
||
describe('toLower', () => { | ||
|
||
it('should convert string, as a whole, to lower case just like String#toLowerCase', () => { | ||
immutaTest((input, path) => { | ||
const output = toLower(input, path) | ||
expect(output).toEqual({ nested: { prop: 'a string' } }) | ||
return output | ||
}, { nested: { prop: 'A STRING' } }, 'nested.prop') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import _toUpper from 'lodash/toUpper' | ||
import { convert } from 'util/convert' | ||
|
||
/** | ||
* Converts string, as a whole, to upper case just like String#toUpperCase. | ||
* @function | ||
* @memberof object | ||
* @param {Object} object The object to modify. | ||
* @param {Array|string} path The path of the property to set. | ||
* @return {Object} Returns the updated object. | ||
* @example toUpper({ nested: { a: "a string" } }, 'nested.a') // => { nested: { a: "A STRING" } } | ||
* @see {@link https://lodash.com/docs#toUpper|lodash.toUpper} for more information. | ||
* @see {@link https://mdn.io/String/toUpperCase|String.toUpperCase} for more information. | ||
* @since 0.3.0 | ||
*/ | ||
const toUpper = convert(_toUpper) | ||
export { toUpper, toUpper as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-env jest */ | ||
import { immutaTest } from 'test.utils' | ||
import { toUpper } from './toUpper' | ||
|
||
describe('toUpper', () => { | ||
|
||
it('should convert string, as a whole, to upper case just like String#toUpperCase', () => { | ||
immutaTest((input, path) => { | ||
const output = toUpper(input, path) | ||
expect(output).toEqual({ nested: { prop: 'A STRING' } }) | ||
return output | ||
}, { nested: { prop: 'a string' } }, 'nested.prop') | ||
}) | ||
}) |