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.
|
|
|
import * as operations from '../operations';
|
|
|
|
|
|
|
|
type OperationJson = {
|
|
|
|
type: string
|
|
|
|
} | {
|
|
|
|
type: string;
|
|
|
|
[prop: string]: string | number | boolean;
|
|
|
|
};
|
|
|
|
export type KeymapsJSON = { [key: string]: OperationJson };
|
|
|
|
|
|
|
|
export default class Keymaps {
|
|
|
|
constructor(
|
|
|
|
private readonly data: { [key: string]: operations.Operation },
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
static fromJSON(json: KeymapsJSON): Keymaps {
|
|
|
|
let entries: { [key: string]: operations.Operation } = {};
|
|
|
|
for (let key of Object.keys(json)) {
|
|
|
|
entries[key] = operations.valueOf(json[key]);
|
|
|
|
}
|
|
|
|
return new Keymaps(entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|