source: frontend/node_modules/underscore/modules/toArray.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 694 bytes
Line 
1import isArray from './isArray.js';
2import { slice } from './_setup.js';
3import isString from './isString.js';
4import isArrayLike from './_isArrayLike.js';
5import map from './map.js';
6import identity from './identity.js';
7import values from './values.js';
8
9// Safely create a real, live array from anything iterable.
10var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
11export default function toArray(obj) {
12 if (!obj) return [];
13 if (isArray(obj)) return slice.call(obj);
14 if (isString(obj)) {
15 // Keep surrogate pair characters together.
16 return obj.match(reStrSymbol);
17 }
18 if (isArrayLike(obj)) return map(obj, identity);
19 return values(obj);
20}
Note: See TracBrowser for help on using the repository browser.