Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"typedoc-material-theme": "^1.3.0"
},
"pnpm": {
"onlyBuiltDependencies": [
"@biomejs/biome",
"esbuild"
]
"onlyBuiltDependencies": ["@biomejs/biome", "esbuild"]
}
}
11 changes: 11 additions & 0 deletions src/ts/strings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ describe('endsWithOneOf', () => {
expect(strings.endsWithOneOf('baa', ['ab', 'ac'])).toBe(false);
});
});

describe('iEqual', () => {
it('returns true when strings are equal', () => {
expect(strings.iEqual('A', 'a')).toBe(true);
expect(strings.iEqual('Hello, World!', 'hello, world!')).toBe(true);
});

it('returns false when strings are not equal', () => {
expect(strings.iEqual('a', 'b')).toBe(false);
});
});
15 changes: 15 additions & 0 deletions src/ts/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ export function endsWithOneOf(str: string, strings: string[]): boolean {

return false;
}

/** Case insensitive equality. Returns true if `left.toLowerCase()` and `right.toLowerCase()` are equal.
*
* @param left
* @param right
* @returns
*
* ## Usage
* ```ts
* iEqual('Hello, World!', 'hello, World!'); // true
* ```
*/
export function iEqual(left: string, right: string): boolean {
return left.toLowerCase() === right.toLowerCase();
}
Loading