MCPcopy Index your code
hub / github.com/jashkenas/underscore / toArray

Function toArray

underscore-node-f.cjs:1546–1555  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

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

Callers 1

sampleFunction · 0.70

Calls 2

mapFunction · 0.70
valuesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…