@bookbox/core
Version:
Bookbox — e-book format
16 lines (15 loc) • 479 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.iterableTreeGetter = void 0;
function iterableTreeGetter(options) {
const { getChildren, isLeaf } = options;
return function* iterableTree(schema) {
for (const item of schema) {
yield item;
if (isLeaf(item))
continue;
yield* iterableTree(getChildren(item));
}
};
}
exports.iterableTreeGetter = iterableTreeGetter;