UNPKG

cs2inspects

Version:

openskindb inspect sdk with bulk processing capabilities

94 lines 3.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runExamples = runExamples; const index_1 = require("./index"); async function exampleUsage() { console.log("CS2 Inspect API - Bulk Processing Example\n"); console.log("1. Single Item Inspection:"); const singleResult = await (0, index_1.inspect)("steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198023809011A40368145941D14586214085613790969"); console.log("Result:", JSON.stringify(singleResult, null, 2)); console.log("\n2. Bulk Inspection (Background Processing):"); const bulkRequest = { items: [ { s: "76561198023809011", a: "40368145941", d: "14586214085613790969", m: "0", }, { s: "76561198023809011", a: "40368145942", d: "14586214085613790970", m: "0", }, ], waitForAll: false, lowPriority: false, }; const bulkResult = await (0, index_1.bulkInspect)(bulkRequest); console.log("Bulk Result:", JSON.stringify(bulkResult, null, 2)); console.log("\n3. Bulk Inspection (Wait for All Results):"); const bulkRequestWait = { items: [ { url: "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198023809011A40368145941D14586214085613790969", }, ], waitForAll: true, }; const bulkResultWait = await (0, index_1.bulkInspect)(bulkRequestWait); console.log("Bulk Result (Wait):", JSON.stringify(bulkResultWait, null, 2)); console.log("\n4. Service Statistics:"); const stats = (0, index_1.getSimpleStats)(); console.log("Stats:", JSON.stringify(stats, null, 2)); console.log("\n5. Detailed Service Statistics:"); const detailedStats = (0, index_1.getServiceStats)(); console.log("Detailed Stats:", JSON.stringify(detailedStats, null, 2)); if (index_1.workerManager.isEnabled()) { console.log("\n6. Worker Information:"); console.log("Active Workers:", index_1.workerManager.getActiveWorkerCount()); console.log("Worker Stats:", index_1.workerManager.getWorkerStats()); } else { console.log("\n6. Workers are disabled. Set WORKER_ENABLED=true to enable multi-threading."); } } async function performanceTest() { console.log("\nPerformance Test - Processing 10 items:"); const items = Array.from({ length: 10 }, (_, i) => ({ s: "76561198023809011", a: (40368145941 + i).toString(), d: "14586214085613790969", m: "0", })); const startTime = Date.now(); const result = await (0, index_1.bulkInspect)({ items, waitForAll: true, lowPriority: true, }); const endTime = Date.now(); const duration = endTime - startTime; console.log(`Processed ${result.total} items in ${duration}ms`); console.log(`Success rate: ${(((result.processed - result.errorCount) / result.total) * 100).toFixed(2)}%`); console.log(`Average time per item: ${(duration / result.total).toFixed(2)}ms`); } async function runExamples() { try { await index_1.workerManager.init(); await exampleUsage(); await performanceTest(); } catch (error) { console.error("Example error:", error); } finally { await index_1.workerManager.shutdown(); } } if (require.main === module) { runExamples(); } //# sourceMappingURL=example.js.map