Advertisement
Guest User

reap from @karlnp hackmud

a guest
Sep 27th, 2016
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function(context, args) // tgt:#s.ex_corp.entryway, verb:"", opt:""
  2. {
  3.     var h = 'usage: reap {tgt:#s.ex_corp.entryway, verb:"get", opt:"blog"}';
  4.     if(!args) {
  5.         return {ok: false,msg: h};
  6.     }
  7.     var l = #s.scripts.lib();
  8.     var r = /' -- (\w*) when|(\w*) of project/gim
  9.     var matches = [];
  10.     var match = [];
  11.     if(args.tgt && args.verb && args.opt) {
  12.         var ret = args.tgt.call({[args.verb]:args.opt});
  13.         while ((match = r.exec(ret)) != null) {
  14.             var re = match[1] || match[2];
  15.             if(re === null) {
  16.                 match = [];
  17.                 continue;
  18.             }
  19.             matches.push(re);
  20.             match = [];
  21.         }
  22.         return {ok: true, msg:matches};
  23.     }else{
  24.         return {ok: false,msg:h};
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement