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.

14 lines
367 B

4 years ago
  1. 'use strict';
  2. var values = require('../helpers/values');
  3. module.exports = function nth(n) {
  4. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  5. var items = values(this.items);
  6. var collection = items.slice(offset).filter(function (item, index) {
  7. return index % n === 0;
  8. });
  9. return new this.constructor(collection);
  10. };