You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

4 years ago
  1. import _curry2 from "./internal/_curry2.js";
  2. import _dispatchable from "./internal/_dispatchable.js";
  3. import _xdrop from "./internal/_xdrop.js";
  4. import slice from "./slice.js";
  5. /**
  6. * Returns all but the first `n` elements of the given list, string, or
  7. * transducer/transformer (or object with a `drop` method).
  8. *
  9. * Dispatches to the `drop` method of the second argument, if present.
  10. *
  11. * @func
  12. * @memberOf R
  13. * @since v0.1.0
  14. * @category List
  15. * @sig Number -> [a] -> [a]
  16. * @sig Number -> String -> String
  17. * @param {Number} n
  18. * @param {*} list
  19. * @return {*} A copy of list without the first `n` elements
  20. * @see R.take, R.transduce, R.dropLast, R.dropWhile
  21. * @example
  22. *
  23. * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
  24. * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz']
  25. * R.drop(3, ['foo', 'bar', 'baz']); //=> []
  26. * R.drop(4, ['foo', 'bar', 'baz']); //=> []
  27. * R.drop(3, 'ramda'); //=> 'da'
  28. */
  29. var drop =
  30. /*#__PURE__*/
  31. _curry2(
  32. /*#__PURE__*/
  33. _dispatchable(['drop'], _xdrop, function drop(n, xs) {
  34. return slice(Math.max(0, n), Infinity, xs);
  35. }));
  36. export default drop;