Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: move some regexes to constants
- Loading branch information
Bo Lingen
committed
Jan 15, 2019
1 parent
7a1057b
commit a87e0a7
Showing
4 changed files
with
15 additions
and
4 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,8 +1,9 @@ | ||
import isString from './is-string' | ||
import isNumber from './is-number' | ||
import { NUMERIC_REGEX } from './constants' | ||
|
||
export default function isNumeric (value) { | ||
if (isNumber(value)) return true | ||
if (!isString(value)) return false | ||
return (/^((?:\d+)?\.?(?:\d+)?)$/).test(value) | ||
return NUMERIC_REGEX.test(value) | ||
} |
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,5 +1,10 @@ | ||
import { | ||
BRACKETED_REGEX, | ||
LEFT_RIGHT_DOT_REGEX | ||
} from '../constants' | ||
|
||
export default function _normalizePath (path) { | ||
return path | ||
.replace(/\[([^[\]]+)\]/g, '.$1') | ||
.replace(/^[.]*|[.]*$/g, '') | ||
.replace(BRACKETED_REGEX, '.$1') // bracketed path link | ||
.replace(LEFT_RIGHT_DOT_REGEX, '') // leading or trailing dots | ||
} |
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