-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contains): add ignoreCase option (#1334)
* Fixes #1303 * Added postal code for nepal * Added NP locale to postal code * Added country code to passport READNE * Added norway identity card * Fix order in readme * Added ignoreCase to contains * Update README
- Loading branch information
1 parent
3223f58
commit e501b9c
Showing
5 changed files
with
36 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import assertString from './util/assertString'; | ||
import toString from './util/toString'; | ||
export default function contains(str, elem) { | ||
import merge from './util/merge'; | ||
var defaulContainsOptions = { | ||
ignoreCase: false | ||
}; | ||
export default function contains(str, elem, options) { | ||
assertString(str); | ||
return str.indexOf(toString(elem)) >= 0; | ||
options = merge(options, defaulContainsOptions); | ||
return options.ignoreCase ? str.toLowerCase().indexOf(toString(elem).toLowerCase()) >= 0 : str.indexOf(toString(elem)) >= 0; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import assertString from './util/assertString'; | ||
import toString from './util/toString'; | ||
import merge from './util/merge'; | ||
|
||
export default function contains(str, elem) { | ||
const defaulContainsOptions = { | ||
ignoreCase: false, | ||
}; | ||
|
||
export default function contains(str, elem, options) { | ||
assertString(str); | ||
return str.indexOf(toString(elem)) >= 0; | ||
options = merge(options, defaulContainsOptions); | ||
return options.ignoreCase ? | ||
str.toLowerCase().indexOf(toString(elem).toLowerCase()) >= 0 : | ||
str.indexOf(toString(elem)) >= 0; | ||
} |
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