You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

37 lines
811 B

import * as operations from '../operations';
export type KeymapsJSON = { [key: string]: operations.Operation };
export default class Keymaps {
constructor(
private readonly data: KeymapsJSON,
) {
}
static fromJSON(json: any): Keymaps {
if (typeof json !== 'object' || json === null) {
throw new TypeError('invalid keymaps type: ' + JSON.stringify(json));
}
let data: KeymapsJSON = {};
for (let key of Object.keys(json)) {
data[key] = operations.valueOf(json[key]);
}
return new Keymaps(data);
}
combine(other: Keymaps): Keymaps {
return new Keymaps({
...this.data,
...other.data,
});
}
toJSON(): KeymapsJSON {
return this.data;
}
entries(): [string, operations.Operation][] {
return Object.entries(this.data);
}
}