source: node_modules/ramda/src/splitAt.js

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: 892 bytes
Line 
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2.js");
4
5var length =
6/*#__PURE__*/
7require("./length.js");
8
9var slice =
10/*#__PURE__*/
11require("./slice.js");
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;
Note: See TracBrowser for help on using the repository browser.