This commit is contained in:
Mark Nadal 2015-06-08 16:54:02 -07:00
parent f8e4196dc9
commit 45122b5d9a
3 changed files with 13 additions and 11 deletions

View File

@ -1,5 +1,6 @@
language: node_js
node_js:
- 0.6
- 0.8
- 0.10
- 0.11

13
gun.js
View File

@ -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){

View File

@ -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){