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.

28 lines
792 B

4 years ago
  1. 'use strict';
  2. /**
  3. * Values helper
  4. *
  5. * Retrieve values from [this.items] when it is an array, object or Collection
  6. *
  7. * @returns {*}
  8. * @param items
  9. */
  10. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  11. module.exports = function values(items) {
  12. var valuesArray = [];
  13. if (Array.isArray(items)) {
  14. valuesArray.push.apply(valuesArray, _toConsumableArray(items));
  15. } else if (items.constructor.name === 'Collection') {
  16. valuesArray.push.apply(valuesArray, _toConsumableArray(items.all()));
  17. } else {
  18. Object.keys(items).forEach(function (prop) {
  19. return valuesArray.push(items[prop]);
  20. });
  21. }
  22. return valuesArray;
  23. };