-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
c8b806a
commit 95cb9b9
Showing
10 changed files
with
169 additions
and
17 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
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 @@ | ||
/** | ||
* @file Type Tests - lowercase | ||
* @module tutils/utils/tests/unit-d/lowercase | ||
*/ | ||
|
||
import type testSubject from '../lowercase' | ||
|
||
describe('unit-d:utils/lowercase', () => { | ||
it('should return Lowercase<T>', () => { | ||
// Arrange | ||
type T = 'STRING' | ||
|
||
// Expect | ||
expectTypeOf<typeof testSubject<T>>().returns.toEqualTypeOf<Lowercase<T>>() | ||
}) | ||
}) |
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 @@ | ||
/** | ||
* @file Unit Tests - lowercase | ||
* @module tutils/utils/tests/unit/lowercase | ||
*/ | ||
|
||
import testSubject from '../lowercase' | ||
|
||
describe('unit:utils/lowercase', () => { | ||
it('should return lowercase string', () => { | ||
// Arrange | ||
const string: string = faker.internet.email().toLowerCase() | ||
|
||
// Act + Expect | ||
expect(testSubject(string)).to.equal(string.toLocaleLowerCase()) | ||
}) | ||
}) |
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 @@ | ||
/** | ||
* @file Type Tests - uppercase | ||
* @module tutils/utils/tests/unit-d/uppercase | ||
*/ | ||
|
||
import type testSubject from '../uppercase' | ||
|
||
describe('unit-d:utils/uppercase', () => { | ||
it('should return Uppercase<T>', () => { | ||
// Arrange | ||
type T = 'string' | ||
|
||
// Expect | ||
expectTypeOf<typeof testSubject<T>>().returns.toEqualTypeOf<Uppercase<T>>() | ||
}) | ||
}) |
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 @@ | ||
/** | ||
* @file Unit Tests - uppercase | ||
* @module tutils/utils/tests/unit/uppercase | ||
*/ | ||
|
||
import testSubject from '../uppercase' | ||
|
||
describe('unit:utils/uppercase', () => { | ||
it('should return uppercase string', () => { | ||
// Arrange | ||
const string: string = faker.person.firstName().toLowerCase() | ||
|
||
// Act + Expect | ||
expect(testSubject(string)).to.equal(string.toLocaleUpperCase()) | ||
}) | ||
}) |
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,27 @@ | ||
/** | ||
* @file Utilities - lowercase | ||
* @module tutils/utils/lowercase | ||
*/ | ||
|
||
import type { OneOrMany } from '#src/types' | ||
|
||
/** | ||
* Converts all alphabetic characters in `string` to lowercase. | ||
* | ||
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase | ||
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase | ||
* | ||
* @template T - String to convert | ||
* | ||
* @param {T} string - String to convert | ||
* @param {OneOrMany<string> | undefined} [locales] - Locales to consider | ||
* @return {Lowercase<T>} Lowercase `string` | ||
*/ | ||
function lowercase<T extends string>( | ||
string: T, | ||
locales?: OneOrMany<string> | undefined | ||
): Lowercase<T> { | ||
return string.toLocaleLowerCase<T>(locales) | ||
} | ||
|
||
export default lowercase |
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,27 @@ | ||
/** | ||
* @file Utilities - uppercase | ||
* @module tutils/utils/uppercase | ||
*/ | ||
|
||
import type { OneOrMany } from '#src/types' | ||
|
||
/** | ||
* Converts all alphabetic characters in `string` to uppercase. | ||
* | ||
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase | ||
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
* | ||
* @template T - String to convert | ||
* | ||
* @param {T} string - String to convert | ||
* @param {OneOrMany<string> | undefined} [locales] - Locales to consider | ||
* @return {Uppercase<T>} Uppercase `string` | ||
*/ | ||
function uppercase<T extends string>( | ||
string: T, | ||
locales?: OneOrMany<string> | undefined | ||
): Uppercase<T> { | ||
return string.toLocaleUpperCase<T>(locales) | ||
} | ||
|
||
export default uppercase |
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 |
---|---|---|
@@ -1,17 +1,49 @@ | ||
interface String { | ||
/** | ||
* Converts all the alphabetic characters in a string to lowercase. | ||
* | ||
* @return {string} Lowercase string | ||
*/ | ||
toLowerCase(): Lowercase<string> | ||
import type { OneOrMany } from '@flex-development/tutils' | ||
|
||
/** | ||
* Converts all alphabetic characters to lowercase, taking into account the | ||
* host environment's current locale. | ||
* | ||
* @param {string | string[]} [locales] - Locales to consider | ||
* @return {string} Lowercase string | ||
*/ | ||
toLocaleLowerCase(): Lowercase<string> | ||
declare global { | ||
interface String { | ||
/** | ||
* Converts all alphabetic characters to lowercase, taking into account the | ||
* host environment's current locale. | ||
* | ||
* @template T - String being converted | ||
* | ||
* @param {OneOrMany<string> | undefined} [locales] - Locales to consider | ||
* @return {T} Lowercase string | ||
*/ | ||
toLocaleLowerCase<T extends string>( | ||
locales?: OneOrMany<string> | undefined | ||
): Lowercase<T> | ||
|
||
/** | ||
* Converts all alphabetic characters to uppercase, taking into account the | ||
* host environment's current locale. | ||
* | ||
* @template T - String being converted | ||
* | ||
* @param {OneOrMany<string> | undefined} [locales] - Locales to consider | ||
* @return {T} Lowercase string | ||
*/ | ||
toLocaleUpperCase<T extends string>( | ||
locales?: OneOrMany<string> | undefined | ||
): Uppercase<T> | ||
|
||
/** | ||
* Converts all the alphabetic characters in a string to lowercase. | ||
* | ||
* @template T - String being converted | ||
* | ||
* @return {Lowercase<T>} Lowercase string | ||
*/ | ||
toLowerCase<T extends string>(): Lowercase<T> | ||
|
||
/** | ||
* Converts all the alphabetic characters in a string to uppercase. | ||
* | ||
* @template T - String being converted | ||
* | ||
* @return {Uppercase<T>} Uppercase string | ||
*/ | ||
toUpperCase<T extends string>(): Uppercase<T> | ||
} | ||
} |