in src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingFunction.java [38:52]
public Object call(final Context cx, final Scriptable scope, Scriptable thisObj, Object[] args) {
if (args.length == 0) {
return Context.getUndefinedValue();
}
if (!(args[0] instanceof Function)) {
throw new IllegalArgumentException("Timing function must receive a function as the first argument");
}
final Function function = (Function) args[0];
return EventLoopInterop.schedule(cx, new Runnable() {
@Override
public void run() {
JsUtils.callFn(function, cx, scope, null, new Object[0]);
}
});
}