flow2schema/src/utils.js

15 lines
292 B
JavaScript
Raw Normal View History

2017-11-16 15:17:15 +03:00
export function partition(iter, predicate) {
2017-10-29 01:55:39 +03:00
const left = [];
const right = [];
for (const item of iter) {
(predicate(item) ? left : right).push(item);
}
return [left, right];
}
2017-11-16 15:17:15 +03:00
export function isNode(it) {
2017-11-13 21:11:18 +03:00
return it && typeof it === 'object' && it.type;
}