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
immosquare-cleaner-0.1.60 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.59 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.58 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.57 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.56 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.55 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.54 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.53 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.52 node_modules/lodash/takeRight.js
trusty-cms-6.3.1 node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.51 node_modules/lodash/takeRight.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/takeRight.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/takeRight.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/takeRight.js
immosquare-cleaner-0.1.50 node_modules/lodash/takeRight.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/takeRight.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/takeRight.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/takeRight.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/takeRight.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/takeRight.js