Skip to content

Commit

Permalink
Use regex.test(str) instead of str.match(regex)
Browse files Browse the repository at this point in the history
In both of these places, we really care about a boolean regex match so
we can use the much faster regex.test instead of str.match.

https://jsperf.com/str-match-vs-regex-test/1
  • Loading branch information
lencioni committed Mar 6, 2017
1 parent b596706 commit 0d61dae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/isPrefixedProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
const regex = /^(Webkit|Moz|O|ms)/

export default function isPrefixedProperty(property: string): boolean {
return property.match(regex) !== null
return regex.test(property)
}
2 changes: 1 addition & 1 deletion modules/isPrefixedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
const regex = /-webkit-|-moz-|-ms-/

export default function isPrefixedValue(value: any): boolean {
return typeof value === 'string' && value.match(regex) !== null
return typeof value === 'string' && regex.test(value)
}

0 comments on commit 0d61dae

Please sign in to comment.