-
-
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):
trim
, trimEnd
, trimStart
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
45bccc7
commit 4a6f2bc
Showing
14 changed files
with
206 additions
and
6 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
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 @@ | ||
/** | ||
* @file Type Tests - trimEnd | ||
* @module tutils/utils/tests/unit-d/trimEnd | ||
*/ | ||
|
||
import type { TrimEnd } from '#src/types' | ||
import type testSubject from '../trim-end' | ||
|
||
describe('unit-d:utils/trimEnd', () => { | ||
it('should return TrimEnd<T>', () => { | ||
// Arrange | ||
type T = 'foo ' | ||
|
||
// Expect | ||
expectTypeOf<typeof testSubject<T>>().returns.toEqualTypeOf<TrimEnd<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 - trimEnd | ||
* @module tutils/utils/tests/unit/trimEnd | ||
*/ | ||
|
||
import testSubject from '../trim-end' | ||
|
||
describe('unit:utils/trimEnd', () => { | ||
it('should return string without trailing whitespaces', () => { | ||
// Arrange | ||
const string: string = 'foo ' | ||
|
||
// Act + Expect | ||
expect(testSubject(string)).to.equal(string.trimEnd()) | ||
}) | ||
}) |
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 @@ | ||
/** | ||
* @file Type Tests - trimStart | ||
* @module tutils/utils/tests/unit-d/trimStart | ||
*/ | ||
|
||
import type { TrimStart } from '#src/types' | ||
import type testSubject from '../trim-start' | ||
|
||
describe('unit-d:utils/trimStart', () => { | ||
it('should return TrimStart<T>', () => { | ||
// Arrange | ||
type T = ' bar' | ||
|
||
// Expect | ||
expectTypeOf<typeof testSubject<T>>().returns.toEqualTypeOf<TrimStart<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 - trimStart | ||
* @module tutils/utils/tests/unit/trimStart | ||
*/ | ||
|
||
import testSubject from '../trim-start' | ||
|
||
describe('unit:utils/trimStart', () => { | ||
it('should return string without leading whitespaces', () => { | ||
// Arrange | ||
const string: string = ' bar' | ||
|
||
// Act + Expect | ||
expect(testSubject(string)).to.equal(string.trimStart()) | ||
}) | ||
}) |
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 @@ | ||
/** | ||
* @file Type Tests - trim | ||
* @module tutils/utils/tests/unit-d/trim | ||
*/ | ||
|
||
import type { Trim } from '#src/types' | ||
import type testSubject from '../trim' | ||
|
||
describe('unit-d:utils/trim', () => { | ||
it('should return Trim<T>', () => { | ||
// Arrange | ||
type T = ' baz ' | ||
|
||
// Expect | ||
expectTypeOf<typeof testSubject<T>>().returns.toEqualTypeOf<Trim<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 - trim | ||
* @module tutils/utils/tests/unit/trim | ||
*/ | ||
|
||
import testSubject from '../trim' | ||
|
||
describe('unit:utils/trim', () => { | ||
it('should return string without leading and trailing whitespaces', () => { | ||
// Arrange | ||
const string: string = ' baz ' | ||
|
||
// Act + Expect | ||
expect(testSubject(string)).to.equal(string.trim()) | ||
}) | ||
}) |
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,22 @@ | ||
/** | ||
* @file Utilities - trimEnd | ||
* @module tutils/utils/trimEnd | ||
*/ | ||
|
||
import type { TrimEnd } from '#src/types' | ||
|
||
/** | ||
* Removes trailing whitespace characters from `string`. | ||
* | ||
* @see {@linkcode TrimEnd} | ||
* | ||
* @template T - String to trim | ||
* | ||
* @param {T} string - String to trim | ||
* @return {TrimEnd<T>} `string` with trailing whitespaces removed | ||
*/ | ||
function trimEnd<T extends string>(string: T): TrimEnd<T> { | ||
return string.trimEnd<T>() | ||
} | ||
|
||
export default trimEnd |
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,22 @@ | ||
/** | ||
* @file Utilities - trimStart | ||
* @module tutils/utils/trimStart | ||
*/ | ||
|
||
import type { TrimStart } from '#src/types' | ||
|
||
/** | ||
* Removes leading whitespace characters from `string`. | ||
* | ||
* @see {@linkcode TrimStart} | ||
* | ||
* @template T - String to trim | ||
* | ||
* @param {T} string - String to trim | ||
* @return {TrimStart<T>} `string` with leading whitespaces removed | ||
*/ | ||
function trimStart<T extends string>(string: T): TrimStart<T> { | ||
return string.trimStart<T>() | ||
} | ||
|
||
export default trimStart |
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,22 @@ | ||
/** | ||
* @file Utilities - trim | ||
* @module tutils/utils/trim | ||
*/ | ||
|
||
import type { Trim } from '#src/types' | ||
|
||
/** | ||
* Removes leading and trailing whitespace characters from `string`. | ||
* | ||
* @see {@linkcode Trim} | ||
* | ||
* @template T - String to trim | ||
* | ||
* @param {T} string - String to trim | ||
* @return {Trim<T>} `string` with leading and trailing whitespaces removed | ||
*/ | ||
function trim<T extends string>(string: T): Trim<T> { | ||
return string.trim<T>() | ||
} | ||
|
||
export default trim |
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