mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-06-04 04:48:55 +00:00
feat: changes
This commit is contained in:
@@ -152,25 +152,35 @@ export function mapParseResult(
|
||||
};
|
||||
}
|
||||
|
||||
export function iterActions(
|
||||
export function iterActions<T = void>(
|
||||
chord: ChordMeta,
|
||||
callback: (action: ActionMeta) => void,
|
||||
) {
|
||||
callback: (action: ActionMeta) => T | void,
|
||||
): T | undefined {
|
||||
if (chord.input) {
|
||||
for (const action of chord.input.actions) {
|
||||
callback(action);
|
||||
const result = callback(action);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chord.compounds) {
|
||||
for (const compound of chord.compounds) {
|
||||
for (const action of compound.actions) {
|
||||
callback(action);
|
||||
const result = callback(action);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chord.phrase) {
|
||||
for (const action of chord.phrase.actions) {
|
||||
callback(action);
|
||||
const result = callback(action);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user