@Override
public void write(OutputStream outputStream) throws IOException {
Context cx = CommonJSEngine.enterContext();
FunctionObject writeFunc = new FunctionObject("bodyWriter", writeMethod, scope);
BoundFunction boundWrite = new BoundFunction(cx, scope, writeFunc, body, new Object[] {outputStream});
Object[] args = {boundWrite};
try {
forEach.call(cx, scope, body, args);
} finally {
Context.exit();