UNPKG

ai-ip-plugin

Version:

AI-IP Plugin for MCP Workflow Management with SSE streaming and event handling

68 lines 1.62 kB
"use strict"; /** * Common utility functions */ Object.defineProperty(exports, "__esModule", { value: true }); exports.generateUUID = generateUUID; exports.delay = delay; exports.deepClone = deepClone; exports.isEmpty = isEmpty; /** * Generate UUID v4 */ function generateUUID() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { const r = Math.random() * 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } /** * Delay execution */ function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } /** * Deep clone object */ function deepClone(obj) { if (obj === null || typeof obj !== 'object') { return obj; } if (obj instanceof Date) { return new Date(obj.getTime()); } if (obj instanceof Array) { return obj.map(item => deepClone(item)); } if (typeof obj === 'object') { const clonedObj = {}; for (const key in obj) { if (obj.hasOwnProperty(key)) { clonedObj[key] = deepClone(obj[key]); } } return clonedObj; } return obj; } /** * Check if value is empty */ function isEmpty(value) { if (value === null || value === undefined) { return true; } if (typeof value === 'string') { return value.trim().length === 0; } if (Array.isArray(value)) { return value.length === 0; } if (typeof value === 'object') { return Object.keys(value).length === 0; } return false; } //# sourceMappingURL=common.js.map