flow2schema/src/utils.js

15 lines
292 B
JavaScript

export function partition(iter, predicate) {
const left = [];
const right = [];
for (const item of iter) {
(predicate(item) ? left : right).push(item);
}
return [left, right];
}
export function isNode(it) {
return it && typeof it === 'object' && it.type;
}