jashkenas/underscore — pull request #1406 by braddunbar (2014-01-16 22:34:55+00:00)
Title: _.keys accepts non-object arguments.

Some time ago, an optimization was accepted for `_.each` (10695ba5) that uses `_.keys` for iteration instead of `for (var prop in obj)`. This has broken the usage of `_.each(false, ...)` and friends by throwing instead of acting as a no-op. I don't see a good reason we should throw at all on non-objects and I propose that we do not.

Further, the `_.keys` optimization has been used in several other methods that now throw on non-object arguments (`pairs`, `invert`, `size`, `values`). I've commented on this before in #1286 and I still think these micro-optimizations are much less important than not throwing unexpectedly, especially in a backwards incompatible manner.

*Note: The actual usage wasn't `_.each(false, ...)`. It was `_.each(unexpectedVaryingReturnType(), ...)`.*