Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
43 lines
1.0 KiB
Plaintext
43 lines
1.0 KiB
Plaintext
var File = function(url, object){
|
|
File.list = Array.isArray(File.list)? File.list : [];
|
|
File.progress = File.progress || 0;
|
|
this.progress = 0;
|
|
this.object = object;
|
|
this.url = url;
|
|
};
|
|
|
|
File.indexOf = function(term){
|
|
for(var index in File.list){
|
|
var file = File.list[index];
|
|
if (file.equals(term) || file.url === term || file.object === term) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
};
|
|
|
|
File.find = function(term){
|
|
var index = File.indexOf(term);
|
|
return ~index && File.list[index];
|
|
};
|
|
|
|
File.prototype.equals = function(file){
|
|
var isFileType = file instanceof File;
|
|
return isFileType && this.url === file.url && this.object === file.object;
|
|
};
|
|
|
|
File.prototype.save = function(update){
|
|
update = typeof update === 'undefined'? true : update;
|
|
if(Array.isArray(File.list)){
|
|
var index = File.indexOf(this);
|
|
if(~index && update) {
|
|
File.list[index] = this;
|
|
console.warn('File `%s` has been loaded before and updated now for: %O.', this.url, this);
|
|
}else File.list.push(this);
|
|
console.log(File.list)
|
|
}else{
|
|
File.list = [this];
|
|
}
|
|
return this;
|
|
};
|