Sha256: e82c0b9b868d9cd082f8a4af0c3c7b94de3bcbbda83f7aa333972018bf7f9589

Contents?: true

Size: 930 Bytes

Versions: 273

Compression:

Stored size: 930 Bytes

Contents

var baseSlice = require('./_baseSlice'),
    toInteger = require('./toInteger');

/**
 * Creates a slice of `array` with `n` elements taken from the end.
 *
 * @static
 * @memberOf _
 * @since 3.0.0
 * @category Array
 * @param {Array} array The array to query.
 * @param {number} [n=1] The number of elements to take.
 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
 * @returns {Array} Returns the slice of `array`.
 * @example
 *
 * _.takeRight([1, 2, 3]);
 * // => [3]
 *
 * _.takeRight([1, 2, 3], 2);
 * // => [2, 3]
 *
 * _.takeRight([1, 2, 3], 5);
 * // => [1, 2, 3]
 *
 * _.takeRight([1, 2, 3], 0);
 * // => []
 */
function takeRight(array, n, guard) {
  var length = array == null ? 0 : array.length;
  if (!length) {
    return [];
  }
  n = (guard || n === undefined) ? 1 : toInteger(n);
  n = length - n;
  return baseSlice(array, n < 0 ? 0 : n, length);
}

module.exports = takeRight;

Version data entries

273 entries across 271 versions & 29 rubygems

Version Path
locomotivecms-3.4.0 app/javascript/node_modules/lodash/takeRight.js
cortex-0.1.3 spec/dummy/node_modules/lodash/takeRight.js
sumomo-0.8.3 data/sumomo/api_modules/node_modules/lodash/takeRight.js
sumomo-0.8.2 data/sumomo/api_modules/node_modules/lodash/takeRight.js
sumomo-0.8.1 data/sumomo/api_modules/node_modules/lodash/takeRight.js
condenser-0.0.4 lib/condenser/processors/node_modules/lodash/takeRight.js
ela-4.0.0 node_modules/lodash/takeRight.js
ela-3.4.3 node_modules/lodash/takeRight.js
ela-3.4.2 node_modules/lodash/takeRight.js
ela-3.4.0 node_modules/lodash/takeRight.js
ela-3.3.1 node_modules/lodash/takeRight.js
dragonfly_puppeteer-0.1.0 node_modules/lodash/takeRight.js
ela-3.3.0 node_modules/lodash/takeRight.js
ela-3.2.0 node_modules/lodash/takeRight.js
ela-3.1.1 node_modules/lodash/takeRight.js
ela-3.1.0 node_modules/lodash/takeRight.js
ela-3.0.0 node_modules/lodash/takeRight.js
ela-2.0.0 node_modules/lodash/takeRight.js
ela-1.1.0 node_modules/lodash/takeRight.js
sumomo-0.8.0 data/sumomo/api_modules/node_modules/lodash/takeRight.js