function GET(url, callback) {
  if (url in xhrCache) {
    if (xhrCache[url] === 'pending') {
      setTimeout(function() {
        GET(url, callback);
      }, 10);
    } else {
      setTimeout(function() {
        callback(xhrCache[url]);
      }, 0);
    }
    return;
  }
  xhrCache[url] = 'pending';

  var xhr = new XMLHttpRequest();
  xhr.open('GET', url, true);
  xhr.responseType = 'arraybuffer';
  xhr.onload = function() {
    if (xhr.status === 200) {
      xhrCache[url] = xhr.response;
      callback(xhr.response);
    } else {
      console.log('GET ' + url + ' failed: ' + xhr.status);
    }
  };
  xhr.send();
}
// it to |callback| once the request completes successfully.
it to |callback| once the request completes successfully.
it to |callback| once the request completes successfully .
function GET(url, callback) {
  if (url in xhrCache) {
    if (xhrCache[url] === 'pending') {
      setTimeout(function() {
        GET(url, callback);
      }, 10);
    } else {
      setTimeout(function() {
        callback(xhrCache[url]);
      }, 0);
    }
    return;
  }
  xhrCache[url] = 'pending';
  var xhr = new XMLHttpRequest();
  xhr.open('GET', url, true);
  xhr.responseType = 'arraybuffer';
  xhr.onload = function() {
    if (xhr.status === 200) {
      xhrCache[url] = xhr.response;
      callback(xhr.response);
    } else {
      console.log('GET ' + url + ' failed: ' + xhr.status);
    }
  };
  xhr.send();
}
function GET ( url , callback ) { if ( url in xhrCache ) { if ( xhrCache [ url ] === 'pending' ) { setTimeout ( function ( ) { GET ( url , callback ) ; } , 10 ) ; } else { setTimeout ( function ( ) { callback ( xhrCache [ url ] ) ; } , 0 ) ; } return ; } xhrCache [ url ] = 'pending' ; var xhr = new XMLHttpRequest ( ) ; xhr . open ( 'GET' , url , true ) ; xhr . responseType = 'arraybuffer' ; xhr . onload = function ( ) { if ( xhr . status === 200 ) { xhrCache [ url ] = xhr . response ; callback ( xhr . response ) ; } else { console . log ( 'GET ' + url + ' failed: ' + xhr . status ) ; } } ; xhr . send ( ) ; }
it to |callback| once the request completes successfully.
it to |callback| once the request completes successfully .