@paulshorey/DS Queue
JavaScript

Messing around...

I built🔨
THIS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var Queue = function(){
  
  // data
  this.list = [];
  
  // private api
  var upload = (file)=>{
    
    // simulate random upload wait times
    setTimeout(()=>{
      this.list.splice(this.list.indexOf(file),1);
      console.log("\nuploaded: "+file.path+'...','waiting to upload: ',this.list,"\n");
    },Math.random()*10000);
  }
  
  // public api
  return {
    files_uploading: [],
    files_added: this.list,
    file_add: function(file){
      this.files_added.push(file);
      upload(file);
    }
    
  }  

}

var uploads = new Queue();
uploads.file_add({path:'kitty.jpg'});
uploads.file_add({path:'kat.gif'});
uploads.file_add({path:'giraffe.jpg'});
uploads.file_add({path:'snoop-doggy-dogg.mp3'});
Native Browser JavaScript