1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

Factor out MatrixClient methods to MatrixBaseApis

Starts work on a class which is intended to just wrap the Matrix apis with very
simple functions.

There is a lot more work to be done here. For now, I have just taken methods
which don't refer to anything in MatrixClient except _http. This excludes a
bunch of things which refer to $userId, as well as the login stuff because of
the deviceId stuff I've just added :/.

For now, it's an internal class. I don't really see any reason it can't be
exposed to applications, though.
This commit is contained in:
Richard van der Hoff
2016-07-28 14:51:32 +01:00
parent 59d7935934
commit 6c25110682
4 changed files with 763 additions and 579 deletions

View File

@@ -332,6 +332,30 @@ var deepCompare = module.exports.deepCompare = function(x, y) {
return true;
};
/**
* Copy properties from one object to another.
*
* All enumerable properties, included inherited ones, are copied.
*
* @param {Object} target The object that will receive new properties
* @param {...Object} source Objects from which to copy properties
*
* @return {Object} target
*/
module.exports.extend = function() {
var target = arguments[0] || {};
// disable jshint "The body of a for in should be wrapped in an if
// statement"
/* jshint -W089 */
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var propName in source) {
target[propName] = source[propName];
}
}
/* jshint +W089 */
return target;
};
/**
* Run polyfills to add Array.map and Array.filter if they are missing.