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:
836 bytes
|
Line | |
---|
1 | import _curry2 from "./internal/_curry2.js";
|
---|
2 | import length from "./length.js";
|
---|
3 | import slice from "./slice.js";
|
---|
4 | /**
|
---|
5 | * Splits a given list or string at a given index.
|
---|
6 | *
|
---|
7 | * @func
|
---|
8 | * @memberOf R
|
---|
9 | * @since v0.19.0
|
---|
10 | * @category List
|
---|
11 | * @sig Number -> [a] -> [[a], [a]]
|
---|
12 | * @sig Number -> String -> [String, String]
|
---|
13 | * @param {Number} index The index where the array/string is split.
|
---|
14 | * @param {Array|String} array The array/string to be split.
|
---|
15 | * @return {Array}
|
---|
16 | * @example
|
---|
17 | *
|
---|
18 | * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]]
|
---|
19 | * R.splitAt(5, 'hello world'); //=> ['hello', ' world']
|
---|
20 | * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r']
|
---|
21 | */
|
---|
22 |
|
---|
23 | var splitAt =
|
---|
24 | /*#__PURE__*/
|
---|
25 | _curry2(function splitAt(index, array) {
|
---|
26 | return [slice(0, index, array), slice(index, length(array), array)];
|
---|
27 | });
|
---|
28 |
|
---|
29 | export default splitAt; |
---|
Note:
See
TracBrowser
for help on using the repository browser.