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.

loop.js 554 B

3 years ago
1234567891011121314151617181920212223
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var loopable = function loopable(i, length) {
  6. var props = {};
  7. var setProp = function setProp(name) {
  8. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  9. props[name] = value;
  10. };
  11. i === 0 && setProp('first-child');
  12. i === length - 1 && setProp('last-child');
  13. (i === 0 || i % 2 === 0) && setProp('even');
  14. Math.abs(i % 2) === 1 && setProp('odd');
  15. setProp('nth-child', i);
  16. return props;
  17. };
  18. exports.default = loopable;