CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
takeRight.js40 linesDownload Raw Back to lodash-es
1import baseSlice from './_baseSlice.js';2import toInteger from './toInteger.js';3 4/**5 * Creates a slice of `array` with `n` elements taken from the end.6 *7 * @static8 * @memberOf _9 * @since 3.0.010 * @category Array11 * @param {Array} array The array to query.12 * @param {number} [n=1] The number of elements to take.13 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.14 * @returns {Array} Returns the slice of `array`.15 * @example16 *17 * _.takeRight([1, 2, 3]);18 * // => [3]19 *20 * _.takeRight([1, 2, 3], 2);21 * // => [2, 3]22 *23 * _.takeRight([1, 2, 3], 5);24 * // => [1, 2, 3]25 *26 * _.takeRight([1, 2, 3], 0);27 * // => []28 */29function takeRight(array, n, guard) {30  var length = array == null ? 0 : array.length;31  if (!length) {32    return [];33  }34  n = (guard || n === undefined) ? 1 : toInteger(n);35  n = length - n;36  return baseSlice(array, n < 0 ? 0 : n, length);37}38 39export default takeRight;40 
basant307/AI_Governance_Project · CoolFace