UNPKG

@drip_sync/drip

Version:

Scalable incremental sync for MongoDB aggregation pipelines

22 lines (21 loc) 803 B
"use strict"; // Some Node drivers have means to compare object ids // eg. https://github.com/mongodb/mongo-csharp-driver/blob/bfc43d64016048d634f0f21d552df6339626ca87/src/MongoDB.Bson/ObjectModel/ObjectId.cs#L359 // But not the JS BSON implementation. So we roll our own. Object.defineProperty(exports, "__esModule", { value: true }); exports.oidLT = oidLT; const assert_1 = require("assert"); // Return true iff the first object id is less than the second. function oidLT(a, b) { const BUF_LEN = 12; const arr1 = a.id; const arr2 = b.id; (0, assert_1.strict)(arr1.length === BUF_LEN); (0, assert_1.strict)(arr2.length === BUF_LEN); for (let i = 0; i < BUF_LEN; i++) { if (arr1[i] !== arr2[i]) { return arr1[i] < arr2[i]; } } return false; }