invoke method
Calls the function, collapsing the result list the way JavaScript does: no results gives null, one result gives the value itself and several results give the list.
Implementation
Object? invoke(List<Object?> arguments) {
final results = call(arguments);
if (results.isEmpty) return null;
if (results.length == 1) return results.first;
return results;
}