anchor.diff:  %% -------------------------------------------------------------------
   
   %% @doc Apply a function to a Riak object, and send its results
  -%%      downstream.
  -%%
  -%%      This module is intended as the second half of the emulation
  -%%      layer for running Riak KV MapReduce on top of Riak Pipe.  An
  -%%      upstream fitting should read the object out of Riak KV, and
  -%%      then send it to this fitting as a 3-tuple of the form
  -%%      `{ok, RiakObject, KeyData}'.  If there was an error reading
  -%%      the object, that can be sent to this fitting as a 3-tuple of
  -%%      the form `{{error, Reason}, {Bucket, Key}, KeyData}'.
  -%%
  -%%      This module expects a 2-tuple, `{PhaseSpec, PhaseArg}' as
  -%%      argument.  Both elements come directly from the phase
  -%%      definition in the MapReduce query: `{map, PhaseSpec, PhaseArg,
  -%%      Keep}'.
  +%% downstream.
  +%%
  +%% This module is intended as the second half of the emulation layer
  +%% for running Riak KV MapReduce on top of Riak Pipe.  An upstream
  +%% fitting should read the object out of Riak KV, and then send it to
  +%% this fitting as a 3-tuple of the form `{ok, RiakObject, KeyData}'.
  +%% If there was an error reading the object, that can be sent to this
  +%% fitting as a 3-tuple of the form `{{error, Reason}, {Bucket, Key},
  +%% KeyData}'.  (The {@link riak_kv_pipe_get} fitting conforms to this
  +%% interface.)
  +%%
  +%% This module expects a 2-tuple, `{PhaseSpec, PhaseArg}' as argument.
  +%% Both elements come directly from the phase definition in the
  +%% MapReduce query: `{map, PhaseSpec, PhaseArg, Keep}'.
  +%%
  +%% When an `ok' input arrives, the function defined by `PhaseSpec' is
  +%% evalutated as, in pseudocode: `PhaseSpec(RiakObject, KeyData,
  +%% PhaseArg)'.  The result of the function is expected to be a list.
  +%% Each element of the result list is sent downstream as an output.
  +%%
  +%% When an `error' input arrives, the behavior of this fitting depends
  +%% on whether `PhaseSpec' specifies an Erlang function or a Javascript
  +%% function.  In the case of an Erlang function, `PhaseSpec' will be
  +%% evaluated as `PhaseSpec({error, Reason}, KeyData, PhaseArg)'.  In
  +%% the case of a Javascript function, if the `Reason' is `not_found',
  +%% then the output `{not_found, {Bucket, Key}, KeyData}' is sent
  +%% downstream as output.  Other error reasons cause Javascript
  +%% evaluation to fail.
   -module(riak_kv_mrc_map).
   -behaviour(riak_pipe_vnode_worker).
   
  
positive.code: %% extract keydata from the input
  erlang_keydata({_OkError, _Input, KeyData}) -> KeyData.
  
  map_js(_JS, _Arg, {{error, notfound}, {Bucket, Key}, KeyData}) ->
      {ok, [{not_found,
             {Bucket, Key},
  
negative.code:                       "   {qfun, Function :: function()}~n"
                        "   {jsanon, {Bucket :: binary(), Key :: binary()}}~n"
                        "   {jsanon, Source :: binary()}~n"
                        "   {jsfun, Name :: binary()}~n"
                        "   {strfun, Source :: string()}~n"
                        "   {strfun, {Bucket :: binary(), Key :: binary()}}~n",
                        [?MODULE])}
      end;
  validate_arg(Other) ->
  