anchor.diff:  %% Map phase with anonymous function
   handle_cast({dispatch, _Requestor, JobId, {Sender, {map, {jsanon, JS}, Arg, _Acc},
                                               Value,
  -                                            KeyData, _BKey}}, #state{ctx=Ctx}=State) ->
  -    {Result, UpdatedState} = case define_anon_js(JS, State) of
  -                                 {ok, FunName, NewState} ->
  -                                     JsonValue = riak_object:to_json(Value),
  -                                     JsonArg = jsonify_arg(Arg),
  -                                     case invoke_js(Ctx, FunName, [JsonValue, KeyData, JsonArg]) of
  -                                         {ok, R} ->
  -                                             {{ok, R}, NewState};
  -                                         Error ->
  -                                             {Error, State}
  -                                     end;
  -                                 {Error, undefined, NewState} ->
  -                                     {Error, NewState}
  -                             end,
  +                                            KeyData, _BKey}}, State) ->
  +    JsonValue = riak_object:to_json(Value),
  +    JsonArg = jsonify_arg(Arg),
  +    {Result, UpdatedState} = define_invoke_anon_js(JS, [JsonValue, KeyData, JsonArg], State),
       FinalState = case Result of
                        {ok, ReturnValue} ->
                            riak_core_vnode:send_command(Sender, {mapexec_reply, JobId, ReturnValue}),
  
positive.code:     Reply = invoke_js(Ctx, JS, [Reduced, Arg]),
      riak_kv_js_manager:mark_idle(),
      {reply, Reply, State};
  %% Pre-commit hook with named function
  handle_call({dispatch, _JobId, {{jsfun, JS}, Obj}}, _From, #state{ctx=Ctx}=State) ->
      Reply = invoke_js(Ctx, JS, [riak_object:to_json(Obj)]),
  
negative.code:     {ok, State}.
  
  %% Internal functions
  define_invoke_anon_js(JS, Args, #state{ctx=Ctx}=State) ->
      case define_anon_js(JS, State) of
          {ok, FunName, NewState} ->
              case invoke_js(Ctx, FunName, Args) of
                  {ok, R} ->
                      {{ok, R}, NewState};
                  Error ->
                      {Error, State}
              end;
          {Error, undefined, NewState} ->
              {Error, NewState}
      end.
  
  invoke_js(Ctx, Js, Args) ->
      try
          case js:call(Ctx, Js, Args) of
  