diff --git a/.travis.yml b/.travis.yml index 742f4ca0..a5540c04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - 0.6 - 0.8 - 0.10 - 0.11 \ No newline at end of file diff --git a/gun.js b/gun.js index be9b8f15..eb08c469 100644 --- a/gun.js +++ b/gun.js @@ -520,11 +520,13 @@ return gun; } Chain.map = function(cb, opt){ - var gun = this; - opt = (Gun.obj.is(opt)? opt : (opt? {node: true} : {})); // TODO: BUG: inverse the default here. - gun.val(function(val){ - cb = cb || function(){}; - Gun.obj.map(val, function(val, field){ // by default it maps over everything. + var gun = this, ctx = {}; + opt = (Gun.obj.is(opt)? opt : (opt? {node: true} : {})); + cb = cb || function(){}; + + gun._.status('node').event(function($){ + var node = gun.__.graph[$.soul]; + Gun.obj.map(node, function(val, field){ if(Gun._.meta == field){ return } if(Gun.is.soul(val)){ gun.get(val).val(function(val){ // should map have support for `.not`? @@ -536,7 +538,6 @@ } }); }); - var ahead = gun.chain(); return ahead; return gun; } Chain.not = function(cb){ diff --git a/test/common.js b/test/common.js index 5d63681a..b4c4265b 100644 --- a/test/common.js +++ b/test/common.js @@ -1238,18 +1238,18 @@ describe('Gun', function(){ }); }); }); - return; + it('map', function(done){ var c = 0, map = gun.put({a: {here: 'you'}, b: {go: 'dear'}, c: {sir: '!'} }); - map.map(function(obj, soul){ + map.map(function(obj, field){ c++; - if(soul === 'a'){ + if(field === 'a'){ expect(obj.here).to.be('you'); } - if(soul === 'b'){ + if(field === 'b'){ expect(obj.go).to.be('dear'); } - if(soul === 'c'){ + if(field === 'c'){ expect(obj.sir).to.be('!'); } if(c === 3){