UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

22 lines (21 loc) 540 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.comparePath = void 0; const comparePathComponent = (a, b) => { if (a === b) return 0; return a > b ? -1 : 1; }; const comparePath = (a, b) => { const aLen = a.length; const bLen = b.length; if (aLen !== bLen) return bLen - aLen; for (let i = 0; i < aLen; i++) { const c = comparePathComponent(a[i], b[i]); if (c !== 0) return c; } return 0; }; exports.comparePath = comparePath;