mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +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){
|
||||
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(o.atom){
|
||||
tmp = (tmp.next||'')[o.atom] ;
|
||||
@ -89,7 +89,7 @@ Gun.on('create', function(root){
|
||||
if(o.atom){
|
||||
data = u;
|
||||
} 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, '') }
|
||||
|
@ -399,18 +399,15 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('read contacts in descending order', function(done){ // TODO!!!
|
||||
var all = {}, cursor = 'm', to;
|
||||
names.forEach(function(v){
|
||||
all[v] = true;
|
||||
});
|
||||
gun.get('names').get({'.': {'-': true}, '%': 1000 * 100}).once().map().once(function(data, key){
|
||||
expect(data.name).to.be.ok();
|
||||
expect(data.age).to.be.ok();
|
||||
delete all[key];
|
||||
it('read contacts in descending order', function(done){
|
||||
var to;
|
||||
const filtered = names.filter(v => v.startsWith('M'));
|
||||
|
||||
gun.get('names').get({'.': { '*': 'm' }, '%': 1000 * 100, '-': 1}).map().once(function(data){
|
||||
expect(filtered.pop()).to.be(data.name);
|
||||
clearTimeout(to);
|
||||
to = setTimeout(function(){
|
||||
expect(Gun.obj.empty(all)).to.be.ok();
|
||||
expect(filtered.length).to.be(0);
|
||||
done();
|
||||
},100);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user