UNPKG

883 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var length =
6/*#__PURE__*/
7require("./length");
8
9var slice =
10/*#__PURE__*/
11require("./slice");
12/**
13 * Splits a given list or string at a given index.
14 *
15 * @func
16 * @memberOf R
17 * @since v0.19.0
18 * @category List
19 * @sig Number -> [a] -> [[a], [a]]
20 * @sig Number -> String -> [String, String]
21 * @param {Number} index The index where the array/string is split.
22 * @param {Array|String} array The array/string to be split.
23 * @return {Array}
24 * @example
25 *
26 * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]]
27 * R.splitAt(5, 'hello world'); //=> ['hello', ' world']
28 * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r']
29 */
30
31
32var splitAt =
33/*#__PURE__*/
34_curry2(function splitAt(index, array) {
35 return [slice(0, index, array), slice(index, length(array), array)];
36});
37
38module.exports = splitAt;
\No newline at end of file