mirror of
https://github.com/amark/gun.git
synced 2025-11-23 22:15:55 +00:00
(WIP) Bug rad reverse sorting (#1021)
* bug: fixes issue with reverse sorting * chore: updates unit test * bug: new array not needed as filter already return a new one
This commit is contained in:
parent
1c25266935
commit
45dd008cb7
@ -56,7 +56,7 @@ Gun.on('create', function(root){
|
|||||||
if((tmp = get['%']) || o.limit){
|
if((tmp = get['%']) || o.limit){
|
||||||
o.limit = (tmp <= (o.pack || (1000 * 100)))? tmp : 1;
|
o.limit = (tmp <= (o.pack || (1000 * 100)))? tmp : 1;
|
||||||
}
|
}
|
||||||
if(has['-'] || (soul||{})['-']){ o.reverse = true }
|
if(has['-'] || (soul||{})['-'] || get['-']){ o.reverse = true; }
|
||||||
if((tmp = (root.next||'')[soul]) && tmp.put){
|
if((tmp = (root.next||'')[soul]) && tmp.put){
|
||||||
if(o.atom){
|
if(o.atom){
|
||||||
tmp = (tmp.next||'')[o.atom] ;
|
tmp = (tmp.next||'')[o.atom] ;
|
||||||
@ -89,7 +89,7 @@ Gun.on('create', function(root){
|
|||||||
if(o.atom){
|
if(o.atom){
|
||||||
data = u;
|
data = u;
|
||||||
} else {
|
} else {
|
||||||
Radix.map(data, each); // IS A RADIX TREE, NOT FUNCTION!
|
Radix.map(data, each, o); // IS A RADIX TREE, NOT FUNCTION!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!graph && data){ each(data, '') }
|
if(!graph && data){ each(data, '') }
|
||||||
|
|||||||
@ -399,18 +399,15 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('read contacts in descending order', function(done){ // TODO!!!
|
it('read contacts in descending order', function(done){
|
||||||
var all = {}, cursor = 'm', to;
|
var to;
|
||||||
names.forEach(function(v){
|
const filtered = names.filter(v => v.startsWith('M'));
|
||||||
all[v] = true;
|
|
||||||
});
|
gun.get('names').get({'.': { '*': 'm' }, '%': 1000 * 100, '-': 1}).map().once(function(data){
|
||||||
gun.get('names').get({'.': {'-': true}, '%': 1000 * 100}).once().map().once(function(data, key){
|
expect(filtered.pop()).to.be(data.name);
|
||||||
expect(data.name).to.be.ok();
|
|
||||||
expect(data.age).to.be.ok();
|
|
||||||
delete all[key];
|
|
||||||
clearTimeout(to);
|
clearTimeout(to);
|
||||||
to = setTimeout(function(){
|
to = setTimeout(function(){
|
||||||
expect(Gun.obj.empty(all)).to.be.ok();
|
expect(filtered.length).to.be(0);
|
||||||
done();
|
done();
|
||||||
},100);
|
},100);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user