From 0d61dae945844c8487c12bc424e888c75079aed3 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Sun, 5 Mar 2017 20:24:06 -0800 Subject: [PATCH] Use regex.test(str) instead of str.match(regex) 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 --- modules/isPrefixedProperty.js | 2 +- modules/isPrefixedValue.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/isPrefixedProperty.js b/modules/isPrefixedProperty.js index 616ff4b..ed055b7 100644 --- a/modules/isPrefixedProperty.js +++ b/modules/isPrefixedProperty.js @@ -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) } diff --git a/modules/isPrefixedValue.js b/modules/isPrefixedValue.js index c6ea983..4320a34 100644 --- a/modules/isPrefixedValue.js +++ b/modules/isPrefixedValue.js @@ -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) }