@graffy/common
Version:
Common libraries that used by various Graffy modules.
10 lines (8 loc) • 334 B
JavaScript
import { isRange } from '../node';
export default function pageInfo(graph) {
if (!graph || !graph.length) return {};
const start = graph[0].key;
const lastNode = graph[graph.length - 1];
const end = isRange(lastNode) ? lastNode.end : lastNode.key;
return { start, end, hasPrev: start !== '', hasNext: end !== '\uffff' };
}