main
Last change
on this file since b78c0c1 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
850 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _curry2 from "./internal/_curry2.js";
|
---|
| 2 | import equals from "./equals.js";
|
---|
| 3 | import take from "./take.js";
|
---|
| 4 | /**
|
---|
| 5 | * Checks if a list starts with the provided sublist.
|
---|
| 6 | *
|
---|
| 7 | * Similarly, checks if a string starts with the provided substring.
|
---|
| 8 | *
|
---|
| 9 | * @func
|
---|
| 10 | * @memberOf R
|
---|
| 11 | * @since v0.24.0
|
---|
| 12 | * @category List
|
---|
| 13 | * @sig [a] -> [a] -> Boolean
|
---|
| 14 | * @sig String -> String -> Boolean
|
---|
| 15 | * @param {*} prefix
|
---|
| 16 | * @param {*} list
|
---|
| 17 | * @return {Boolean}
|
---|
| 18 | * @see R.endsWith
|
---|
| 19 | * @example
|
---|
| 20 | *
|
---|
| 21 | * R.startsWith('a', 'abc') //=> true
|
---|
| 22 | * R.startsWith('b', 'abc') //=> false
|
---|
| 23 | * R.startsWith(['a'], ['a', 'b', 'c']) //=> true
|
---|
| 24 | * R.startsWith(['b'], ['a', 'b', 'c']) //=> false
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | var startsWith =
|
---|
| 28 | /*#__PURE__*/
|
---|
| 29 | _curry2(function (prefix, list) {
|
---|
| 30 | return equals(take(prefix.length, list), prefix);
|
---|
| 31 | });
|
---|
| 32 |
|
---|
| 33 | export default startsWith; |
---|
Note:
See
TracBrowser
for help on using the repository browser.