source: node_modules/ramda/es/test.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 839 bytes
Line 
1import _cloneRegExp from "./internal/_cloneRegExp.js";
2import _curry2 from "./internal/_curry2.js";
3import _isRegExp from "./internal/_isRegExp.js";
4import 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
23var 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
33export default test;
Note: See TracBrowser for help on using the repository browser.