Selaa lähdekoodia

make_model: be aware of array with empyt slots

master
Bing Sun 5 vuotta sitten
vanhempi
commit
82133fed3b
Allekirjoittanut: sunb GPG Key ID: F7795F8C590626AB
1 muutettua tiedostoa jossa 2 lisäystä ja 5 poistoa
  1. +2
    -5
      src/util/make_model.js

+ 2
- 5
src/util/make_model.js Näytä tiedosto

@@ -61,11 +61,8 @@ export default (options={}) => {
limit = _cache.upstream_limit || _cache.count || Infinity

// be lazy 1: if the data is presented, return the value immediately
//
// note that Array.every(list) == true if list is empty
let _portion = _cache.data.slice(offset, offset+limit)
if (_portion.length > 0 && _portion.every(data => data != undefined))
return Promise.resolve(_portion)
if (this.data(offset, limit).length > 0 && !this.data(offset, limit).includes(undefined))
return Promise.resolve(this.data(offset, limit))

// be lazy 2: if there is a promise, return it if ambient matches or
// cancel it


Ladataan…
Peruuta
Tallenna