[Build] Use native bind

...in CouchPersistenceProvider and ElasticPersistenceProvider, per
https://github.com/nasa/openmct/pull/724#issuecomment-193542314
This commit is contained in:
Victor Woeltjen 2016-04-08 16:25:32 -07:00
parent 0b11ddbcfd
commit f6a9c90cef
2 changed files with 8 additions and 20 deletions
platform/persistence

@ -54,12 +54,6 @@ define(
this.path = path;
}
function bind(fn, thisArg) {
return function () {
return fn.apply(thisArg, arguments);
};
}
// Pull out a list of document IDs from CouchDB's
// _all_docs response
function getIdsFromAllDocs(allDocs) {
@ -117,29 +111,29 @@ define(
};
CouchPersistenceProvider.prototype.listObjects = function () {
return this.get("_all_docs").then(bind(getIdsFromAllDocs, this));
return this.get("_all_docs").then(getIdsFromAllDocs.bind(this));
};
CouchPersistenceProvider.prototype.createObject = function (space, key, value) {
return this.put(key, new CouchDocument(key, value))
.then(bind(this.checkResponse, this));
.then(this.checkResponse.bind(this));
};
CouchPersistenceProvider.prototype.readObject = function (space, key) {
return this.get(key).then(bind(this.getModel, this));
return this.get(key).then(this.getModel.bind(this));
};
CouchPersistenceProvider.prototype.updateObject = function (space, key, value) {
var rev = this.revs[key];
return this.put(key, new CouchDocument(key, value, rev))
.then(bind(this.checkResponse, this));
.then(this.checkResponse.bind(this));
};
CouchPersistenceProvider.prototype.deleteObject = function (space, key, value) {
var rev = this.revs[key];
return this.put(key, new CouchDocument(key, value, rev, true))
.then(bind(this.checkResponse, this));
.then(this.checkResponse.bind(this));
};
return CouchPersistenceProvider;

@ -58,12 +58,6 @@ define(
this.path = path;
}
function bind(fn, thisArg) {
return function () {
return fn.apply(thisArg, arguments);
};
}
// Issue a request using $http; get back the plain JS object
// from the expected JSON response
ElasticPersistenceProvider.prototype.request = function (subpath, method, value, params) {
@ -141,11 +135,11 @@ define(
ElasticPersistenceProvider.prototype.createObject = function (space, key, value) {
return this.put(key, value).then(bind(this.checkResponse, this));
return this.put(key, value).then(this.checkResponse.bind(this));
};
ElasticPersistenceProvider.prototype.readObject = function (space, key) {
return this.get(key).then(bind(this.getModel, this));
return this.get(key).then(this.getModel.bind(this));
};
ElasticPersistenceProvider.prototype.updateObject = function (space, key, value) {
@ -158,7 +152,7 @@ define(
};
ElasticPersistenceProvider.prototype.deleteObject = function (space, key) {
return this.del(key).then(bind(this.checkResponse, this));
return this.del(key).then(this.checkResponse.bind(this));
};
return ElasticPersistenceProvider;