ScrapVim-lite-2/keyStack
ScrapVim-lite-2で使うkeyをためておくところ
配列の先頭に新しいkeyを入れるようにしよう
ScrapVim-lite-2/parserでkeyの参照がしやすくなる
一つ古いキーを取得する、などの操作が楽になる
code
from ScrapVim-lite#5fb36ea11280f000002413a7
code:script.js
export class KeyStack {
constructor() {
this._stack = [];
}
// keyを入れる
push(key) {
this._stack.push(key);
}
// stackの中身を出しつつ、this._stackを空っぽにする
flush() {
const result = ...this._stack;
this._stack = [];
return result;
}
// 一番新しいkeyを取得する
get last() {
return this.keys.length !== 0 ? this.keysthis.keys.length - 1 : undefined;
}
// 一番最初のkeyを取得する
get first() {
return this.keys0;
}
// key sequenceを取得する
get keys() {
return this._stack;
}
}
#2020-11-24 18:07:17