-
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(stringlike): adding case sensitive matching with multi character…
… match *
- Loading branch information
1 parent
43646f0
commit e5f2fc8
Showing
7 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,11 +1,13 @@ | ||
import {stringEquals} from './string/stringEquals'; | ||
import {stringEqualsIgnoreCase} from './string/stringEqualsIgnoreCase'; | ||
import {stringLike} from './string/stringLike'; | ||
import {stringNotEquals} from './string/stringNotEquals'; | ||
import {stringNotEqualsIgnoreCase} from './string/stringNotEqualsIgnoreCase'; | ||
|
||
export const operators: Record<string, unknown>={ | ||
stringEquals, | ||
stringEqualsIgnoreCase, | ||
stringLike, | ||
stringNotEquals, | ||
stringNotEqualsIgnoreCase | ||
}; |
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 { stringLike } from './stringLike'; | ||
|
||
describe('stringLike', () => { | ||
it('returns true', () => { | ||
expect(stringLike('newHouse', 'new*')).toBeTruthy; | ||
expect(stringLike('topSecret', '*Secret')).toBeTruthy; | ||
expect(stringLike('hi', 'hi')).toBeTruthy; | ||
}); | ||
|
||
it('returns false', () => { | ||
expect(stringLike('NewHouse', 'new*')).toBeFalsy; | ||
expect(stringLike('TopSecret', '*Secret')).toBeFalsy; | ||
expect(stringLike('hi', 'no')).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,24 @@ | ||
import {Matcher} from '../../Matcher'; | ||
|
||
/** | ||
* Case-sensitive matching. The values can include a multi-character match wildcard (*) anywhere in the string. | ||
* | ||
* @since 4.5.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 like `expected value`. | ||
* @example | ||
* ```javascript | ||
* stringLike('newHouse', 'new*') | ||
* // => true | ||
* | ||
* stringLike('House', 'new*') | ||
* // => false | ||
* ``` | ||
*/ | ||
export function stringLike(data: string, expected: string): boolean { | ||
return ( | ||
new Matcher(data).match(expected) | ||
); | ||
} |