main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
839 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _cloneRegExp from "./internal/_cloneRegExp.js";
|
---|
| 2 | import _curry2 from "./internal/_curry2.js";
|
---|
| 3 | import _isRegExp from "./internal/_isRegExp.js";
|
---|
| 4 | import toString from "./toString.js";
|
---|
| 5 | /**
|
---|
| 6 | * Determines whether a given string matches a given regular expression.
|
---|
| 7 | *
|
---|
| 8 | * @func
|
---|
| 9 | * @memberOf R
|
---|
| 10 | * @since v0.12.0
|
---|
| 11 | * @category String
|
---|
| 12 | * @sig RegExp -> String -> Boolean
|
---|
| 13 | * @param {RegExp} pattern
|
---|
| 14 | * @param {String} str
|
---|
| 15 | * @return {Boolean}
|
---|
| 16 | * @see R.match
|
---|
| 17 | * @example
|
---|
| 18 | *
|
---|
| 19 | * R.test(/^x/, 'xyz'); //=> true
|
---|
| 20 | * R.test(/^y/, 'xyz'); //=> false
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | var test =
|
---|
| 24 | /*#__PURE__*/
|
---|
| 25 | _curry2(function test(pattern, str) {
|
---|
| 26 | if (!_isRegExp(pattern)) {
|
---|
| 27 | throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString(pattern));
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | return _cloneRegExp(pattern).test(str);
|
---|
| 31 | });
|
---|
| 32 |
|
---|
| 33 | export default test; |
---|
Note:
See
TracBrowser
for help on using the repository browser.