Parcourir la source

make_model: be aware of array with empyt slots

master
Bing Sun il y a 5 ans
Parent
révision
82133fed3b
Signé par: sunb ID de la clé GPG: F7795F8C590626AB
1 fichiers modifiés avec 2 ajouts et 5 suppressions
  1. +2
    -5
      src/util/make_model.js

+ 2
- 5
src/util/make_model.js Voir le fichier

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


Chargement…
Annuler
Enregistrer