source: node_modules/ramda/es/slice.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: 1.2 KB
RevLine 
[d24f17c]1import _checkForMethod from "./internal/_checkForMethod.js";
2import _curry3 from "./internal/_curry3.js";
3/**
4 * Returns the elements of the given list or string (or object with a `slice`
5 * method) from `fromIndex` (inclusive) to `toIndex` (exclusive).
6 *
7 * Dispatches to the `slice` method of the third argument, if present.
8 *
9 * @func
10 * @memberOf R
11 * @since v0.1.4
12 * @category List
13 * @sig Number -> Number -> [a] -> [a]
14 * @sig Number -> Number -> String -> String
15 * @param {Number} fromIndex The start index (inclusive).
16 * @param {Number} toIndex The end index (exclusive).
17 * @param {*} list
18 * @return {*}
19 * @example
20 *
21 * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
22 * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
23 * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
24 * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
25 * R.slice(0, 3, 'ramda'); //=> 'ram'
26 */
27
28var slice =
29/*#__PURE__*/
30_curry3(
31/*#__PURE__*/
32_checkForMethod('slice', function slice(fromIndex, toIndex, list) {
33 return Array.prototype.slice.call(list, fromIndex, toIndex);
34}));
35
36export default slice;
Note: See TracBrowser for help on using the repository browser.