-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stringoperators): adding new string operators
stringEqualsIgnoreCase, stringNotEquals, stringNotEqualsIgnoreCase
- Loading branch information
1 parent
0ab50bd
commit 83665fa
Showing
7 changed files
with
118 additions
and
2 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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import {stringEquals} from './string/stringEquals'; | ||
import {stringEqualsIgnoreCase} from './string/stringEqualsIgnoreCase'; | ||
import {stringNotEquals} from './string/stringNotEquals'; | ||
import {stringNotEqualsIgnoreCase} from './string/stringNotEqualsIgnoreCase'; | ||
|
||
export const operators: Record<string, unknown>={ | ||
stringEquals | ||
stringEquals, | ||
stringEqualsIgnoreCase, | ||
stringNotEquals, | ||
stringNotEqualsIgnoreCase | ||
}; | ||
|
15 changes: 15 additions & 0 deletions
15
src/conditionOperators/string/stringEqualsIgnoreCase.test.ts
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,15 @@ | ||
import { stringEqualsIgnoreCase } from './stringEqualsIgnoreCase'; | ||
|
||
describe('stringEqualsIgnoreCase', () => { | ||
it('returns true', () => { | ||
expect(stringEqualsIgnoreCase('secrets', 'Secrets')).toBeTruthy; | ||
expect(stringEqualsIgnoreCase('newHouse', 'NewHouse')).toBeTruthy; | ||
expect(stringEqualsIgnoreCase('', '')).toBeTruthy; | ||
}); | ||
|
||
it('returns false', () => { | ||
expect(stringEqualsIgnoreCase('secrets', 'house')).toBeFalsy; | ||
expect(stringEqualsIgnoreCase('house', 'secrets')).toBeFalsy; | ||
expect(stringEqualsIgnoreCase('', '1')).toBeFalsy; | ||
}); | ||
}); |
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 @@ | ||
/** | ||
* Exact matching, ignoring case. | ||
* | ||
* @since 4.4.0 | ||
* @category String | ||
* @param {string} data The value to be compared. | ||
* @param {string} expected The expected value. | ||
* @returns {boolean} Returns `true` if `value` is equal to `expected value`. | ||
* @example | ||
* ```javascript | ||
* stringEqualsIgnoreCase('hi', 'Hi') | ||
* // => true | ||
* | ||
* stringEqualsIgnoreCase('hi', 'no') | ||
* // => false | ||
* ``` | ||
*/ | ||
export function stringEqualsIgnoreCase(data: string, expected: string): boolean { | ||
return ( | ||
data.toLowerCase() === expected.toLowerCase() | ||
); | ||
} |
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,15 @@ | ||
import { stringNotEquals } from './stringNotEquals'; | ||
|
||
describe('stringNotEquals', () => { | ||
it('returns true', () => { | ||
expect(stringNotEquals('secrets', 'Secrets')).toBeTruthy; | ||
expect(stringNotEquals('house', 'secrets')).toBeTruthy; | ||
expect(stringNotEquals('', '1')).toBeTruthy; | ||
}); | ||
|
||
it('returns false', () => { | ||
expect(stringNotEquals('secrets', 'secrets')).toBeFalsy; | ||
expect(stringNotEquals('house', 'house')).toBeFalsy; | ||
expect(stringNotEquals('', '')).toBeFalsy; | ||
}); | ||
}); |
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 @@ | ||
/** | ||
* Negated string matching. | ||
* | ||
* @since 4.4.0 | ||
* @category String | ||
* @param {string} data The value to be compared. | ||
* @param {string} expected The expected value. | ||
* @returns {boolean} Returns `true` if `value` is not equal to `expected value`. | ||
* @example | ||
* ```javascript | ||
* stringNotEquals('hi', 'no') | ||
* // => true | ||
* | ||
* stringNotEquals('hi', 'hi') | ||
* // => false | ||
* ``` | ||
*/ | ||
export function stringNotEquals(data: string, expected: string): boolean { | ||
return ( | ||
data !== expected | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/conditionOperators/string/stringNotEqualsIgnoreCase.test.ts
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,15 @@ | ||
import { stringNotEqualsIgnoreCase } from './stringNotEqualsIgnoreCase'; | ||
|
||
describe('stringNotEqualsIgnoreCase', () => { | ||
it('returns true', () => { | ||
expect(stringNotEqualsIgnoreCase('secrets', 'house')).toBeTruthy; | ||
expect(stringNotEqualsIgnoreCase('house', 'secrets')).toBeTruthy; | ||
expect(stringNotEqualsIgnoreCase('', '1')).toBeTruthy; | ||
}); | ||
|
||
it('returns false', () => { | ||
expect(stringNotEqualsIgnoreCase('secrets', 'Secrets')).toBeFalsy; | ||
expect(stringNotEqualsIgnoreCase('newHouse', 'NewHouse')).toBeFalsy; | ||
expect(stringNotEqualsIgnoreCase('', '')).toBeFalsy; | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
src/conditionOperators/string/stringNotEqualsIgnoreCase.ts
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 @@ | ||
/** | ||
* Negated string matching, ignoring case. | ||
* | ||
* @since 4.4.0 | ||
* @category String | ||
* @param {string} data The value to be compared. | ||
* @param {string} expected The expected value. | ||
* @returns {boolean} Returns `true` if `value` is not equal to `expected value`. | ||
* @example | ||
* ```javascript | ||
* stringNotEqualsIgnoreCase('hi', 'no') | ||
* // => true | ||
* | ||
* stringNotEqualsIgnoreCase('hi', 'Hi') | ||
* // => false | ||
* ``` | ||
*/ | ||
export function stringNotEqualsIgnoreCase(data: string, expected: string): boolean { | ||
return ( | ||
data.toLowerCase() !== expected.toLowerCase() | ||
); | ||
} |