lib/ampersand-sync-localforage.js
function findAll(collection, callbacks) {
  localforage.getItem(collection.sync.localforageKey, function(err, data) {
    if (data && data.length) {
      var done = function() {
        if (callbacks.success) {
          callbacks.success(data.filter(function (model) {
            // Because the collection is stored as a list of model keys, some
            // keys may point to models that no longer exist. localForage
            // returns those as null, so just filter those out for now, and
            // when a new model is saved, the list of keys will be updated to
            // match existing models.
            return model !== null;
          }));
        }
      };

      // Only execute `done` after getting all of the
      // collection's models.
      done = after(data.length, done);

      var onModel = function(i, err, model) {
        data[i] = model;
        done();
      };

      for (var i = 0; i < data.length; ++i) {
        localforage.getItem(data[i], partial(onModel, i));
      }
    } else {
      data = [];
      if (callbacks.success) {
        callbacks.success(data);
      }
    }
  });
}
function findAll(collection, callbacks) {
  localforage.getItem(collection.sync.localforageKey, function(err, data) {
    if (data && data.length) {
      var done = function() {
        if (callbacks.success) {
          callbacks.success(data.filter(function (model) {
            // Because the collection is stored as a list of model keys, some
            // keys may point to models that no longer exist. localForage
            // returns those as null, so just filter those out for now, and
            // when a new model is saved, the list of keys will be updated to
            // match existing models.
            return model !== null;
          }));
        }
      };

      // Only execute `done` after getting all of the
      // collection's models.
      done = after(data.length, done);

      var onModel = function(i, err, model) {
        data[i] = model;
        done();
      };

      for (var i = 0; i < data.length; ++i) {
        localforage.getItem(data[i], partial(onModel, i));
      }
    } else {
      data = [];
      if (callbacks.success) {
        callbacks.success(data);
      }
    }
  });
}
Only used by `Collection#sync`.