UNPKG
@bookbox/core
Version:
latest (0.4.0)
0.4.0
0.3.2
0.3.1
0.3.0
0.2.0
0.1.1
0.1.0
Bookbox — e-book format
@bookbox/core
/
build
/
esm
/
utils
/
iterable.js
12 lines
(11 loc)
•
323 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
export
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)); } }; }