-
-
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.
feat(utils):
isLowercase
, isUppercase
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
249e217
commit 45bccc7
Showing
7 changed files
with
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @file Type Tests - isLowercase | ||
* @module tutils/utils/tests/unit-d/isLowercase | ||
*/ | ||
|
||
import type testSubject from '../is-lowercase' | ||
|
||
describe('unit-d:utils/isLowercase', () => { | ||
it('should guard Lowercase<T>', () => { | ||
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<Lowercase<string>>() | ||
}) | ||
}) |
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 - isLowercase | ||
* @module tutils/utils/tests/unit/isLowercase | ||
*/ | ||
|
||
import testSubject from '../is-lowercase' | ||
|
||
describe('unit:utils/isLowercase', () => { | ||
it('should return false if value is not lowercase string', () => { | ||
expect(testSubject(faker.string.sample().toUpperCase())).to.be.false | ||
}) | ||
|
||
it('should return true if value is lowercase string', () => { | ||
expect(testSubject(faker.string.sample().toLowerCase())).to.be.true | ||
}) | ||
}) |
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,12 @@ | ||
/** | ||
* @file Type Tests - isUppercase | ||
* @module tutils/utils/tests/unit-d/isUppercase | ||
*/ | ||
|
||
import type testSubject from '../is-uppercase' | ||
|
||
describe('unit-d:utils/isUppercase', () => { | ||
it('should guard Uppercase<T>', () => { | ||
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<Uppercase<string>>() | ||
}) | ||
}) |
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 - isUppercase | ||
* @module tutils/utils/tests/unit/isUppercase | ||
*/ | ||
|
||
import testSubject from '../is-uppercase' | ||
|
||
describe('unit:utils/isUppercase', () => { | ||
it('should return false if value is not uppercase string', () => { | ||
expect(testSubject(faker.string.sample().toLowerCase())).to.be.false | ||
}) | ||
|
||
it('should return true if value is uppercase string', () => { | ||
expect(testSubject(faker.string.sample().toUpperCase())).to.be.true | ||
}) | ||
}) |
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,19 @@ | ||
/** | ||
* @file Utilities - isLowercase | ||
* @module tutils/utils/isLowercase | ||
*/ | ||
|
||
import isString from './is-string' | ||
import lowercase from './lowercase' | ||
|
||
/** | ||
* Checks if `value` is a lowercase string. | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is Lowercase<string>} `true` if `value` is lowercase string | ||
*/ | ||
const isLowercase = (value: unknown): value is Lowercase<string> => { | ||
return isString(value) && value === lowercase(value) | ||
} | ||
|
||
export default isLowercase |
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,19 @@ | ||
/** | ||
* @file Utilities - isUppercase | ||
* @module tutils/utils/isUppercase | ||
*/ | ||
|
||
import isString from './is-string' | ||
import uppercase from './uppercase' | ||
|
||
/** | ||
* Checks if `value` is an uppercase string. | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is Uppercase<string>} `true` if `value` is uppercase string | ||
*/ | ||
const isUppercase = (value: unknown): value is Uppercase<string> => { | ||
return isString(value) && value === uppercase(value) | ||
} | ||
|
||
export default isUppercase |