anchor.diff:  skip_deleted(Case, A, B, C) ->
       {Case, A, B, C}.
   
  +stop_on_leaving_namespace(NS) ->
  +    fun
  +        (visit, #full_doc_info{id = Key} = FullInfo, Reds, Acc) ->
  +            case has_prefix(Key, NS) of
  +                true ->
  +                    {visit, FullInfo, Reds, Acc};
  +                false ->
  +                    {stop, FullInfo, Reds, Acc}
  +            end;
  +        (Case, KV, Reds, Acc) ->
  +            {Case, KV, Reds, Acc}
  +    end.
  +
  +has_prefix(Bin, Prefix) ->
  +    S = byte_size(Prefix),
  +    case Bin of
  +        <<Prefix:S/binary, "/", _/binary>> ->
  +            true;
  +        _Else ->
  +            false
  +    end.
  +
   pipe(Filters, Final) ->
       Wrap =
           fun
  
positive.code:         F0(C, KV, Reds, Acc)
      end,
      do_pipe(Rest, F1).
  
negative.code:     FoldFun = pipe([fun skip_deleted/4], InFun),
      {ok, _LastReduce, OutAcc} = couch_btree:fold(
          Db#db.local_tree, FoldFun, InAcc, Options),
      {ok, 0, OutAcc};
  enum_docs(Db, NS, InFun, InAcc, Options0) ->
      FoldFun = pipe([
          fun skip_deleted/4,
          stop_on_leaving_namespace(NS)], InFun),
      Options = set_namespace_range(Options0, NS),
      {ok, LastReduce, OutAcc} = couch_btree:fold(
          Db#db.id_tree, FoldFun, InAcc, Options),
      {ok, enum_docs_reduce_to_count(LastReduce), OutAcc}.
  
  extract_namespace(Options0) ->
      case proplists:split(Options0, [namespace]) of
  