I am using node-js and I have this line of code in a file called utils.js
:
const spartial = (func, ...args) => (...rest) => func(...args, ...rest);
The file App.js
contains a class called App
and this class is using the spartial
function in utils.js
.
I have written a unit test using the ava
library which tests App.js
, and when I run the test, I get this error:
Function.prototype.apply was called on #<Object>, which is a object and not a function
and the following line of code is highlighted in red...
1: const spartial = (func, ...args) => (...rest) => func(...args, ...rest);
Does anyone have any idea what is happening here and how I can fix this? I'm not sure if it is the unit test library or not that is causing the issue, but when I run node utils.js
I don't get any error.
This was entirely because I called the spartial
function with the paramaters in the wrong order. I don't know how I didn't see this after looking at it for an hour.