Function.prototype.apply 是在 #<Object> 上调用的,它是一个对象而不是函数

Function.prototype.apply was called on #<Object>, which is a object and not a function

我正在使用 node-js,我在一个名为 utils.js:

的文件中有这行代码
const spartial = (func, ...args) => (...rest) => func(...args, ...rest);

文件 App.js 包含一个名为 App 的 class,这个 class 正在使用 utils.js 中的 spartial 函数。

我使用 ava 库编写了一个单元测试来测试 App.js,当我 运行 测试时,我得到这个错误:

Function.prototype.apply was called on #<Object>, which is a object and not a function

下面的代码行以红色突出显示...

 1: const spartial = (func, ...args) => (...rest) => func(...args, ...rest);

有谁知道这里发生了什么以及我该如何解决这个问题?我不确定是不是单元测试库导致了这个问题,但是当我 运行 node utils.js 我没有收到任何错误。

这完全是因为我用错误的顺序调用了spartial函数。不知道看了一个小时怎么没看到这个。