From 96be393bdcb21db7ffbcfe604d182bdadcb6cf54 Mon Sep 17 00:00:00 2001 From: Alex LaFroscia Date: Sun, 18 Jan 2015 04:30:34 -0500 Subject: [PATCH] Add .map to Chain --- gun.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gun.js b/gun.js index 6eabd0e9..781bb451 100644 --- a/gun.js +++ b/gun.js @@ -459,6 +459,22 @@ this._.dud = Gun.fns.is(dud)? dud : function(){}; return this; } + Chain.map = function(cb){ + var gun = this; + gun.shot.then(function(val){ + cb = cb || function(){}; + //console.log("map module is loading", val); + Gun.obj.map(val, function(obj, soul){ + //console.log(obj, Gun.is.soul(obj)); + if(!Gun.is.soul(obj)){ return; } + gun.load(obj).get(function(obj){ + delete obj._; + cb.call(this, obj, soul); + }); + }); + }); + return gun; + } }(Gun.chain = Gun.prototype)); ;(function(Util){ Util.fns = {};