Closed guyellis closed 8 years ago
@guyellis Great question. I should be using _.toArray
everywhere. The problem is that arguments
returns an object with numeric keys. So if you are doing args[index]
things work just fine, but since its not an array it doesn't have length, map, forEach, etc. In the base mock function I wasn't turning it into an array, because it was only being used there and its clear what its being used for. In the when
function its being passed further into the stack. I didn't want underlying modules to have to worry about wether what they were getting was really and array or not.
:+1:
On these 2 lines: https://github.com/Ellisande/mockolate/blob/master/src/mock/mockFunc.js#L12 https://github.com/Ellisande/mockolate/blob/master/src/mock/mockFunc.js#L28 there are:
const args = arguments;
andconst args = _.toArray(arguments);
Why
_.toArray()
for one and not the other? What's the difference?