mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
37 lines
906 B
JavaScript
37 lines
906 B
JavaScript
"use strict";
|
|
|
|
const Expression = require('./expression');
|
|
const NoteSet = require('../note_set');
|
|
|
|
class ChildOfExp extends Expression {
|
|
constructor(subExpression) {
|
|
super();
|
|
|
|
this.subExpression = subExpression;
|
|
}
|
|
|
|
execute(inputNoteSet, executionContext) {
|
|
const subInputNoteSet = new NoteSet();
|
|
|
|
for (const note of inputNoteSet.notes) {
|
|
subInputNoteSet.addAll(note.parents);
|
|
}
|
|
|
|
const subResNoteSet = this.subExpression.execute(subInputNoteSet, executionContext);
|
|
|
|
const resNoteSet = new NoteSet();
|
|
|
|
for (const parentNote of subResNoteSet.notes) {
|
|
for (const childNote of parentNote.children) {
|
|
if (inputNoteSet.hasNote(childNote)) {
|
|
resNoteSet.add(childNote);
|
|
}
|
|
}
|
|
}
|
|
|
|
return resNoteSet;
|
|
}
|
|
}
|
|
|
|
module.exports = ChildOfExp;
|