Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit

Permalink
removed deferred from remove method
Browse files Browse the repository at this point in the history
  • Loading branch information
chelm committed Aug 15, 2013
1 parent c25a929 commit 236ff7e
Show file tree
Hide file tree
Showing 485 changed files with 191 additions and 288 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified dist/browser/LICENSE
100644 → 100755
Empty file.
44 changes: 13 additions & 31 deletions dist/browser/Store/LocalStorage.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}(this, function() {
var exports = { };

var Terraformer;
var Terraformer, callback;

// Local Reference To Browser Global
if(typeof this.navigator === "object") {
Expand All @@ -41,43 +41,39 @@
}

// store the data at id returns true if stored successfully
LocalStorage.prototype.add = function(geojson, dfd){
LocalStorage.prototype.add = function(geojson, callback){
if(geojson.type === "FeatureCollection"){
for (var i = 0; i < geojson.features.length; i++) {
this.set(geojson.features[i]);
}
} else {
this.set(geojson);
}
dfd.resolve(geojson);
return dfd;
if ( callback ) callback( null, geojson );
};

LocalStorage.prototype.key = function(id){
return this._key +"_"+id;
};

// remove the data from the index and data with id returns true if removed successfully.
LocalStorage.prototype.remove = function(id, dfd){
localStorage.removeItem(this.key(id));
dfd.resolve(id);
return dfd;
LocalStorage.prototype.remove = function( id, callback ){
localStorage.removeItem( this.key( id ) );
if ( callback ) callback( null, id );
};

// return the data stored at id
LocalStorage.prototype.get = function(id, dfd){
dfd.resolve(JSON.parse(localStorage.getItem(this.key(id))));
return dfd;
LocalStorage.prototype.get = function(id, callback){
if ( callback ) callback( null, JSON.parse(localStorage.getItem(this.key(id))));
};

LocalStorage.prototype.set = function(feature){
localStorage.setItem(this.key(feature.id), JSON.stringify(feature));
if ( callback ) localStorage.setItem(this.key(feature.id), JSON.stringify(feature));
};

LocalStorage.prototype.update = function(geojson, dfd){
LocalStorage.prototype.update = function(geojson, callback){
this.set(geojson);
dfd.resolve(geojson);
return dfd;
if ( callback ) callback( null, geojson );
};

LocalStorage.prototype.toJSON = function(){
Expand All @@ -93,27 +89,13 @@
LocalStorage.prototype.serialize = function(callback){
var objs = [];

// make a new deferred
var dfd = new Terraformer.Deferred();

// map callback to dfd if we have one
if(callback){
dfd.then(function(result){
callback(null, result);
}, function(error){
callback(error, null);
});
}

for (var key in localStorage){
if(key.match(this._key)){
objs.push(localStorage.getItem(key));
}
}

dfd.resolve(JSON.stringify(objs));

return dfd;
if ( callback ) callback(null, JSON.stringify(objs));
};

LocalStorage.prototype.deserialize = function(serial){
Expand All @@ -127,4 +109,4 @@
exports.LocalStorage = LocalStorage;

return exports;
}));
}));
38 changes: 10 additions & 28 deletions dist/browser/Store/Memory.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -45,54 +45,36 @@
}

// store the data at id returns true if stored successfully
Memory.prototype.add = function(geojson, dfd){
Memory.prototype.add = function(geojson, callback){
if(geojson.type === "FeatureCollection"){
for (var i = 0; i < geojson.features.length; i++) {
this.data[geojson.features[i].id] = geojson.features[i];
}
} else {
this.data[geojson.id] = geojson;
}
dfd.resolve(geojson);
return dfd;
if ( callback ) callback( null, geojson);
};

// remove the data from the index and data with id returns true if removed successfully.
Memory.prototype.remove = function(id, dfd){
Memory.prototype.remove = function(id, callback){
delete this.data[id];
dfd.resolve(id);
return dfd;
if ( callback ) callback( null, id );
};

// return the data stored at id
Memory.prototype.get = function(id, dfd){
dfd.resolve(this.data[id]);
return dfd;
Memory.prototype.get = function(id, callback){
if ( callback ) callback( null, this.data[id] );
};

Memory.prototype.update = function(geojson, dfd){
Memory.prototype.update = function(geojson, callback){
this.data[geojson.id] = geojson;
dfd.resolve();
return dfd;
if ( callback ) callback( null );
};

Memory.prototype.serialize = function(callback){
// make a new deferred
var dfd = new Terraformer.Deferred();
var data = JSON.stringify(this.data);

// map callback to dfd if we have one
if(callback){
dfd.then(function(result){
callback(null, result);
}, function(error){
callback(error, null);
});
}

dfd.resolve(data);

return dfd;
if ( callback ) callback( null, data );
};

Memory.prototype.deserialize = function(serializedStore){
Expand All @@ -103,4 +85,4 @@
exports.Memory = Memory;

return exports;
}));
}));
Empty file modified dist/browser/arcgis.js
100644 → 100755
Empty file.
Loading

0 comments on commit 236ff7e

Please sign in to comment.