Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_getView.js 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. /* Built-in method references for those with the same name as other `lodash` methods. */
  2. var nativeMax = Math.max,
  3. nativeMin = Math.min;
  4. /**
  5. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  6. *
  7. * @private
  8. * @param {number} start The start of the view.
  9. * @param {number} end The end of the view.
  10. * @param {Array} transforms The transformations to apply to the view.
  11. * @returns {Object} Returns an object containing the `start` and `end`
  12. * positions of the view.
  13. */
  14. function getView(start, end, transforms) {
  15. var index = -1,
  16. length = transforms.length;
  17. while (++index < length) {
  18. var data = transforms[index],
  19. size = data.size;
  20. switch (data.type) {
  21. case 'drop': start += size; break;
  22. case 'dropRight': end -= size; break;
  23. case 'take': end = nativeMin(end, start + size); break;
  24. case 'takeRight': start = nativeMax(start, end - size); break;
  25. }
  26. }
  27. return { 'start': start, 'end': end };
  28. }
  29. module.exports = getView;