Implement size(collection) — return how many elements a collection holds, no matter which kind of collection it is. An array or string reports its .length; a Map or Set reports its .size; a plain object reports the number of its own enumerable keys. This mirrors Lodash's _.size: one function that measures anything you hand it.
// collection: an array, string, Map, Set, plain object, null, or undefined.
// returns: number — the count of elements (own keys for a plain object).
// null and undefined return 0 rather than throwing.
function size(collection): number;
size([1, 2, 3]); // → 3 (array length)
size('hello'); // → 5 (string length)
size({ a: 1, b: 2 }); // → 2 (own key count)
size(new Map([['a', 1]])); // → 1 (Map .size)
size(new Set([1, 2, 3])); // → 3 (Set .size)
size(null); // → 0 (no throw)
.length; Map and Set use .size; plain objects use the number of keys. Your job is to dispatch to the right one..length, then .size, then fall back to keys. An array also has indexed keys, and a Map has none — picking the wrong order gives the wrong number.null and undefined return 0. Don't throw on missing input — match lodash and answer 0.0.