UNPKG
begins-with
Version:
latest (1.1.0)
1.1.0
1.0.0
Checks if string begins with the given target string
github.com/kevva/begins-with
kevva/begins-with
begins-with
/
index.js
8 lines
(6 loc)
•
200 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
'use strict'
;
var
escapeStringRegexp =
require
(
'escape-string-regexp'
);
module
.
exports
=
function
(
str, match
) {
var
regex =
new
RegExp
(
'^'
+
escapeStringRegexp
(match));
return
regex.
test
(str); };