| 1551 | // Safely create a real, live array from anything iterable. |
| 1552 | var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; |
| 1553 | function toArray(obj) { |
| 1554 | if (!obj) return []; |
| 1555 | if (isArray(obj)) return slice.call(obj); |
| 1556 | if (isString(obj)) { |
| 1557 | // Keep surrogate pair characters together. |
| 1558 | return obj.match(reStrSymbol); |
| 1559 | } |
| 1560 | if (isArrayLike(obj)) return map(obj, identity); |
| 1561 | return values(obj); |
| 1562 | } |
| 1563 | |
| 1564 | // Sample **n** random values from a collection using the modern version of the |
| 1565 | // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle). |