UNPKG

@azure/cosmos

Version:
52 lines (51 loc) 1.94 kB
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 clientSideMetrics_exports = {}; __export(clientSideMetrics_exports, { ClientSideMetrics: () => ClientSideMetrics }); module.exports = __toCommonJS(clientSideMetrics_exports); class ClientSideMetrics { constructor(requestCharge) { this.requestCharge = requestCharge; } /** * Adds one or more ClientSideMetrics to a copy of this instance and returns the result. */ add(...clientSideMetricsArray) { let requestCharge = this.requestCharge; for (const clientSideMetrics of clientSideMetricsArray) { if (clientSideMetrics == null) { throw new Error("clientSideMetrics has null or undefined item(s)"); } requestCharge += clientSideMetrics.requestCharge; } return new ClientSideMetrics(requestCharge); } static zero = new ClientSideMetrics(0); static createFromArray(...clientSideMetricsArray) { if (clientSideMetricsArray == null) { throw new Error("clientSideMetricsArray is null or undefined item(s)"); } return this.zero.add(...clientSideMetricsArray); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ClientSideMetrics });