You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
Remove dead code (#2510)
This commit is contained in:
@@ -109,18 +109,6 @@ describe("utils", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("checkObjectHasNoAdditionalKeys", function() {
|
|
||||||
it("should throw for extra keys", function() {
|
|
||||||
expect(function() {
|
|
||||||
utils.checkObjectHasNoAdditionalKeys({ foo: "bar", baz: 4 }, ["foo"]);
|
|
||||||
}).toThrow();
|
|
||||||
|
|
||||||
expect(function() {
|
|
||||||
utils.checkObjectHasNoAdditionalKeys({ foo: "bar" }, ["foo"]);
|
|
||||||
}).not.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("deepCompare", function() {
|
describe("deepCompare", function() {
|
||||||
const assert = {
|
const assert = {
|
||||||
isTrue: function(x: any) {
|
isTrue: function(x: any) {
|
||||||
|
@@ -109,11 +109,6 @@ export interface ISecretStorageKeyInfo {
|
|||||||
passphrase: IPassphraseInfo;
|
passphrase: IPassphraseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISecretStorageKey {
|
|
||||||
keyId: string;
|
|
||||||
keyInfo: ISecretStorageKeyInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPassphraseInfo {
|
export interface IPassphraseInfo {
|
||||||
algorithm: "m.pbkdf2";
|
algorithm: "m.pbkdf2";
|
||||||
iterations: number;
|
iterations: number;
|
||||||
|
@@ -46,13 +46,6 @@ export const newUserCancelledError = errorFactory("m.user", "Cancelled by user")
|
|||||||
*/
|
*/
|
||||||
export const newTimeoutError = errorFactory("m.timeout", "Timed out");
|
export const newTimeoutError = errorFactory("m.timeout", "Timed out");
|
||||||
|
|
||||||
/**
|
|
||||||
* The transaction is unknown.
|
|
||||||
*/
|
|
||||||
export const newUnknownTransactionError = errorFactory(
|
|
||||||
"m.unknown_transaction", "Unknown transaction",
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An unknown method was selected.
|
* An unknown method was selected.
|
||||||
*/
|
*/
|
||||||
@@ -72,11 +65,6 @@ export const newKeyMismatchError = errorFactory(
|
|||||||
"m.key_mismatch", "Key mismatch",
|
"m.key_mismatch", "Key mismatch",
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* The user does not match.
|
|
||||||
*/
|
|
||||||
export const newUserMismatchError = errorFactory("m.user_error", "User mismatch");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An invalid message was sent.
|
* An invalid message was sent.
|
||||||
*/
|
*/
|
||||||
|
80
src/utils.ts
80
src/utils.ts
@@ -144,23 +144,6 @@ export function checkObjectHasKeys(obj: object, keys: string[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that the given object has no extra keys other than the specified ones.
|
|
||||||
* @param {Object} obj The object to check.
|
|
||||||
* @param {string[]} allowedKeys The list of allowed key names.
|
|
||||||
* @throws If there are extra keys.
|
|
||||||
*/
|
|
||||||
export function checkObjectHasNoAdditionalKeys(obj: object, allowedKeys: string[]): void {
|
|
||||||
for (const key in obj) {
|
|
||||||
if (!obj.hasOwnProperty(key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (allowedKeys.indexOf(key) === -1) {
|
|
||||||
throw new Error("Unknown key: " + key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deep copy the given object. The object MUST NOT have circular references and
|
* Deep copy the given object. The object MUST NOT have circular references and
|
||||||
* MUST NOT have functions.
|
* MUST NOT have functions.
|
||||||
@@ -283,69 +266,6 @@ export function deepSortedObjectEntries(obj: any): [string, any][] {
|
|||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Inherit the prototype methods from one constructor into another. This is a
|
|
||||||
* port of the Node.js implementation with an Object.create polyfill.
|
|
||||||
*
|
|
||||||
* @param {function} ctor Constructor function which needs to inherit the
|
|
||||||
* prototype.
|
|
||||||
* @param {function} superCtor Constructor function to inherit prototype from.
|
|
||||||
*/
|
|
||||||
export function inherits(ctor: Function, superCtor: Function) {
|
|
||||||
// Add util.inherits from Node.js
|
|
||||||
// Source:
|
|
||||||
// https://github.com/joyent/node/blob/master/lib/util.js
|
|
||||||
// Copyright Joyent, Inc. and other Node contributors.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the
|
|
||||||
// "Software"), to deal in the Software without restriction, including
|
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
||||||
// persons to whom the Software is furnished to do so, subject to the
|
|
||||||
// following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included
|
|
||||||
// in all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
||||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
||||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
(ctor as any).super_ = superCtor;
|
|
||||||
ctor.prototype = Object.create(superCtor.prototype, {
|
|
||||||
constructor: {
|
|
||||||
value: ctor,
|
|
||||||
enumerable: false,
|
|
||||||
writable: true,
|
|
||||||
configurable: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Polyfills inheritance for prototypes by allowing different kinds of
|
|
||||||
* super types. Typically prototypes would use `SuperType.call(this, params)`
|
|
||||||
* though this doesn't always work in some environments - this function
|
|
||||||
* falls back to using `Object.assign()` to clone a constructed copy
|
|
||||||
* of the super type onto `thisArg`.
|
|
||||||
* @param {any} thisArg The child instance. Modified in place.
|
|
||||||
* @param {any} SuperType The type to act as a super instance
|
|
||||||
* @param {any} params Arguments to supply to the super type's constructor
|
|
||||||
*/
|
|
||||||
export function polyfillSuper(thisArg: any, SuperType: any, ...params: any[]) {
|
|
||||||
try {
|
|
||||||
SuperType.call(thisArg, ...params);
|
|
||||||
} catch (e) {
|
|
||||||
// fall back to Object.assign to just clone the thing
|
|
||||||
const fakeSuper = new SuperType(...params);
|
|
||||||
Object.assign(thisArg, fakeSuper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given value is a finite number without type-coercion
|
* Returns whether the given value is a finite number without type-coercion
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user