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

toArray.js 656B

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