repl.it
@paulshorey/DS Queue
JavaScript

Messing around...

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