瀏覽代碼

make_model: be aware of array with empyt slots

master
Bing Sun 5 年之前
父節點
當前提交
82133fed3b
簽署人: sunb GPG Key ID: F7795F8C590626AB
共有 1 個文件被更改,包括 2 次插入5 次删除
  1. +2
    -5
      src/util/make_model.js

+ 2
- 5
src/util/make_model.js 查看文件

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


Loading…
取消
儲存