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

toArray.js 733B

12345678910111213141516171819202122
  1. var _setup = require('./_setup.js');
  2. var identity = require('./identity.js');
  3. var isArray = require('./isArray.js');
  4. var _isArrayLike = require('./_isArrayLike.js');
  5. var values = require('./values.js');
  6. var isString = require('./isString.js');
  7. var map = require('./map.js');
  8. // Safely create a real, live array from anything iterable.
  9. var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
  10. function toArray(obj) {
  11. if (!obj) return [];
  12. if (isArray(obj)) return _setup.slice.call(obj);
  13. if (isString(obj)) {
  14. // Keep surrogate pair characters together.
  15. return obj.match(reStrSymbol);
  16. }
  17. if (_isArrayLike(obj)) return map(obj, identity);
  18. return values(obj);
  19. }
  20. module.exports = toArray;