@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
68 lines (67 loc) • 2 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var nonStreamingOrderByMap_exports = {};
__export(nonStreamingOrderByMap_exports, {
NonStreamingOrderByMap: () => NonStreamingOrderByMap
});
module.exports = __toCommonJS(nonStreamingOrderByMap_exports);
class NonStreamingOrderByMap {
map;
compareFn;
constructor(compareFn) {
this.compareFn = compareFn;
this.map = /* @__PURE__ */ new Map();
}
set(key, value) {
if (!this.map.has(key)) {
this.map.set(key, value);
} else {
const oldValue = this.map.get(key);
if (this.replaceResults(oldValue, value)) {
this.map.set(key, value);
}
}
}
get(key) {
if (!this.map.has(key)) return void 0;
return this.map.get(key);
}
/**
* Returns all the values in the map and resets the map.
*/
getAllValuesAndReset() {
const res = [];
for (const [key, value] of this.map) {
res.push(value);
this.map.delete(key);
}
return res;
}
replaceResults(res1, res2) {
const res = this.compareFn(res1, res2);
if (res < 0) return true;
return false;
}
size() {
return this.map.size;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
NonStreamingOrderByMap
});